Repository navigation
Hardening: trust-anchor client, shared-state mirrors, chunked body-cap audit - #49
Merged
Merged
Conversation
…it gaps Implements the validated delta of the Cursor production-hardening plan (.cursor/plans/production_hardening_remediation_abd286c5.plan.md) — three confirmed findings the 2026-08 audit missed, plus ops guardrails: - Trust-anchor client (P0): gateway.New passed http.DefaultClient into the verifier and EMA, so JWKS fetches had no timeout and followed redirects — the 10s client in newJWKSCache only applied when nil was passed, which the gateway never did. auth.TrustAnchorClient now bounds them at 10s and refuses redirects, matching every other outbound trust-path client. - Redis limiter/breaker fallback (P1): rate limits and breakers failed open to allow-everything on Redis errors while budgets/Once/Store degraded to local mirrors — and the security model claimed per-instance enforcement for all of them. They now keep warm local mirrors (fed on every healthy decision) that take over during an outage; degraded decisions count in fold_state_degraded_total with a FoldStateDegraded alert in both rule files. Docs now say precisely what happens. - Chunked body-cap audit (P1): oversized chunked bodies tripped MaxBytesReader inside the handler and bypassed the body_too_large reject/audit path that Content-Length bodies hit. A tripwire on the wrapped body routes them through the same metric and audit event. - Ops guardrails: Helm NOTES warn on multi-replica-without-Redis, discovery-without-allowlists, and ServiceMonitor-without-listener; the gateway warns at startup when discovery has no credential allowlists; the production checklist covers discovery allowlists, introspection.groups, and rediss://; the groups claim's array-or-fail-closed shape is documented. Already covered by PR #46 (no code change): the plan's credential- error redaction and EMA audit items. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Implements the validated delta of the Cursor-authored hardening plan (
.cursor/plans/production_hardening_remediation_abd286c5.plan.md). Each claim was verified against the code before implementation; two of the plan's seven items (credential-error redaction, EMA audit events) were already shipped in #46, and the rest are here.P0 — trust-anchor transport
gateway.Newpassedhttp.DefaultClientintoauth.NewVerifier/auth.NewEMA— no timeout, redirects followed — because the bounded client innewJWKSCacheonly installs when the caller passes nil, which the gateway never did. A wedged IdP could pin verification goroutines forever, and whoever answers the JWKS URI could redirect the fetch anywhere.auth.TrustAnchorClient()(10s timeout, redirects refused) now backs both, matching the discovery/token-endpoint/audit-webhook posture. Tested.P1 — Redis outage semantics now match the security model
redisLimiter/redisBreakerfailed open to allow-everything on Redis errors, while budgets, replay protection, and the task store all degrade to local mirrors — anddocs/security-model.mdclaimed "per-instance enforcement" across the board. Both now keep warm local mirrors (the limiter's window is fed on every healthy decision; the breaker mirrors everyRecord), which take overAllowduring an outage. Degraded decisions count in the newfold_state_degraded_total{kind}with aFoldStateDegradedalert in both rule files (pack lockstep tests pass). The security-model and deploy docs now describe the behavior exactly. Tested with miniredis: mid-flight outage → third-of-two requests refused, warm breaker opens, both kinds observed.P1 — chunked bodies exit through the same door
bodyCapMiddlewareaudited only the Content-Length branch; an oversized chunked body trippedMaxBytesReaderinside the MCP handler with nobody_too_largemetric or audit event. A tripwire on the wrapped body now routes that refusal through the identical metric + audit path. Integration-tested with a 64KB chunked POST against a 1KB cap.Ops guardrails
discoveryis configured with none of the three credential allowlists — same posture as the budget-without-Redis warning.introspection.groupsfor multi-tenant,rediss:///HTTPS inside the mesh, allow-all-when-absent policy note.Verification
make checkgreen (race, lint 0 issues),make helm-checkrenders all fixtures, bench gate passes. New tests: trust-anchor redirect refusal, per-instance degradation for limiter+breaker+observer, chunked overflow audit.🤖 Generated with Claude Code