Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.
Python agentic-aiai-securityalert-triageblue-teamcybersecuritydetection-engineeringincident-responselanggraphllm-agentsmcpmitre-attackmodel-context-protocolpurple-teamsecurity-operationsself-hostedsiemsoarsocthreat-detectionthreat-intelligence
docs(depth): record 7.3, its claim row and two deviations
Beenu Aroraf3cb04bee741
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 59b54ed67..5e6f80d11 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -231,6 +231,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added+- **An adversary-in-the-middle detection family, on sessions (depth 7.3).**+ The attack is invisible to every rule the corpus had, and the reason is+ structural rather than a coverage gap: an AiTM proxy relays the victim's+ credentials *and* their MFA response, so the sign-in is legitimate by every+ check the identity provider makes. There is no failed authentication to+ count and often no impossible travel to measure, because the proxy sits in+ the victim's own country. What gives it away is the stolen session being+ used from somewhere it was never established — so the entity these rules+ group by is the **session**, not the user. That is why the connector work+ had to land first: `OktaConnector.normalize()` returned `None` for+ `session_id`, `src_asn`, `user_agent`, `client_browser` and+ `mfa_satisfied` on a System Log row carrying all five, because the engine+ flattens `raw_event` exactly one level and `authenticationContext` arrives+ as a dict — the same shape as the `outcome` hoist in #1279. Four rules:+ three distinct-value rules at threshold two (a second network, a second+ client family, a second country for one session) and one ordered sequence+ at `critical` — an MFA-satisfied sign-in, then the same session from+ another network within half an hour, which a threshold cannot express.+ `mfa_satisfied` is three-valued, because treating "this event says nothing+ about MFA" as `False` would fire on every directory read, and a denied push+ is an MFA event and emphatically not a satisfied one. On Entra,+ `correlationId` is deliberately **not** a fallback for `sessionId`: one+ identifies a request and the other a session, and substituting would make+ every sign-in its own session so the reuse detection could never fire while+ looking like it worked. The clause "this event carries a session" is spelled+ `session_id_neq: null`, using an operator that exists — inventing `_exists`+ would have been read as a field literally named `session_id_exists`, which+ is the `approver_role_neq` defect one release later. Fixtures are+ hand-authored from an Okta System Log row and a Microsoft Graph `signIn`+ resource rather than synthesised from the rules, and the negative twin+ inverts only the clause each rule is about — same session, same user, same+ event type, same outcome, same network. Windowed rules 72 → 76.+- `services/api/app/models/detection_rule.py` maps the `author` column, whichhas existed since `001_init.sql` and was mapped by nothing — while fusion'stenant overlay reads it on every reload to say *who* silenced a rule when itdiff --git a/DEPTH_PROGRESS.md b/DEPTH_PROGRESS.mdindex a75a88df4..d585503db 100644--- a/DEPTH_PROGRESS.md+++ b/DEPTH_PROGRESS.md@@ -407,7 +407,7 @@ invented fields on the first run of the gate.- [ ] **7.1** Intake to purge (gap-closure Phase 10 / parity 6.4)- [ ] **7.2** Header, URL and attachment analysis-- [ ] **7.3** Adversary-in-the-middle session reuse+- [x] **7.3** Adversary-in-the-middle session reuse## Phase 8: Enterprise gates@@ -442,3 +442,51 @@ invented fields on the first run of the gate.| 2026-10-09 | 3.2 | Ordered and unordered sequences in the windowed engine; all four translatable Sigma correlation types compile, seven refusal reasons recorded. No upstream correlation rule exists in this tree to import (D8), so the corpus is first-party and labelled as such. || 2026-10-09 | 4.1 | Reproduced: `check_cloud_native_collection.py` on the unmodified tree reported all three collection paths absent. Implemented `aws_cloudtrail_s3` (SQS-notified S3 objects; management events, data events and VPC flow logs; delete-after-emit), `gcp_pubsub` (REST pull on a log-sink subscription; ack-after-read) and `azure_event_hubs` (Capture blobs over the Data Lake Gen2 JSON API, with a focused Avro OCF reader). Negative controls recorded in the PR: deleting the SQS message before the object is read, acknowledging the Pub/Sub batch before it is built, ignoring the Avro union branch index, and ignoring the flow-log header line each fail a named test, and all were restored. Connectors suite 1014 -> 1098 passed. || 2026-10-09 | 3.1 | All 74 decided. 50 translated into `wd-*` rules derived from each original's own clauses and replayed through the real engine (162 assertions); 24 refused with a reason across five kinds. `MAX_UNREACHABLE` 119 → 45, published executable 2,603 → 2,529, windowed 18 → 68. Three findings recorded as D4–D6 below. |+| 2026-10-11 | 7.3 | Reproduced: `OktaConnector.normalize()` returned `None` for `session_id`, `src_asn`, `user_agent`, `client_browser` and `mfa_satisfied` on a System Log row carrying all five, so the family had nothing to group by and could not have been written. Same shape as the `outcome` hoist in #1279 -- the engine flattens `raw_event` one level and `authenticationContext` arrives as a dict. Hoisted the session, network and client fields on Okta and Entra, then wrote four rules grouping by **session** rather than by user: three distinct-value rules at threshold 2 and one ordered sequence at critical. Fixtures hand-authored from an Okta System Log row and a Graph `signIn` resource; the negative twin inverts only the clause each rule is about. Windowed 72 -> 76; executable detections unchanged at 2,511, because a windowed rule is not in that corpus. Negative controls: removing the `session_id` hoist reds 4 connector tests; switching one rule's `group_by` to `actor_email` reds 2 engine tests. Two findings recorded as D-7.3a (the threshold engine windows by arrival and only sequences window by event time) and D-7.3b (the reported-message link is deferred with a reason). |++### D-7.3a -- The threshold engine windows by arrival, not by event time++Found by a test that failed. An earlier version of+`test_a_replay_outside_the_sequence_window_does_not_fire` fed two events whose+`event_time` fields were two hours apart and expected the threshold rules to+stay quiet. They fired, because `_evaluate_thresholds` scores each Redis+member with `time.time()` while `_evaluate_sequences` reads+`parse_event_time`. Both events arrived in the same second, so the window+never moved.++This is recorded rather than patched. Arrival-time scoring is what makes a+threshold cheap, and a connector polling a vendor every five minutes delivers+a burst whose arrival order is the only clock fusion has for it. The+consequence is specific and worth knowing: **the one-hour figure on the three+`wd-aitm-*` threshold rules is a budget on ingestion, not on the vendor's+timestamps.** A replay that happened an hour ago and is polled now lands in+the same window as the sign-in. For this family that direction is the safe+one -- it widens rather than narrows -- but a future rule whose correctness+depends on the vendor's clock needs a sequence, not a threshold.++### D-7.3b -- The reported-message half of 7.3 is deferred, with the reason++The plan's 7.3 asks for the session-reuse family "plus the link from a+reported message whose URL precedes that sign-in". The session half is+implemented and gated. The link is not, and inventing it would have been+worse than deferring it.++The obstacle is not effort, it is that nothing can feed it today. The+reported-message URLs live in `aisoc_phishing_submissions` in `services/api`+(depth 7.1), and the windowed engine consumes Kafka events in+`services/fusion`; fusion has no read of the API's tables and should not grow+one for a detection. The alternative -- staging a *gateway's* phishing+verdict instead of AiSOC's own reported-message corpus -- was examined and+refused: the one secure-email-gateway connector in the tree, `proofpoint`,+fetches `/v2/siem/messages/blocked` only, so it never sees a click, and its+`normalize()` emits neither the recipient nor the URL. Hoisting fields for an+event the connector does not fetch is a rule that cannot fire wearing a rule+that can.++What would close it, in the order it has to happen: `proofpoint` (or a+`netskope` / `zscaler` web arm) fetching click events and emitting+`recipient`, `url` and the gateway's classification; then a sequence rule+staging that click and the MFA-satisfied sign-in by the same principal. The+AiSOC-authored half -- joining a tenant's *own* reported-message URLs to a+sign-in -- belongs in the API beside the campaign store rather than in+fusion, as an enrichment on the alert the session rules raise.diff --git a/docs/audit/CLAIM_TO_GATE_MATRIX.md b/docs/audit/CLAIM_TO_GATE_MATRIX.mdindex bbcc6e6db..21fd6447e 100644--- a/docs/audit/CLAIM_TO_GATE_MATRIX.md+++ b/docs/audit/CLAIM_TO_GATE_MATRIX.md@@ -310,6 +310,7 @@ Statuses: `GATED` (a CI job fails when the claim stops being true) · `PARTIAL`| A stored report schedule produces a report, and says whether it was delivered | `apps/docs/docs/operations/notifications.md` (scheduled reports) | `ci.yml :: Python — Tests` (api, `test_delivery_5_2.py::TestCronMatching` — nine match cases, six unparseable expressions that raise rather than matching everything, a schedule falling between two five-minute polls, an already-run schedule not firing twice, and a week-long outage collapsing into one report) | core | GATED | `report_templates.cron_schedule` was storable, editable and **read by nothing**, so a tenant could set a schedule, see it saved and never receive anything. Asking "does the current minute match" would have checked 08:57 and 09:02 and never 09:00; the matcher asks over the interval since the last run. Migration 098 adds `delivery_status`, because `delivered_at` alone cannot tell "no relay configured" from "the relay refused" from "not run yet" || An outbound event webhook is signed, retried, and its failures are visible | `apps/docs/docs/operations/notifications.md` (outbound webhooks) | `ci.yml :: Python — Tests` (api, `test_delivery_5_2.py::TestWebhookSignature` and `::TestWebhookDelivery` — signature round-trip through the real client, a modified body and a re-stamped timestamp both refused, five malformed headers refused without raising, the 4xx/5xx split, the ladder ending in the dead-letter view, byte-identical bodies across attempts, and an undecryptable secret killing the delivery rather than sending it unsigned) | core | GATED | AiSOC could be told things and could tell nobody anything: `grep -rln outbound_webhook` over `services/` and `apps/` returned nothing. The signature is the shape Stripe, GitHub and Slack use, because a scheme nobody recognises is a scheme nobody verifies. The retry queue and the dead-letter list are one table at different points on one ladder, so there is no window where a delivery is in neither || The fix for `fake_tool_output` is measured on payloads authored after it was frozen, and that measurement carries no floor | `services/agents/tests/adversarial/behavioural_holdout.py`; `apps/docs/docs/benchmark.md` | `ci.yml :: Python — Tests` (`tests/adversarial/test_behavioural_holdout.py` pins the held-out flip, catch and unsafe-action rates **exactly**, in both directions, so a change moving any of them either way has to say so in the same commit; every payload is asserted to carry a steering phrase or an action trigger so the denominator cannot be padded with strings that were never going to work, asserted disjoint from the tuned corpus, and every declared seam asserted to have a payload) + `test_tool_result_channel.py` (the channel invariant the guard rule rests on, walked out of the service's syntax tree, plus a 20-entry good corpus and a negative control that lifts the rule from the table and watches the family reopen) | core | GATED | **Flip 85% and catch 10% on 20 held-out payloads, against 0% and 100% on the 3 tuned ones.** Published rather than closed, because tuning until they agree is the move this repository has measured the cost of. A worst-case probe rather than a neutral sample: the tuned payloads predate the fix and the held-out ones were aimed at named properties of it, so part of the gap is adversarial-versus-naive. The sharper finding is that the guard and the ledger-provenance demotion **share a detector**, so they are one control counted twice rather than two layers, which a test asserts. No floor and no ratchet, deliberately: a target on a held-out set is an instruction to tune against it, and a test fails if the two rates ever agree so that agreement cannot pass silently |+| An adversary-in-the-middle session replay is detected on the session, not on the user | `services/fusion/app/data/windowed_ruleset.json` (`wd-aitm-*`); depth plan 7.3 | `ci.yml :: python-test` (fusion, `test_aitm_session_rules.py` — 20 cases driving the **real** `WindowedDetectionEngine`, the real matcher and the **shipped** ruleset loaded off disk rather than a hand-made rule list: the replay fires all four rules, the negative twin fires none of them, a single event fires nothing, two sessions for one user do not complete each other, an event with no session id is not grouped at all, the sequence does not fire without its MFA stage or in the wrong order, and one tenant's sign-in cannot complete another's replay) + `ci.yml` connectors matrix (`test_aitm_session_fields_reach_detection.py` — 18 cases driving the real `OktaConnector.normalize()` and `AzureEntraConnector.normalize()` over hand-authored vendor payloads, including that `mfa_satisfied` is three-valued and that a Graph `correlationId` does not stand in for a missing `sessionId`) + `ci.yml :: python-lint` (`check_windowed_translation.py` — the ceiling of 0 windowed rules selecting on a computed field, which is what forced the connector hoist rather than a rule naming a field nothing emits; `export_windowed_ruleset.py --check` for drift between the authored list and the artefact the engine loads) | core | GATED | The two halves live in different interpreters because `services/connectors` and `services/fusion` both name their package `app`; the connector test pins the payload the engine test transcribes, so a connector change that drops a field reds the connector test rather than silently passing the engine one |## Summary