Skip to content

armgit / AiSOC

Public Imported from GitHub
0

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.

Merge PR #1303: depth 6.1 — AI asset inventory

beenuare57958f82623
diff --cc DEPTH_PROGRESS.md
index 1209295d6,ca371fc17..8a66fe502
--- a/DEPTH_PROGRESS.md
+++ b/DEPTH_PROGRESS.md
@@@ -77,15 -70,19 +77,28 @@@ is written. Next free at capture: migra
| migration `113` | 8.1 — `113_entitlement_enforcement.sql` | claimed |
| ADR `0011` | 8.1 — truncating a hash-chained audit log | claimed |
+| migration `104` | 5.4 stateful user/manager verification (verification requests, answers, tenant opt-in) | claimed |
+| migration `105` | 5.6 plain-language playbook drafts (draft, preview, approval) | claimed |
+
+Lane B claimed `102`/`103` and landed that claim on `main` first, so Lane C's
+two moved to `104`/`105` and `102_playbook_verification.sql` was renamed with
+it. Both lanes had claimed before writing, as the plan requires -- what the
+rule cannot prevent is two lanes claiming the same free number before either
+merges, so re-read `services/api/migrations/` **and** this table before
+picking one.
+ | migration `110` | 6.1 — `110_ai_assets.sql` | claimed |
+ | migration `111` | 6.4 — `111_ai_agent_identities.sql` | claimed |
+ | ADR `0011` | 6.6 — AI containment arms off by default, and the rollback a kill-switch needs | claimed |
+ | — | 5.4 — `104_playbook_verification.sql` on `depth/5.4-5.6-lane-c`, and 7.1 — `104_phishing_campaigns.sql` on `depth/7.1-7.3-phishing` | **collision, unresolved here.** Both lanes wrote a `104` on a branch without a row in this table. Phase 9's `104` is the one with a claim, so these two need renumbering by their own lanes; recorded rather than renamed from outside, because renaming another lane's migration from here is how a branch comes back to a file that no longer exists |
+
+ Highest migration on `main` at claim time was `101_audit_immutable_nullify.sql`,
+ so `095`--`101` were taken by sibling lanes between the capture above and this
+ claim; re-read `services/api/migrations/` rather than trusting the capture row.
+
+ The same is true of this table: `104` was already written on two sibling
+ lanes' branches with no row here, which is how lanes collide. Phase 6's
+ numbers were picked after reading `services/api/migrations/` on `main` **and**
+ `git ls-tree` over every `origin/*` branch, not from the row above.
Phase 9 re-read `services/api/migrations/` on 2026-10-11 before claiming:
`101_audit_immutable_nullify.sql` was still the highest on `main`, and `102`
@@@ -807,7 -831,8 +917,9 @@@ endpoint produces once triage falls thr
| 2026-10-09 | 3.3 | Identity privilege (18 rules) and a per-tenant first-seen store (2) built; 5 rules were never unreachable (gate operator drift, D9); 18 retired with a reason (D10). `MAX_UNREACHABLE` 45 → 2, the two remaining both needing the 3.4 baseline. Two matcher operators three shipped rules already used were implemented. |
| 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-11 | 5.4 | Reproduced: `check_stateful_verification.py` against `origin/main` reported eight problems — no `verification.py` at all, `verify_user` absent from the control-flow table, no resume path, no escalation, no `timed_out`, no sweep, no migration and no writer for the opt-in table. Built the stage machine on the existing pause row rather than a second table. Three negative controls recorded in the PR: reverting the run-loop break fails three tests including the `wait` regression (D11), removing `manager_ref=_extract_manager(body)` fails three SCIM tests, and removing `ENABLE ROW LEVEL SECURITY` from migration 102 fails the live tenancy test with "tenant B read tenant A's verification policy". Two pre-existing tests pinned the old shape and were widened rather than relaxed: the control-flow table's membership (still an equality, now of four) and the sweeper's return dict. Writing the gate found a hole in the gate: its first block extractor matched `\n\n\n`, which finds nothing for the *last* function in a module, so the ordering rule was skipped entirely over an injected violation. |
+ | 2026-10-11 | 6.2 | Reproduced: 13 of 16 new cases failed, driving the shapes the four endpoint connectors actually emit. Root cause was 6.1's endpoint branch reading `process.name` off OCSF, which the canonical profile never populates — it found `None` on every real source while its own tests passed. Fixed by reconstructing the connector namespace. Shipped the osquery pack (5 queries, packs 5 -> 6), the source-capability table, the operator doc and a 6-rule gate. Fusion suite 683 -> 700. Claim row is PARTIAL: no osquery agent runs in CI, and the EDR connectors return vendor detections rather than process telemetry, so the plan's "CrowdStrike, Defender, SentinelOne" wording is not satisfiable with these connectors. |
+ | 2026-10-11 | 6.1 | Reproduced: the new gate reported nine problems across five of eight rules on the unmodified tree. Built `aisoc_ai_assets` (migration 110), its routes behind a new `ai_estate:*` permission pair, the fusion recorder that writes it on the default profile, the `AIAsset` graph label with `OPERATES`/`HOSTS` edges, and the `/ai-estate` page. Two negative controls against a real PostgreSQL: reverting `NULLS NOT DISTINCT` turns one provider-key row into three, and a `USING (true)` policy leaks across tenants. Claim matrix 302 -> 303 rows, 300 GATED. Writing the gate found two blind spots in the gate itself. |
| 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 | 8.1 | parity 4.1's containerised-IdP leg **observed to pass**, both halves: `keycloak-oidc` verifies a real `id_token` against Keycloak's published JWKS with an audience-mismatch negative control, and `keycloak-saml` walks the whole SP-initiated flow to the real ACS and signs `[email protected]` in as `infosec`, with an untrusted-key control answering 400. Run `38124780886`, as `ENVIRONMENT=test` against the DML-only `aisoc_app` role. The SSO claim row moves PARTIAL → GATED on that evidence. Building it found two shipped defects no self-authored provider could expose: `resolve_saml_connection` bound `:i` untyped so `:i IS NULL` raised on asyncpg, and Keycloak's default role-list mapper emits one `<Attribute Name="Role">` per role, which python3-saml refuses. |
| 2026-10-11 | 8.1 | WebAuthn as a console second factor and MFA enforced per role. Fixing the branch's own gates found three `passkey_credentials` reads scoped by user id alone on a tenant-scoped table, and a permission-model violation where the MFA policy route imported `ROLE_PERMISSIONS` directly; the role *vocabulary* now has one owner in `role_grants.known_roles()`. 23 of 23 live cases pass against real Postgres, and deleting the login integration fails 14 of them — measured, where the workflow had said eight. |
diff --cc ROADMAP.md
index fa6f0557c,9504abd47..2218cdb8e
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -45,7 -45,9 +45,8 @@@ A proof-first, security-first program t
- **Phase D (breadth):** D1 eight connectors (QRadar/Exabeam/Securonix/Devo/Netskope/Windows-Sysmon/Zeek-Suricata/syslog-CEF) · D2 AI/LLM-usage audit connector + `llm-*` detections + hot/cold lake tiering · D3 live-vendor mock-server smoke.
- **Phase E (prove it):** E1 CI-gated benchmark scoreboard tied to a deterministic live-agent MITRE-accuracy run.
- The claim-to-gate matrix stands at **303 rows — 301 GATED / 2 PARTIAL / 0 NO GATE**. Two rows are PARTIAL. "The retention window a tenant chooses is the one the lake honours" stays PARTIAL until a live ClickHouse test watches a row survive past the old 90-day boundary. "Cloud-native collection" stays PARTIAL until a capture recorded from a live Event Hub replaces the fixture synthesised from the Avro specification. "SSO completes a sign-in" was the third, and depth 8.1 closed it by building the gate it named rather than by relabelling: `sso-live.yml` now stands up a containerised Keycloak and both legs have been observed to pass — `keycloak-oidc` takes a real `id_token` through `_verify_id_token` against the provider's published JWKS, and `keycloak-saml` walks the whole SP-initiated flow to the real ACS. Every other product claim is backed by a failing test, none is a named deferral either, and the ratchet (`MAX_NO_GATE=0`) forbids any regression. Every PARTIAL row was closed by building the gate it named, never by relabelling. The last two rested on the live-agent eval workflow, which this file said had simply never run: the real reason was that its live path imported a class that exists nowhere in `services/agents`, so its first dispatch failed in 92 seconds and every later one would have. With that fixed the workflow measures, and the groundedness floor is **0.40 over a deterministic 10-incident slice**, derived from ten runs across two environments rather than chosen — seven local runs returning 0.5561 to four decimal places, three GitHub-runner runs returning 0.5821, 0.5329 and 0.5933. Every one is a locally-served `qwen2.5:0.5b`; no hosted provider has been exercised and the floor describes none. Count the table rows with `python3 scripts/check_claim_gate_matrix.py` rather than trusting a figure quoted in prose — this line has gone stale before. The six lettered deferrals are scoped in [`docs/audit/DEFERRED_SUBPHASES.md`](docs/audit/DEFERRED_SUBPHASES.md).
+ The claim-to-gate matrix stands at **304 rows — 301 GATED / 3 PARTIAL / 0 NO GATE**. Two rows are PARTIAL. "The retention window a tenant chooses is the one the lake honours" stays PARTIAL until a live ClickHouse test watches a row survive past the old 90-day boundary. "Cloud-native collection" stays PARTIAL until a capture recorded from a live Event Hub replaces the fixture synthesised from the Avro specification. "SSO completes a sign-in" was the third, and depth 8.1 closed it by building the gate it named rather than by relabelling: `sso-live.yml` now stands up a containerised Keycloak and both legs have been observed to pass — `keycloak-oidc` takes a real `id_token` through `_verify_id_token` against the provider's published JWKS, and `keycloak-saml` walks the whole SP-initiated flow to the real ACS. Every other product claim is backed by a failing test, none is a named deferral either, and the ratchet (`MAX_NO_GATE=0`) forbids any regression. Every PARTIAL row was closed by building the gate it named, never by relabelling. The last two rested on the live-agent eval workflow, which this file said had simply never run: the real reason was that its live path imported a class that exists nowhere in `services/agents`, so its first dispatch failed in 92 seconds and every later one would have. With that fixed the workflow measures, and the groundedness floor is **0.40 over a deterministic 10-incident slice**, derived from ten runs across two environments rather than chosen — seven local runs returning 0.5561 to four decimal places, three GitHub-runner runs returning 0.5821, 0.5329 and 0.5933. Every one is a locally-served `qwen2.5:0.5b`; no hosted provider has been exercised and the floor describes none. Count the table rows with `python3 scripts/check_claim_gate_matrix.py` rather than trusting a figure quoted in prose — this line has gone stale before. The six lettered deferrals are scoped in [`docs/audit/DEFERRED_SUBPHASES.md`](docs/audit/DEFERRED_SUBPHASES.md).
+
-The claim-to-gate matrix stands at **304 rows — 301 GATED / 3 PARTIAL / 0 NO GATE**. Four rows are PARTIAL. "The retention window a tenant chooses is the one the lake honours" stays PARTIAL until a live ClickHouse test watches a row survive past the old 90-day boundary. "Cloud-native collection" stays PARTIAL until a capture recorded from a live Event Hub replaces the fixture synthesised from the Avro specification. And "SSO completes a sign-in": fix pass 4.1 drove both handlers end to end against real Postgres and real signed assertions, and it stays PARTIAL until the containerised-IdP leg of `sso-live.yml` has been observed to pass, because the identity providers in that suite are trust material this repository authors. "Endpoint discovery of the AI estate" stays PARTIAL until a containerised osquery runs `packs/aisoc-ai-estate.yaml` end to end: the pack is asserted to load and to select the columns the recorder classifies on, but no test has watched a real `osqueryd` execute one of its queries against a real filesystem. Every other product claim is backed by a failing test, none is a named deferral either, and the ratchet (`MAX_NO_GATE=0`) forbids any regression. Every PARTIAL row was closed by building the gate it named, never by relabelling. The last two rested on the live-agent eval workflow, which this file said had simply never run: the real reason was that its live path imported a class that exists nowhere in `services/agents`, so its first dispatch failed in 92 seconds and every later one would have. With that fixed the workflow measures, and the groundedness floor is **0.40 over a deterministic 10-incident slice**, derived from ten runs across two environments rather than chosen — seven local runs returning 0.5561 to four decimal places, three GitHub-runner runs returning 0.5821, 0.5329 and 0.5933. Every one is a locally-served `qwen2.5:0.5b`; no hosted provider has been exercised and the floor describes none. Count the table rows with `python3 scripts/check_claim_gate_matrix.py` rather than trusting a figure quoted in prose — this line has gone stale before. The six lettered deferrals are scoped in [`docs/audit/DEFERRED_SUBPHASES.md`](docs/audit/DEFERRED_SUBPHASES.md).
## v4.0 — Shipped
diff --cc schemas/graph-schema.yaml
index 6ce08fa8a,445155f6c..e8fc99c6e
--- a/schemas/graph-schema.yaml
+++ b/schemas/graph-schema.yaml
@@@ -358,34 -358,27 +358,55 @@@ node_labels
- { name: last_rotated, type: datetime, required: false }
- { name: rotation_days, type: int, required: false }
+ # ── v1.2: session depth (depth plan 2.4) ───────────────────────────────────
+ - label: Session
+ description: >-
+ One session as the vendor understands it, or the closest the vendor lets
+ us get. The node exists so a traversal can ask what else one session
+ touched; the authoritative row is in Postgres, because ADR-0010 measured
+ Neo4j at 42.2% of the CORE profile's remaining memory and kept the graph
+ in `full`. `id` is the same deterministic uuid the Postgres row and the
+ ClickHouse column carry, so the three join without coordinating.
+ properties:
+ - { name: id, type: string, required: true }
+ - { name: tenant_id, type: string, required: true }
+ # As the vendor spells it, never a hash: an analyst pastes this into the
+ # vendor's own console, and a value that exists nowhere else cannot be
+ # looked up anywhere.
+ - { name: session_key, type: string, required: true }
+ # vendor_session | vendor_credential | vendor_flow | derived. A property
+ # rather than four labels, because the kinds are a strength ordering and
+ # a query naming each one it wants would silently miss a fifth.
+ - { name: key_kind, type: string, required: true }
+ - { name: key_source, type: string, required: false }
+ - { name: source, type: string, required: true }
+ - { name: principal, type: string, required: false }
+ - { name: originating_human, type: string, required: false }
+ - { name: first_seen_at, type: datetime, required: true }
+ - { name: last_seen_at, type: datetime, required: true }
+ - { name: ended_at, type: datetime, required: false }
+ - { name: event_count, type: int, required: false }
+ # ── v1.3: the AI estate ────────────────────────────────────────────────────
+ - label: AIAsset
+ description: >-
+ One observed AI asset: an AI application, a coding agent, an MCP server,
+ an IDE extension, a model-provider key or an OAuth grant to an AI app.
+ One label with a `kind` property rather than six labels, because every
+ question asked of this data is asked across the kinds — what does this
+ person run, what runs on this laptop — and six labels would make each
+ of those a six-way union. Tenant-scoped: an agent is somebody's.
+ Written by `extractAIEstate` from `ai-runtime` / `ai-finding` telemetry
+ and from process activity naming a known agent binary. The durable
+ record is `aisoc_ai_assets` in Postgres; this is the projection an
+ investigation traverses.
+ properties:
+ - { name: id, type: string, required: true }
+ - { name: tenant_id, type: string, required: true }
+ - { name: kind, type: string, required: true }
+ - { name: external_id, type: string, required: true }
+ - { name: display_name, type: string, required: false }
+ - { name: vendor, type: string, required: false }
+ - { name: model, type: string, required: false }
# ── v1.1: threat depth ─────────────────────────────────────────────────────
# Malware, Campaign, ThreatActor, Technique and Tactic are *global*
@@@ -746,41 -739,30 +767,60 @@@ relationships
- { name: snapshot_id, type: string, required: true }
- { name: role, type: string, required: false }
+ # ── v1.2: session depth (depth plan 2.4) ───────────────────────────────────
+ - name: OPENED_SESSION
+ source_label: Identity
+ target_label: Session
+ event_edge: true
+ description: >-
+ "What else did this principal do", without scanning every event the
+ principal ever produced.
+ # ── v1.3: the AI estate ────────────────────────────────────────────────────
+ # Two new types rather than a second pair of endpoints on OWNED_BY and
+ # RUNS: each relationship here declares one source label and one target
+ # label, so reusing them would make this file assert something untrue of
+ # the edges the extractor actually writes.
+ - name: OPERATES
+ source_label: User
+ target_label: AIAsset
+ event_edge: true
+ description: >-
+ The person an AI asset acted for. Absent rather than guessed when the
+ source did not say: an unlinked agent is the finding, not a blank.
properties:
- { name: ts, type: datetime, required: true }
- { name: source_event_id, type: string, required: true }
- { name: snapshot_id, type: string, required: true }
+ - name: ISSUED_SESSION
+ source_label: Session
+ target_label: Session
+ event_edge: true
+ description: >-
+ The assumed-role chain. This edge exists on the issuing STS call and
+ nowhere else: a chained session's own events name only the role it
+ assumed, so without it the person behind the second hop is unrecoverable
+ once the issuing record ages out of the lake. `link_source` records which
+ field established it, because a chain built from a caller-chosen
+ roleSessionName is weaker evidence than one built from sourceIdentity.
+ properties:
+ - { name: ts, type: datetime, required: true }
+ - { name: source_event_id, type: string, required: true }
+ - { name: snapshot_id, type: string, required: true }
+ - { name: link_source, type: string, required: false }
+
+ - name: SESSION_RAISED
+ source_label: Session
+ target_label: Alert
+ event_edge: true
+ description: What the session is accused of.
+ - name: HOSTS
+ source_label: Endpoint
+ target_label: AIAsset
+ event_edge: true
+ description: >-
+ The device an AI asset ran on. This is the edge containment reads:
+ without it a kill-switch has nowhere to act.
properties:
- { name: ts, type: datetime, required: true }
- { name: source_event_id, type: string, required: true }
diff --cc services/fusion/app/main.py
index d8ce126ee,b0d511ecc..a1c4484fa
--- a/services/fusion/app/main.py
+++ b/services/fusion/app/main.py
@@@ -149,13 -157,9 +158,14 @@@ async def lifespan(app: FastAPI)
# with hot reload. Without it the engine evaluated the shared
# corpus and nothing else, so a tenant who disabled a noisy rule
# in the console kept receiving its alerts.
- overlays=OverlayCache(_overlay_pool()),
+ overlays=OverlayCache(_fusion_pool()),
+ # Depth plan 2.4. Sessions per principal: the stateful half of the
+ # projection `session.go` derives per event. Disabled by the same
+ # switch as the alert sink, because a session row nothing can join
+ # an alert to is a row nobody reads.
+ sessions=SessionStore(_fusion_pool()) if settings.alert_sink_enabled else None,
ueba_cache=ueba_cache,
+ ai_assets=ai_assets,
)
set_worker(worker)
diff --cc services/fusion/app/workers/consumer.py
index 5c255e20e,cfc9fca75..804a10004
--- a/services/fusion/app/workers/consumer.py
+++ b/services/fusion/app/workers/consumer.py
@@@ -71,7 -61,7 +73,8 @@@ class FusionWorker
first_seen: Any | None = None,
ueba_cache: UebaSignalCache | None = None,
overlays: OverlayCache | None = None,
+ sessions: SessionStore | None = None,
+ ai_assets: AiAssetRecorder | None = None,
) -> None:
self._engine = engine
self._sink = sink
@@@ -180,15 -156,8 +187,17 @@@
await asyncio.sleep(interval)
if self._lake is not None:
await self._lake.flush_if_stale()
+ if self._ai_assets is not None:
+ await self._ai_assets.flush_if_stale()
+ if self._sessions is None:
+ continue
+ now = time.monotonic()
+ if now - last_sweep < SESSION_SWEEP_SECONDS:
+ continue
+ last_sweep = now
+ closed = await self._sessions.close_idle()
+ if closed:
+ logger.info("Closed idle derived sessions", closed=closed)
except asyncio.CancelledError: # pragma: no cover — shutdown path
pass
diff --cc services/ingest/internal/graph/schema.go
index 3d07361ba,322aa2a4e..931adb103
--- a/services/ingest/internal/graph/schema.go
+++ b/services/ingest/internal/graph/schema.go
@@@ -182,7 -181,7 +194,8 @@@ var AllNodeLabels = []NodeLabel
NodeApplication,
NodeCloudAccount,
NodeSecret,
+ NodeSession,
+ NodeAIAsset,
NodeIOC,
NodeMalware,
NodeCampaign,
@@@ -253,19 -252,16 +266,28 @@@ const
// is who an escalation actually goes to.
RelOwnedBy RelType = "OWNED_BY"
+ // ── v1.3: the AI estate ───────────────────────────────────────────
+ // Two new types rather than reusing OWNED_BY and RUNS. Those two are
+ // declared in the YAML with one source label and one target label each
+ // (Application -> Employee, Resource -> Application), and a second pair
+ // of endpoints cannot be expressed on them without making the schema
+ // file say something that is not true of the edges actually written.
+ RelOperates RelType = "OPERATES" // User -> AIAsset: who runs it
+ RelHosts RelType = "HOSTS" // Endpoint -> AIAsset: where it ran
+
// ── v1.1: threat depth ────────────────────────────────────────────
+ // ── v1.2: session depth (depth plan 2.4) ─────────────────────────
+ // Identity|User -> Session. "What else did this principal do" without
+ // scanning every event the principal ever produced.
+ RelOpenedSession RelType = "OPENED_SESSION"
+ // Session -> Session. The assumed-role chain. This edge exists on the
+ // issuing STS call and nowhere else: a chained session's own events
+ // name only the role, so without it the person behind the second hop
+ // is unrecoverable once the issuing record ages out of the lake.
+ RelIssuedSession RelType = "ISSUED_SESSION"
+ // Session -> Alert. What the session is accused of.
+ RelSessionRaised RelType = "SESSION_RAISED"
+
RelObservedIOC RelType = "OBSERVED_IOC" // Alert -> IOC
RelIndicates RelType = "INDICATES" // IOC -> Malware
RelPartOf RelType = "PART_OF" // Malware -> Campaign
@@@ -300,9 -296,8 +322,11 @@@ var AllRelTypes = []RelType
RelInAccount,
RelStores,
RelOwnedBy,
+ RelOpenedSession,
+ RelIssuedSession,
+ RelSessionRaised,
+ RelOperates,
+ RelHosts,
RelObservedIOC,
RelIndicates,
RelPartOf,