Files
AiSOC/examples/github-token-theft.md
T
Beenu Arora 8edb91cc22 sandbox: compute the verdict from the events, or say it was not computed (#1604)
* sandbox: compute the verdict from the events, or say it was not computed

A community reviewer fed the offline demo a harmless login — same user,
same address, New York both times, eight hours apart, tagged T1078 at
severity `high` — and got back "the geo pivot between sequential events
is physically impossible", high confidence, 83/100. Relabelling genuine
impossible-travel events `info` returned "L4 — fully autonomous closure"
and "auto-execute eligible". Every claim reproduced against main.

The cause was structural and visible from three signatures:

    _confidence_band(*, severity: str, technique_count: int)
    _automation_tier(severity: str)
    DeterministicReasoner.explain(self, *, technique: str | None)

None of the three decision functions could see the events. The rationale
came from a fixed table keyed on the MITRE technique; 83 is 75 (high) +
4 x 2 techniques; the tier was a dict keyed on severity, so a label in
an input file selected the autonomy posture. Several canned rationales
asserted measurements nothing had taken — a Welford-online baseline, a
domain registration age, a file-extension churn rate — and the class
docstring named the intent outright: that a reader "can't tell the
rendered ledger apart at a glance" from the live demo. That is the
family this project deletes rather than rewords, so it is deleted.

What replaces it, in two halves:

Compute what is computable. `aisoc_sandbox.signals` derives geo-velocity
(a great-circle distance over an elapsed time), event burst rate, origin
diversity and a domain age the payload itself records. Each signal
prints its own arithmetic and carries three outcomes, not two:
`not_computable` is distinct from `does_not_hold`, because "the city is
not in the table" and "the user did not move" are different facts. An
unresolvable or ambiguous city is named, never substituted with a
centroid. The reporter's benign payload now reports 0.0 km apart, 0.0
km/h, and says T1078 is not supported by anything computed here; their
relabelled payload still identifies the travel as impossible, from the
arithmetic, and determines no tier at all. New York to Saint Petersburg
across eight hours is reported as an ordinary 861 km/h flight, because
the threshold is a real quotient and not a city-pair lookup.

Say so where it cannot. Confidence score, L0–L4 tier, approval posture,
related-case count, entity risk and hunt matches are now NotComputed
values carrying their reason — never a plausible figure, and never a
zero: a sweep that did not run reports "unknown", since it looked
nowhere rather than finding nothing. Tool calls carry executed=false.
The hunt stage no longer reports "no additional compromised entities",
which was a negative finding from a search that never ran. The ruleset
figure is derived from corpus-stats.json by a new sync script instead of
the hand-typed "800+" that had gone stale by a factor of three. The
synthetic-run notice moved onto every decision line and to the head of
the JSON payload, because the reporter read the verdict several screens
below the banner.

Proof. `test_honesty.py` adds 41 cases; 37 fail against the pre-fix tree
and the four that pass are parametrised siblings of ones that fail.
`scripts/check_sandbox_honesty.py` drives the real CLI over the bundled
scenarios and four adversarial payloads, sweeps severity across the
ladder with the events held fixed, and refuses the *shape* statically —
a dict mapping a technique id or a severity name to a sentence or a
score — so a reintroduction is caught in a new module before anything
calls it. Measured both ways: 222 problems against origin/main at
517a08f6, 0 after. Its self-test injects six violations, one per rule.

`_stable_int` is gone with the figures it stabilised; a reproducibly
fabricated related-case count was never the better half of that problem.
The determinism suite now pins the real arithmetic instead, and an AST
test keeps any published figure from coming out of a hash or an RNG.

Also corrected: the five example walkthroughs quoted the sandbox's
confidence scores as fact, and examples/README.md and SUPPORT.md still
said the PyPI package was unpublished — it has resolved since 0.1.0.

Reported by a community reviewer who was right on every count and
careful to scope what they had not tested.

* chore: merge main and move the matrix tallies to 352/347

`main` gained a claim-matrix row while this branch was queued, so the
three surfaces that carry the tally — the matrix summary, ROADMAP.md and
the compliance evidence pack — were one behind the table and
`readme_gates` caught it. Recomputed with check_claim_gate_matrix.py
rather than edited, which is what that gate exists to force.
2026-11-02 05:31:32 -08:00

4.0 KiB

Walkthrough — github-token-theft

GitHub PAT leaked. A personal-access token tied to carol@example.com is used from an ASN the org has never previously contacted, against six private repositories in 11 seconds. The token's repo scope is wide enough to ex-filtrate every source tree Carol can read.

  • Fixture: examples/alerts/github-token-theft.json
  • MITRE techniques: T1078, T1555, T1567
  • Severity at intake: high
  • What the sandbox computes: event_burst — 4 clones in 11.0 s, all inside one 60 s window

The step-by-step below describes the full stack. The offline aisoc-sandbox run shows the same ledger shape but computes only what arithmetic over these events can give it — there is no model, no graph, no Qdrant and no lake in the wheel, and it emits no confidence score, no automation tier and no verdict. Values it cannot compute say so, with the reason attached. What it does compute for this scenario is listed above.

Run it

# Offline simulator:
aisoc-sandbox demo --scenario github-token-theft

# Real stack (after `make up`, with `pip install -e packages/aisoc-cli`):
aisoc submit examples/alerts/github-token-theft.json

What the agent does, step by step

Step 0 · DetectAgent · detect

The github-pat-bulk-clone detection fires on six private-repo clones from the same hashed_token_id within an 11-second window — well inside the per-token velocity threshold. Fusion correlates against the threat-intel feed and notes that the source ASN has appeared in two other OSS supply-chain incidents in the last 90 days.

Step 1 · TriageAgent · triage

The graph walk pivots from carol to her org memberships and the repos she has push access to. The triage rationale notes that infostealer behaviour against the OS-native keystore is consistent with the access pattern (machine compromised, PAT lifted, used immediately).

Decision (sandbox): 2 of 4 signals computed from the events, 1 fired. No confidence score: the sandbox runs no model, so it has nothing to calibrate one from.

Step 2 · HuntAgent · hunt

Sweeps for any other action by Carol's PAT or session in the last 24 h — including pushes, branch creations, and Action triggers. The hunt confirms the actor has only cloned so far; no malicious code has been pushed yet, which means there's a window to revoke before secrets are siphoned out of acme/secrets-vault.

Step 3 · RespondAgent · respond

Proposes a five-action containment that closes both the credential path and the secrets-at-rest path:

  • github.pat.revoke({"user": "carol", "token_prefix": "ghp_xxxAAAAA"})
  • github.user.session.revoke_all({"user": "carol"})
  • github.org.audit_member({"user": "carol", "lookback_days": 30})
  • secrets.rotate({"repositories": ["acme/secrets-vault", "acme/iam"]})
  • case.create(...) at severity high

Decision (live stack): 5 actions proposed; awaiting analyst approval (severity high).

Decision (sandbox): the same actions are listed as call shapes, each marked executed: false. The automation tier and the approval posture read not computed — the live stack resolves both from the capability contract and the approval matrix, and neither is a thing a severity label can select.

What the analyst would do next

  1. Approve github.pat.revoke first — it has zero blast radius for anyone other than Carol.
  2. Look at every commit + Action run + secret access from the cloned repos in the last 7 days; even read-only cloning gives the actor any secret that was committed historically (which is why secrets.rotate is part of the response, not optional).
  3. Reach Carol via an out-of-band channel (phone, in-person) — not Slack or email — to confirm she didn't run the clones and to investigate her machine.
  4. Open a separate workstream on the org's PAT lifecycle — the org should be on fine-grained GitHub App tokens, not personal-access tokens with repo scope.