First version of this document. SECURITY_FINAL_REPORT.md §25
explicitly recorded this as “NOT PRODUCED” — a named, prioritized gap
carried across every prior security pass on this repository until now.
Treat this as a first draft grounded in this app’s actual real detection
signals and real containment levers (every event name and config flag
below was verified to exist in the current codebase, not invented) —
not a rehearsed, on-call-tested runbook. It has not been exercised
against a simulated incident. See the final line of each scenario for
what verifying it for real would require.
Every scenario below leans on the same mechanism:
security.audit_log.log_security_event(event_type, severity, message,
**context) — one structured event, one dedicated security.audit logger,
correlation-ID-tagged. This app has no SIEM/alerting integration of its
own (confirmed — no Prometheus/alerting client in requirements.txt);
these events reach wherever the operator’s own log pipeline points
stdout/stderr. Grep-confirmed inventory of every event type this app
actually emits (not a hypothetical list):
auth_failed, oidc_token_rejected, authz_denied, user_registered,
account_locked, refresh_token_reuse_detected, logout_all_sessions,
password_changed, password_reset_requested, password_reset_completed,
input_rejected, conversation_history_injection_detected,
possible_rag_poisoning, sql_safety_violation, sensitive_column_blocked,
rate_limit_tripped, rag_role_restricted_content_blocked,
content_moderation_rejected, content_moderation_soft_flagged,
malware_detected, malware_scan_error_fail_closed, malware_scan_skipped,
db_write_privileges_detected, orchestrator_source_denied,
session_expensive_source_limit_tripped, generation_rejected,
generation_rate_limited, generation_provider_failed
auth_failed events from an unfamiliar IP/pattern;
a spike in oidc_token_rejected.auth_mode=static_token (a single shared
secret grants full admin-equivalent access — see docs/RISK_REGISTER.md
R-001).API_AUTH_TOKEN immediately (.env, redeploy —
no revocation list exists, the old value simply stops matching).
For OIDC, rotate the client secret at the IdP and revoke active sessions
at the IdP (this app doesn’t hold IdP-side session state to revoke
itself).auth_failed/oidc_token_rejected events
by correlation ID against any subsequent authz_denied or successful
action from the same window.OIDC_MAX_TOKEN_AGE-style
expiry (verify actual claim name in your IdP config) plus IdP-side
session revocation.identity/)account_locked (repeated failed logins),
refresh_token_reuse_detected (a stolen, already-used refresh token
replayed — identity/repositories/sessions.py’s reuse-detection revokes
the entire session family on this signal, confirmed by reading that
module).logout_all_sessions is the same primitive a user can
self-trigger; an operator can force it via the same repository function
for a specific user_id.password_changed/password_reset_completed events
immediately after a suspected takeover indicate the attacker locking the
legitimate owner out — treat as high-confidence confirmation.refresh_token_reuse_detected
beyond the family-revocation already built in — no alert is sent
anywhere (this app has no outbound alerting channel configured).sql_safety_violation (validator rejected the
statement type/shape), sensitive_column_blocked (restricted-column
gate fired).agent/sql_validator.py’s AST allowlist
means a “SQL abuse” event is, by construction, a rejected query, not
an executed one. A real incident here would mean the validator itself
had a bypass — treat any sustained pattern of sql_safety_violation
from one caller as a signal to investigate the validator’s own coverage,
not just block the caller.db.connection
.check_write_privileges, startup-enforced in production per
api/main.py) is the real backstop if the validator were ever bypassed
— verify that check’s own startup log for the affected deployment.sql_safety_violation — currently relies on the existing rate limiter
alone.authz_denied (RBAC blocked it — the success case),
rag_role_restricted_content_blocked. A genuine leak would show no
denial event at all for the read that shouldn’t have happened — absence
of a denial is not absence of evidence; cross-reference actual query/
document-access logs (application-level, not security-event-level) for
the affected window.identity/repositories/users.py); for a document-level leak, DELETE
/documents/{id} removes the source (cascades to chunks, confirmed via
ON DELETE CASCADE per SECURITY_FINAL_REPORT.md §11).input_rejected (caught pre-generation) or
conversation_history_injection_detected (caught in history, not
blocking). A successful injection producing a malicious SQL
statement would instead surface as sql_safety_violation — the
validator remains the real backstop regardless of the injection vector
(verified this engagement, tests/security/test_prompt_injection_multilingual_and_encoded.py).possible_rag_poisoning (detection-only scan over
extracted PDF text or retrieved schema/sampled-value content, fires on
the same shared injection-pattern set as live questions).DELETE /documents/{id} for a poisoned document.
For poisoned live-database content (a value crafted to look like an
instruction), there is no deletion lever in this app at all — the fix
is in the operator’s own source database.agent/nodes.py’s own
docstring) — a sufficiently subtle poisoning attempt that doesn’t match
the shared regex pattern set produces no event at all.content_moderation_rejected (hard-reject — Azure
Content Safety + text blocklist), content_moderation_soft_flagged
(recorded, not blocked — includes the disclosed “synthetic media,
not_checked” placeholder).moderation.store.record_asset records only the hash/outcome on
rejection, per rag/ingestion.py’s own docstring, independently
re-read this session).ModerationNotConfiguredError), not silently open, which is itself the
containment.malware_detected (signature match — critical),
malware_scan_error_fail_closed (scanner configured but couldn’t
complete — treated as a rejection, not a pass), malware_scan_skipped
(provider is disabled — the default; see
docs/security/FINAL_PRODUCTION_GATE.md’s Malware Scanning row for why
this is a real, disclosed production gap, not resolved by this
document).malware_scan_skipped events exist for a deployment that has
file upload enabled, that is itself the incident to act on —
reconfigure MALWARE_SCAN_PROVIDER=clamav immediately.clamd daemon or a real (even EICAR-test-string) sample
in this engagement — see docs/security/FINAL_PRODUCTION_GATE.md.log_security_event call exists for a
blocked SSRF attempt today — media_gen/download.py::_validate_download_url
raises MediaGenerationError (logged via the ordinary exception path,
not the structured audit-event path) — a real, disclosed gap found
while writing this document, not previously flagged in any prior pass.tests/test_media_gen.py).log_security_event
call to _validate_download_url’s rejection paths so an SSRF attempt is
as visible in the audit log as every other rejection class in this
document — not done as part of this pass (a code change beyond this
gate’s own “do not make unnecessary changes” scope, flagged as a
concrete P1 instead — see docs/security/PRODUCTION_SECURITY_READINESS_REPORT.md).docs/security/DEPENDENCY_SECURITY_FINAL_REPORT.md). A compromised
dependency would only surface via pip-audit/npm audit/Trivy’s own
next manual run, or via anomalous application behavior.requirements.txt/
package-lock.json, rebuild, redeploy.docs/security/sbom/) — those are a point-in-time snapshot, not a
continuous integrity check.rate_limit_tripped,
session_expensive_source_limit_tripped (the multi-source orchestrator’s
own per-session cost ceiling for paid sources).api/rate_limit.py) — confirmed process-local only (see the Rate
Limiting row in docs/security/FINAL_PRODUCTION_GATE.md); a
distributed/multi-instance attacker could exceed the intended global
budget by hitting different instances, though each instance’s own limit
still individually holds (verified this engagement via
tests/security/test_rate_limit_header_spoofing.py’s header-spoofing
regression, a related but distinct property).docs/DEPLOYMENT.md’s reverse-proxy pattern.USER app, uid 1000, confirmed this
engagement via docker run ... id) limits blast radius of a
process-level compromise; redeploy from a known-good, re-scanned image.A tabletop exercise walking at least scenarios 1, 2, 8, and 9 (the ones with the most concrete, testable detection signals) with whoever will actually be on call for a real deployment — not performed as part of this engagement (no on-call rotation or real deployment exists in this sandboxed environment to exercise this against).