Exceptional Conditions Security Check (A05:2025)
What this checks
Protects against information disclosure and fail-open logic. Stack traces in API responses leak internal paths, library versions, and logic for attackers to target; swallowed exceptions and default-allow error paths grant unintended access.
Vulnerable patterns
- Error handler that returns the raw exception message, stack trace, or internal path in the HTTP response body
- Catch block that silently swallows exceptions with no logging, re-raise, or controlled error
- Authorization or permission exception caught and turned into a success or fall-through that grants access
- Debug or verbose-error flag enabled at deployment, exposing tracebacks to clients
- Default framework error page left in place, leaking file paths, library versions, or framework banner
Fix immediately
Flag the vulnerable code and explain the risk. Then suggest a fix that establishes
these properties:
- Client responses carry no internal detail. No stack trace, no file path, no
library version, no raw exception message. The client gets a generic message
and an opaque reference ID; the full traceback goes to a server-side log keyed
by that same ID.
- No catch block exits silently. Every catch / except / recover takes a
definite action: re-raise, log, or return a controlled error. A bare catch-and-pass
is the exact bug this skill prevents.
- Authorization failures fail closed. A permission or access-denied exception
inside a catch block must produce a deny response — never a fall-through or
default-allow. The safest pathway on ambiguity is refusal.
- Debug / verbose-error flags are off at deployment. The framework's
production-mode switch is set explicitly, not left at its development default.
- Every unhandled exception produces a server-side log entry containing a
correlation ID that matches the opaque reference returned to the client, so
operators can reconstruct the failure without leaking internals to the user.
Translate these principles to the audited file's language and framework. Use the
documented error-handler hook, production-mode switch, and logging facility for
that stack — do not invent ad-hoc traceback formatters or response shapes.
Verification
Confirm the following properties hold (language-agnostic):
References
1---2name: exceptional-conditions3description: Detects error handlers that leak stack traces or fail open on exception. Use when writing error handlers, exception catching blocks, try/catch/finally constructs, or API error responses. Also invoke when an application could fail open on exception, or when stack traces might reach end users.4---56# Exceptional Conditions Security Check (A05:2025)78## What this checks910Protects against information disclosure and fail-open logic. Stack traces in API responses leak internal paths, library versions, and logic for attackers to target; swallowed exceptions and default-allow error paths grant unintended access.1112## Vulnerable patterns1314- Error handler that returns the raw exception message, stack trace, or internal path in the HTTP response body15- Catch block that silently swallows exceptions with no logging, re-raise, or controlled error16- Authorization or permission exception caught and turned into a success or fall-through that grants access17- Debug or verbose-error flag enabled at deployment, exposing tracebacks to clients18- Default framework error page left in place, leaking file paths, library versions, or framework banner1920## Fix immediately2122Flag the vulnerable code and explain the risk. Then suggest a fix that establishes23these properties:24251. **Client responses carry no internal detail.** No stack trace, no file path, no26 library version, no raw exception message. The client gets a generic message27 and an opaque reference ID; the full traceback goes to a server-side log keyed28 by that same ID.292. **No catch block exits silently.** Every catch / except / recover takes a30 definite action: re-raise, log, or return a controlled error. A bare catch-and-pass31 is the exact bug this skill prevents.323. **Authorization failures fail closed.** A permission or access-denied exception33 inside a catch block must produce a deny response — never a fall-through or34 default-allow. The safest pathway on ambiguity is refusal.354. **Debug / verbose-error flags are off at deployment.** The framework's36 production-mode switch is set explicitly, not left at its development default.375. **Every unhandled exception produces a server-side log entry containing a38 correlation ID** that matches the opaque reference returned to the client, so39 operators can reconstruct the failure without leaking internals to the user.4041Translate these principles to the audited file's language and framework. Use the42documented error-handler hook, production-mode switch, and logging facility for43that stack — do not invent ad-hoc traceback formatters or response shapes.4445## Verification4647Confirm the following *properties* hold (language-agnostic):4849- [ ] No stack trace, file path, library version, exception message, or other internal detail reaches the client response body — only a generic message and opaque reference ID50- [ ] Every catch/except/recover block takes a definite action (re-raise, log, or return a controlled error) — no silently swallowed exceptions51- [ ] Authorization and permission failures produce a deny response (HTTP 401/403, or equivalent error return) — never a success or fall-through that grants access52- [ ] If the code configures a server or application entry point, debug/verbose-error flags are explicitly set to off using the framework's documented production-mode switch. Skip this criterion for library-level code or handlers that have no configuration surface53- [ ] Every unhandled exception produces a server-side log entry containing a correlation ID (UUID or equivalent) that matches the opaque reference returned to the client5455## References5657- CWE-388 ([Error Handling](https://cwe.mitre.org/data/definitions/388.html))58- CWE-391 ([Unchecked Error Condition](https://cwe.mitre.org/data/definitions/391.html))59- CWE-209 ([Generation of Error Message Containing Sensitive Information](https://cwe.mitre.org/data/definitions/209.html))60- [OWASP A05:2025 Security Misconfiguration](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)