fix(cli): wire bearer token, audit store, and attestation staleness into the live server - #278
Merged
imran-siddique merged 2 commits intoJun 11, 2026
Conversation
… timestamps into the live server run_startup() validated the bearer token, opened the SQLite audit store, and produced attestation timestamps, but cli.start() dropped all of them: - MCPServer was built without bearer_token, so every protected endpoint (/mcp, /audit/export, /catalog/exception, /sessions/*) was reachable unauthenticated in production (AUTH-001 dead in the live path). - AuditChain was built directly instead of via SessionManager, so entries never reached the SQLite store (AUDIT-001 inert) and the chain was never TEE-anchored (AUDIT-002). - CMCPProxy never received attestation_generated_at, so the staleness check could not fire (fail-open). Extract the composition into cli.build_server(ctx) and add regression tests that exercise the real entrypoint wiring, including a TestClient 401 check. Also serialise SqliteAuditStore access with a threading.Lock: the single connection is shared across async handlers and worker threads with check_same_thread=False. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2 tasks
This was referenced Jun 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security review found that
cli.start()(the only production entrypoint) never wired the componentsrun_startup()validates:MCPServer, so the auth middleware was never installed -- every protected endpoint (/mcp,/audit/export, break-glass/catalog/exception, session reset) was reachable unauthenticated in production. Unit tests passed because they constructMCPServer(bearer_token=...)directly.AuditChainwas constructed directly instead of viaSessionManager.create_session(), so the SQLite store added in fix(audit): persist audit chain to SQLite WAL store on every append (AUDIT-001) #276 was opened at startup and then never written -- persistence was inert in the live path.CMCPProxynever receivedattestation_generated_at, so_check_health()could never mark attestation stale.Changes
cli.build_server(ctx);startcalls it. All validated context components are now threaded through.threading.Lockaround the shared SQLite connection inSqliteAuditStore(single connection,check_same_thread=False, used from async handlers and worker threads).tests/unit/test_cli_wiring.py: 5 regression tests against the real entrypoint composition, including aTestClient401/200 check, SQLite persistence check, TEE anchor check, and attestation timestamp check.Stacked on #276 (requires
RuntimeContext.audit_store).Test plan
pytest tests/-- 650 passed, 1 skipped (pre-existing)Generated with Claude Code