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
fix(api): the cross-tenant assertion never ran, and the watermark write named no tenant
Beenu Arora50097cc9b8d9
diff --git a/ROADMAP.md b/ROADMAP.mdindex 8e0bf2111..2a7dc5819 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -45,7 +45,7 @@ A proof-first, security-first program to make every README claim gate-backed, cl- **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 **302 rows — 299 GATED / 3 PARTIAL / 0 NO GATE**. Three 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. 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 **303 rows — 299 GATED / 4 PARTIAL / 0 NO GATE**. Four rows are PARTIAL. "A reported phishing message can be grouped into a campaign and purged across its recipients" is PARTIAL because no Microsoft 365 or Google Workspace tenant is reachable from CI or from this maintainer, so every vendor claim in depth 7.1 rests on the documented request shape and a recorded mock; it returns to GATED when a live tenant is available. "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. 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 — Shippeddiff --git a/apps/docs/docs/compliance/evidence-pack.md b/apps/docs/docs/compliance/evidence-pack.mdindex 1dd2f4f30..90473f0d5 100644--- a/apps/docs/docs/compliance/evidence-pack.md+++ b/apps/docs/docs/compliance/evidence-pack.md@@ -34,7 +34,7 @@ and says so.| Claim-to-gate traceability | Every product claim mapped to the CI job that fails when it stops being true | `docs/audit/CLAIM_TO_GATE_MATRIX.md` |The last row is the one worth reading first. It is the honest index: 299 rows-`GATED`, 3 `PARTIAL`, and a ratchet that refuses to let a row sit at+`GATED`, 4 `PARTIAL`, and a ratchet that refuses to let a row sit at`NO GATE`. Re-read the figure from the table rather than from here — a countcopied into prose goes stale in silence, which is why`scripts/readme_gates.py` cross-checks this sentence against the matrix.diff --git a/docs/openapi.yaml b/docs/openapi.yamlindex 36056e700..4892fe996 100644--- a/docs/openapi.yaml+++ b/docs/openapi.yaml@@ -15599,6 +15599,225 @@ paths:$ref: '#/components/schemas/HTTPValidationError'security:- HTTPBearer: []+ /api/v1/phishing/reports:+ post:+ tags:+ - phishing+ summary: Intake a reported phishing message+ description: 'Take a reported message from one of the three intake doors.+++ Distinct from ``/submit``, which takes an artefact an analyst typed. This++ takes a *message somebody received*, so it carries the two fields the++ response turns on and ``/submit`` has never had: the internet message id++ that finds the copies, and the recipients that bound the purge.'+ operationId: report_api_v1_phishing_reports_post+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/ReportRequest'+ required: true+ responses:+ '201':+ description: Successful Response+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/ReportResponse'+ '422':+ description: Validation Error+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/HTTPValidationError'+ security:+ - HTTPBearer: []+ /api/v1/phishing/campaigns:+ get:+ tags:+ - phishing+ summary: List phishing campaigns+ operationId: list_campaigns_api_v1_phishing_campaigns_get+ security:+ - HTTPBearer: []+ parameters:+ - name: limit+ in: query+ required: false+ schema:+ type: integer+ maximum: 200+ minimum: 1+ default: 50+ title: Limit+ - name: offset+ in: query+ required: false+ schema:+ type: integer+ minimum: 0+ default: 0+ title: Offset+ responses:+ '200':+ description: Successful Response+ content:+ application/json:+ schema:+ type: array+ items:+ type: object+ additionalProperties: true+ title: Response List Campaigns Api V1 Phishing Campaigns Get+ '422':+ description: Validation Error+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/HTTPValidationError'+ /api/v1/phishing/campaigns/{campaign_id}:+ get:+ tags:+ - phishing+ summary: Get a phishing campaign and its recipients+ operationId: get_campaign_api_v1_phishing_campaigns__campaign_id__get+ security:+ - HTTPBearer: []+ parameters:+ - name: campaign_id+ in: path+ required: true+ schema:+ type: string+ format: uuid+ title: Campaign Id+ responses:+ '200':+ description: Successful Response+ content:+ application/json:+ schema:+ type: object+ additionalProperties: true+ title: Response Get Campaign Api V1 Phishing Campaigns Campaign Id Get+ '422':+ description: Validation Error+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/HTTPValidationError'+ /api/v1/phishing/campaigns/{campaign_id}/purge:+ post:+ tags:+ - phishing+ summary: Propose or run a purge across a campaign's recipients+ description: 'One proposal, one dispatch per mailbox, each graded on its own.+++ ``actions:execute`` rather than ``cases:write``: this reaches out of the++ platform and removes mail, so it is gated like every other action++ surface in this service rather than like a case note.+++ Deliberately **not** ``actions:contain``, which is what the capability++ contract declares. That string is held by no role in ``ROLE_PERMISSIONS``++ except the two wildcards, so gating the route on it would ship a route++ only an administrator could reach while reading as though analysts++ could. The contract''s permission is enforced at the dispatcher, where a++ principal exists; here the question is who may *ask*, and++ ``actions:execute`` is the permission this service already means by++ that — its own comment says it "gates the dry-run preview only; a live++ containment goes through the approval path", which is exactly the split++ between ``execute: false`` and ``execute: true`` below.'+ operationId: purge_campaign_api_v1_phishing_campaigns__campaign_id__purge_post+ security:+ - HTTPBearer: []+ parameters:+ - name: campaign_id+ in: path+ required: true+ schema:+ type: string+ format: uuid+ title: Campaign Id+ requestBody:+ required: true+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/PurgeRequest'+ responses:+ '200':+ description: Successful Response+ content:+ application/json:+ schema:+ type: object+ additionalProperties: true+ title: Response Purge Campaign Api V1 Phishing Campaigns Campaign+ Id Purge Post+ '422':+ description: Validation Error+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/HTTPValidationError'+ /api/v1/phishing/campaigns/{campaign_id}/restore:+ post:+ tags:+ - phishing+ summary: Restore a purged campaign's messages+ description: 'The reverse of the purge, over the mailboxes it actually executed+ on.+++ Only rows the purge executed on are restored. Attempting a restore on a++ mailbox that was previewed, failed, or never held the message would++ report work that did not happen.'+ operationId: restore_campaign_api_v1_phishing_campaigns__campaign_id__restore_post+ security:+ - HTTPBearer: []+ parameters:+ - name: campaign_id+ in: path+ required: true+ schema:+ type: string+ format: uuid+ title: Campaign Id+ responses:+ '200':+ description: Successful Response+ content:+ application/json:+ schema:+ type: object+ additionalProperties: true+ title: Response Restore Campaign Api V1 Phishing Campaigns Campaign+ Id Restore Post+ '422':+ description: Validation Error+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/HTTPValidationError'/api/v1/phishing/submissions:get:tags:@@ -32428,6 +32647,24 @@ components:- label- publisher_idtitle: PublisherKeyOut+ PurgeRequest:+ properties:+ execute:+ type: boolean+ title: Execute+ description: 'False previews: every mailbox is graded and reported, nothing+ is removed, and no row reads ''purged''. Preview is the default because+ this is the most disruptive verb the product offers.'+ default: false+ confidence:+ anyOf:+ - type: number+ maximum: 1.0+ minimum: 0.0+ - type: 'null'+ title: Confidence+ type: object+ title: PurgeRequestQueryRequest:properties:question:@@ -33025,6 +33262,64 @@ components:required:- nametitle: ReportDefinitionBody+ ReportRequest:+ properties:+ source:+ type: string+ enum:+ - m365_graph+ - google_workspace+ - email_inbox+ title: Source+ payload:+ additionalProperties: true+ type: object+ title: Payload+ description: 'The vendor''s own payload, unmodified: a Microsoft Graph message+ resource, a Gmail Message, or the event the email_inbox connector emits.+ Normalised server-side by app.services.phishing.intake, which is the only+ place that knows the three shapes.'+ reported_by:+ type: string+ title: Reported By+ description: Who reported it, when the payload does not say.+ default: ''+ type: object+ required:+ - source+ - payload+ title: ReportRequest+ ReportResponse:+ properties:+ submission:+ $ref: '#/components/schemas/SubmissionResponse'+ campaign_id:+ anyOf:+ - type: string+ format: uuid+ - type: 'null'+ title: Campaign Id+ campaign_created:+ type: boolean+ title: Campaign Created+ grouping_basis:+ type: string+ title: Grouping Basis+ default: ''+ grouping_is_factual:+ type: boolean+ title: Grouping Is Factual+ default: false+ recipient_count:+ type: integer+ title: Recipient Count+ default: 0+ type: object+ required:+ - submission+ - campaign_id+ - campaign_created+ title: ReportResponseResetRequest:properties:reason:diff --git a/services/actions/tests/test_mailbox_remediation.py b/services/actions/tests/test_mailbox_remediation.pyindex d17a9bff1..b1b6d3ebf 100644--- a/services/actions/tests/test_mailbox_remediation.py+++ b/services/actions/tests/test_mailbox_remediation.py@@ -213,6 +213,7 @@ class TestADryRunNeverReportsAVendorCall:@pytest.mark.parametrize("vendor", VENDORS)async def test_dry_run_is_simulated_and_executed_is_false(self, vendor: str, _enabled) -> None:executor = registry.get_executor(vendor, "purge_email")+ assert executor is not Noneresult = await executor.execute(LiveActionRequest(capability="purge_email",@@ -235,6 +236,7 @@ class TestADryRunNeverReportsAVendorCall:"""tripwire = respx.route().mock(side_effect=AssertionError("a dry run made an HTTP call"))executor = registry.get_executor("m365", "purge_email")+ assert executor is not Noneresult = await executor.execute(LiveActionRequest(capability="purge_email",@@ -533,6 +535,7 @@ class TestVendorSelection:for vendor in VENDORS:for capability in STATE_CHANGING_VERBS:executor = registry.get_executor(vendor, capability)+ assert executor is not Noneassert executor._vendor_pin == vendor # noqa: SLF001def test_each_adapters_strip_list_is_its_factorys_key_set(self) -> None:@@ -544,6 +547,7 @@ class TestVendorSelection:for vendor in VENDORS:for capability in STATE_CHANGING_VERBS:executor = registry.get_executor(vendor, capability)+ assert executor is not Noneassert set(executor._credential_keys) == expected[vendor] # noqa: SLF001@pytest.mark.parametrize(diff --git a/services/api/app/workers/phishing_report_intake.py b/services/api/app/workers/phishing_report_intake.pyindex 5389d03ba..2098da95d 100644--- a/services/api/app/workers/phishing_report_intake.py+++ b/services/api/app/workers/phishing_report_intake.py@@ -207,7 +207,7 @@ async def run_once() -> SweepReport:"""One sweep across every tenant with a nominated report mailbox."""report = SweepReport()async with AsyncSessionLocal() as db:- assert_cross_tenant_session(db, reason="phishing report intake sweeps every tenant's nominated report mailbox")+ await assert_cross_tenant_session(db, "phishing report intake sweeps every tenant's nominated report mailbox")connectors = await _mailbox_connectors(db)report.tenants_considered = len({str(c.tenant_id) for c in connectors})@@ -272,8 +272,15 @@ async def run_once() -> SweepReport:# arrived during the outage.config[WATERMARK_CONFIG_KEY] = polled_at.isoformat().replace("+00:00", "Z")await db.execute(- text("UPDATE connectors SET connector_config = CAST(:cfg AS jsonb) WHERE id = :id").bindparams(- cfg=json.dumps(config), id=connector.id+ # Keyed by id *and* tenant. The id alone is unique and would+ # work; the predicate is here because `connectors` is a+ # tenant-scoped table and a cross-tenant sweep writing to one+ # without naming the tenant is the shape+ # `check_tenant_query_predicates.py` exists to refuse --+ # "how the row was addressed is irrelevant; naming another+ # tenant's id reaches it".+ text("UPDATE connectors SET connector_config = CAST(:cfg AS jsonb) WHERE id = :id AND tenant_id = :tenant_id").bindparams(+ cfg=json.dumps(config), id=connector.id, tenant_id=connector.tenant_id))