regime-desk is a research and governance copilot for quantitative market-regime risk review. All allocations and historical stress outputs are model-based research indicators derived from regimelab, never investment advice or automated order execution.
| Threat Vector | Concrete Risk | Implemented Mitigation |
|---|---|---|
| Indirect Prompt Injection in Policy RAG | Malicious instructions embedded inside ingested Markdown policy documents attempt to override exposure caps or suppress data-quality warnings. | 1. Ingestion-time screening and neutralization via sanitize_or_flag() in src/regime_desk/rag/retriever.py.2. Retrieved chunks are isolated strictly inside <untrusted_policy_excerpt> XML tags with explicit data-vs-instruction separation in system prompts.3. Deterministic fail-closed risk_auditor checks hard policy limits (POL-RISK-001/002, POL-CORR-001, POL-DATA-001) independently of LLM output. |
| Numeric Hallucination & Limit Breaches | LLM fabricates Sharpe/VaR metrics, flips indicator signs (e.g., VIX backwardation vs contango), invents chunk citations, or breaches SPY/TLT/CASH limits. | Zero-token Python verification gate (audit_committee_memo, audit_editorial_brief) enforces invariants I1–I8 (exact claim grounding, adaptive rounding tolerance + SIGN_CONTRADICTION detection, citation subset validation, POL-EDIT-001 checks) with bounded self-repair retries and deterministic safe_fallback. |
| Secret & PII Leakage | Exposure of GEMINI_API_KEY, Bearer tokens, or local host filesystem paths in logs, HTTP errors, traces, or git history. |
1. pydantic.SecretStr wraps API keys (DeskSettings in src/regime_desk/config.py).2. redact_secrets() scrubs API key prefixes, Bearer tokens, and host home paths from traces, tool error messages, CLI errors, and HTTP 422 responses (HTTP 500 returns a generic message).3. .gitignore and .dockerignore exclude .env, .cache/, and *.sqlite*; CI enforces gitleaks with fetch-depth: 0. |
| Look-Ahead Bias & Stale Data | Leakage of future training windows (train_end > asof), unratified future policy amendments (effective_date > asof), future episodic memory, or trading on stale feeds / inventing exchange holidays. |
1. Hard-block invariant I1 verifies train_end <= asof, observation_date <= session_date <= asof, chunk.effective_date <= asof, and prior.asof_date < asof.2. POL-DATA-001 (I3 + I8) freezes SPY expansion when is_stale=True and prohibits asserting unverified market holidays on asof_not_in_panel warnings. |
| Unsafe Deserialization & Arbitrary Code Execution | Arbitrary code execution via checkpoint deserialization, dynamic tool generation, or privileged container execution. | 1. SqliteSaver uses JsonPlusSerializer(pickle_fallback=False, allowed_msgpack_modules=...) with an explicit Pydantic/enum allowlist.2. Tools are 100% read-only Python adapters pinning asof and dataset_profile (zero eval/exec/shell execution), Gemini runs with AutomaticFunctionCallingConfig(disable=True), and Dockerfile runs as non-root appuser. |
- API Gateway & Auth: In institutional deployments, terminate TLS and enforce OAuth2/OIDC / mTLS authentication at the reverse proxy or API gateway in front of FastAPI (
regime_desk.api:app). - Token Cost Guardrails:
DeskSettings.max_cost_usd(REGIME_DESK_MAX_COST_USD, default$0.05) bounds every graph execution and deterministically routes exhausted runs intosafe_fallback. - Credential Rotation: Never commit
.env; populate runtime secrets exclusively via vault/secret-manager environment injection based on.env.example.