
Verbose Error Messages
What verbose error messages leak in production, how to spot them during testing, and how to turn them off.
Description
An application has verbose errors when it sends diagnostic detail back to the user. That can be a stack trace, the failing SQL query, file paths, configuration values, and sometimes secrets such as API keys or connection strings.
Developers need that detail while debugging. In production it is an information disclosure bug. A tester reads it to fingerprint the stack, learn internal paths and class names, and find the weak spot that would otherwise take a lot of guessing.
Some examples:
- A SQL error names the database engine and often its version.
- A stack trace shows file paths and class names, which tells you how the backend is laid out.
- A misconfigured API returns internal identifiers or part of a credential in the error body.
Why it matters
One error page rarely looks dangerous on its own. It often gives just enough context to build a working exploit, for example the exact query shape for a SQL injection payload.
Remediation
- Return a generic message in production, such as "An error occurred. Please try again later."
- Write the full stack trace, query and debug detail to server-side logs with restricted access, never to the response.
- Use different error settings per environment: verbose in development, suppressed in production.
- Handle errors in one global handler so every route returns the same sanitized response.
- Validate input at each entry point so malformed requests fail early and cleanly instead of deep in the stack.
References
MITRE ATT&CK techniques
- T1087 - Account Discovery - Username enumeration via errors
- T1592.002 - Gather Victim Host Information: Software - Version disclosure
CWE entries
- CWE-209 - Generation of Error Message Containing Sensitive Information - Primary weakness
- CWE-497 - Exposure of Sensitive System Information to an Unauthorized Control Sphere - System information leakage
Security resources
- OWASP: Improper Error Handling - Guidance on error handling
Next steps
Related information disclosure notes:
TLS / SSL information leakage
What weak TLS configurations and TLS library bugs leak, how they enable interception and session theft, and how to test and fix them.
Cross-Site Scripting (XSS): Attack and Defense
Reflected, stored and DOM-based XSS, with payloads for each injection context, filter bypasses, detection and fixes.