Security Misconfiguration Security Check (A02:2025)
What this checks
Protects against insecure defaults, overly permissive policies, and missing hardening
that expose the application to cross-origin attacks, credential stuffing, and
information disclosure via error pages or debug endpoints.
Vulnerable patterns
- Wildcard CORS origin combined with credentials enabled — every site on the web gets cookie-authenticated access
- Debug or verbose-error mode hardcoded on, exposing tracebacks, route lists, or interactive consoles in production
- Wildcard or empty host/origin allowlist accepted in production configuration
- HTTP server with no security-headers layer registered —
Strict-Transport-Security, X-Content-Type-Options, and a framing/CSP control missing. For hardcoded secrets see hardcoded-secrets.
Fix immediately
Flag the vulnerable code, explain the risk, and suggest a fix establishing these
properties. Translate to the language and framework of the audited file — use that
stack's documented middleware or configuration helpers; do not import recipes from a
different stack.
- CORS that allows credentials uses an explicit origin allowlist. Never a wildcard, never a reflected
Origin header. Browsers block wildcard-plus-credentials in spec, but misconfigured middleware still ships it.
- Debug and verbose-error flags default to off in production. Their values are sourced from environment or config, not hardcoded on. A production-only assertion that fails loudly when debug is left enabled catches misconfigured deploys.
- Every HTTP server registers a security-headers layer before routes. Baseline:
Strict-Transport-Security, X-Content-Type-Options: nosniff, and a framing or CSP control. An upstream proxy may own these instead — but only if that ownership is documented at the call site.
- Host and origin validation uses an explicit allowlist, never a wildcard or an empty default. Trusted-origin and CSRF-trusted-origin lists are attacker-reachable when unset.
Verification
Confirm the following properties hold (language-agnostic):
References
1---2name: security-misconfiguration3description: Detects insecure defaults, overly permissive CORS, exposed debug endpoints, and missing security headers. Use when writing server configuration, setting environment variables, configuring CORS policies, enabling debug modes, setting up default credentials, or deploying application infrastructure. Also invoke when writing security headers middleware.4---56# Security Misconfiguration Security Check (A02:2025)78## What this checks910Protects against insecure defaults, overly permissive policies, and missing hardening11that expose the application to cross-origin attacks, credential stuffing, and12information disclosure via error pages or debug endpoints.1314## Vulnerable patterns1516- Wildcard CORS origin combined with credentials enabled — every site on the web gets cookie-authenticated access17- Debug or verbose-error mode hardcoded on, exposing tracebacks, route lists, or interactive consoles in production18- Wildcard or empty host/origin allowlist accepted in production configuration19- HTTP server with no security-headers layer registered — `Strict-Transport-Security`, `X-Content-Type-Options`, and a framing/CSP control missing. For hardcoded secrets see `hardcoded-secrets`.2021## Fix immediately2223Flag the vulnerable code, explain the risk, and suggest a fix establishing these24properties. Translate to the language and framework of the audited file — use that25stack's documented middleware or configuration helpers; do not import recipes from a26different stack.27281. **CORS that allows credentials uses an explicit origin allowlist.** Never a wildcard, never a reflected `Origin` header. Browsers block wildcard-plus-credentials in spec, but misconfigured middleware still ships it.292. **Debug and verbose-error flags default to off in production.** Their values are sourced from environment or config, not hardcoded on. A production-only assertion that fails loudly when debug is left enabled catches misconfigured deploys.303. **Every HTTP server registers a security-headers layer before routes.** Baseline: `Strict-Transport-Security`, `X-Content-Type-Options: nosniff`, and a framing or CSP control. An upstream proxy may own these instead — but only if that ownership is documented at the call site.314. **Host and origin validation uses an explicit allowlist**, never a wildcard or an empty default. Trusted-origin and CSRF-trusted-origin lists are attacker-reachable when unset.3233## Verification3435Confirm the following *properties* hold (language-agnostic):3637- [ ] For every CORS configuration present in the code, if credentials are allowed then the allowed-origins value is an explicit allowlist — never a wildcard (`*`) or a reflected `Origin` header38- [ ] For every debug/development flag present in the code, the value is sourced from an environment variable or config and defaults to off in production39- [ ] For every HTTP server or router present in the code, a security-headers layer is registered before routes, setting at minimum `Strict-Transport-Security`, `X-Content-Type-Options`, and a framing/CSP control — unless the code comments explicitly document that an upstream proxy owns these headers40- [ ] Host or trusted-origin allowlists are explicit values, not wildcards or empty defaults4142## References4344- CWE-16 ([Configuration](https://cwe.mitre.org/data/definitions/16.html))45- CWE-732 ([Incorrect Permission Assignment for Critical Resource](https://cwe.mitre.org/data/definitions/732.html))46- [OWASP A02:2025 Security Misconfiguration](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)