Files
AiSOC/examples
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
..

AiSOC examples

Each scenario in this directory is a small, self-contained alert fixture you can walk through the AiSOC agent funnel two ways:

  1. Real ingest — aisoc submit examples/alerts/<name>.json posts the events to the running stack (started by make up). The CLI is packages/aisoc-cli; install it with pip install -e packages/aisoc-cli from the repo root. It POSTs to /api/v1/alerts/submit, which writes the alert row directly, so the result lands in the Investigation Rail within a second without waiting on the Kafka pipeline.

  2. Offline simulator — aisoc-sandbox demo --scenario <name> runs the same scenario through a zero-dependency in-memory simulator. No Docker, no API key, completes in < 5 s. pip install aisoc-sandbox resolves on PyPI today; pip install -e packages/aisoc-sandbox from the repo root runs it against your own changes. It reaches no verdict and emits no confidence score — it computes what arithmetic over the events allows and says so where it cannot, which is a narrower claim than the walkthroughs below describe for the full stack.

The five scenarios cover the most common attack patterns in modern SOC alert queues; collectively they exercise eleven MITRE ATT&CK techniques across initial access, credential access, lateral movement, privilege escalation, and exfiltration.

ID Title MITRE Severity Walkthrough
lateral-movement Impossible-travel Okta sign-in T1078, T1078.004 high walkthrough
aws-credential-exfil IAM keys used from new ASN, then s3:GetObject flood T1552, T1567, T1078.004 critical walkthrough
phishing-payload Click-through to credential-harvest page T1566, T1566.002 high walkthrough
kubernetes-privesc Namespace SA bound to cluster-admin T1098, T1078 critical walkthrough
github-token-theft PAT leaked — six private repos cloned in 11 s T1078, T1555, T1567 high walkthrough

Layout

examples/
├── README.md                    # this file
├── alerts/
│   ├── lateral-movement.json    # 5x production-faithful OCSF/native-shape
│   ├── aws-credential-exfil.json
│   ├── phishing-payload.json
│   ├── kubernetes-privesc.json
│   └── github-token-theft.json
├── lateral-movement.md          # walkthroughs — what the agent does, step by step
├── aws-credential-exfil.md
├── phishing-payload.md
├── kubernetes-privesc.md
└── github-token-theft.md

The bundled offline scenarios live in packages/aisoc-sandbox/src/aisoc_sandbox/scenarios/ — same IDs, simplified shape so the simulator stays a single small package.

Contributing a new scenario

Open a good first issue or send a PR that adds:

  1. examples/alerts/<id>.json — production-shape fixture with at least one MITRE technique and a clear narrative in the _description.
  2. examples/<id>.md — walkthrough using the existing pages as a template.
  3. packages/aisoc-sandbox/src/aisoc_sandbox/scenarios/<id>.json — simplified sandbox variant so aisoc-sandbox demo --scenario <id> works.
  4. Update the table in examples/README.md and (if relevant) the tables in README.md and packages/aisoc-sandbox/README.md.

A maintainer will pair the scenario with at least one detection rule in detections/ so the production funnel can actually fire on it.