Skip to content

Hardening: trust-anchor client, shared-state mirrors, chunked body-cap audit - #49

Merged
blakebauman merged 1 commit into
mainfrom
hardening/cursor-plan-delta
Aug 12, 2026
Merged

blakebauman merged 1 commit into
mainfrom
hardening/cursor-plan-delta

Conversation

@blakebauman

Copy link
Copy Markdown
Member

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.New passed http.DefaultClient into auth.NewVerifier/auth.NewEMA — no timeout, redirects followed — because the bounded client in newJWKSCache only 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/redisBreaker failed open to allow-everything on Redis errors, while budgets, replay protection, and the task store all degrade to local mirrors — and docs/security-model.md claimed "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 every Record), which take over Allow during an outage. Degraded decisions count in the new fold_state_degraded_total{kind} with a FoldStateDegraded alert 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

bodyCapMiddleware audited only the Content-Length branch; an oversized chunked body tripped MaxBytesReader inside the MCP handler with no body_too_large metric 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

  • Helm NOTES warnings: multi-replica without Redis (N pods = N copies of every limit, one ID-JAG redemption per pod); discovery enabled without credential allowlists; ServiceMonitor on while the metrics listener is off (scrapes answered 403).
  • Startup warning when discovery is configured with none of the three credential allowlists — same posture as the budget-without-Redis warning.
  • Checklist: discovery allowlists, introspection.groups for multi-tenant, rediss:///HTTPS inside the mesh, allow-all-when-absent policy note.
  • Groups claim shape documented: must be a JSON array; anything else reads as no groups (fail closed).

Verification

make check green (race, lint 0 issues), make helm-check renders 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

…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]>
@blakebauman
blakebauman merged commit 89d5727 into main Aug 12, 2026
7 checks passed
@blakebauman
blakebauman deleted the hardening/cursor-plan-delta branch August 13, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant