Bitzu

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

Single choice

What should a production application show a user when an unexpected error occurs?

  1. The full stack trace to ease support
  2. The failing SQL query
  3. A generic message, with details logged on the server
  4. 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.

Select all that apply

Which practices help prevent error-based information disclosure?

  1. Use one global handler for unhandled exceptions
  2. Enable detailed stack traces in production for convenience
  3. Return a generic message to the client
  4. Return the stack trace inside an HTTP 200 response
  5. 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

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.

Download on the App StoreGet it on Google Play

More CPSA topics in this module