CPSA ยท Web application assessment: recon, access control and input
Information disclosure in error messages
Stack traces, database errors and verbose banners and how they help an attacker.
Key points
- Unhandled errors can reveal stack traces (framework, versions, file paths), database errors (table or column names, a sign that input reaches a query) and verbose banners.
- Attackers use them for reconnaissance.
- The defence is a global error handler that returns a generic message to the user and writes full detail to server-side logs, with 4xx codes for client mistakes and 5xx for server failures.
Source: https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html
Practice questions
What should a production application show a user when an unexpected error occurs?
- The full stack trace to ease support
- The failing SQL query
- A generic message, with details logged on the server
- The server's file system paths
Show answer
Answer: C. A generic message, with details logged on the server
A generic message with no implementation detail, while the full error is logged server-side. Showing the stack trace or the SQL query helps the attacker rather than the user.
Which practices help prevent error-based information disclosure?
- Use one global handler for unhandled exceptions
- Enable detailed stack traces in production for convenience
- Return a generic message to the client
- Return the stack trace inside an HTTP 200 response
- Log full error detail on the server
Show answer
Answer: A. Use one global handler for unhandled exceptions, C. Return a generic message to the client, E. Log full error detail on the server
A global handler, generic user messages and server-side logging are the recommended pattern. Showing traces in production and returning them with HTTP 200 only moves the leak around.
True or false: a stack trace only helps developers, so showing it to users carries no security risk.
Show answer
Answer: False
False. Traces can reveal framework and server versions, file paths and code structure, which helps an attacker plan the next step.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
