FastAPI (Python 3.12) · CWE-942

FastAPI: Permissive CORS + Credentials (Code Remediation)

Implement fail-closed guards and safe data filters. Prevent reflected Origin headers paired with Access-Control-Allow-Credentials: true. Tailored for FastAPI: Attach scoped Depends() auth resolvers to every path operation.

Primary AegisSec skill
web-protocol-auth-audit ->
Companion: zap-baseline-passive
Coverage ledger tracking key
surface:fastapi::boundary:cors-credential-leak::angle:remediation
ZAP 40040 / 10098 cross-domain misconfig audit
Risk boundary
// Unverified FastAPI path (CWE-942 · Code Remediation)
// Handler accepts input without validating current_user.id.
Hardened guard
// Hardened FastAPI (CWE-942 · Code Remediation)
// 1. Attach scoped Depends() auth resolvers to every path operation
// 2. Validate origins against an exact static allowlist and never combine wildcard rules with cookies.

Verification steps

  1. 01Seed coverage-ledger.json for every FastAPI handler touching Permissive CORS + Credentials.
  2. 02Trace request parameters through current_user.id validation down to the sink.
  3. 03Verify with paired positive/negative evidence via zap-baseline-passive.