OOmnistu

Blog / Engineering Playbooks

Engineering Playbooks

Error handling without leaking details to attackers

Plan useful internal error reporting while preventing public responses from exposing stack traces, credentials or implementation details.

OOmnistu
Reviewed 2026-11-16 · 2 min read

OWASP's Error Handling Cheat Sheet starts from the point that attacks typically begin with reconnaissance, where the attacker gathers technical details such as server, framework and library names and versions. Unhandled errors help with that and can also reveal injection points. We read the sheet on 15 November 2026. We skimmed its framework code samples (Java, Spring, ASP.NET Core, ASP.NET Web API) and did not run them, and we did not read the WSTG and RFC pages it links.

What a leak looks like

The sheet's examples: a full exception page showing the framework and server versions and a stack trace, and a database warning showing the install path and the failing call. Either tells an attacker what you run and where to poke.

The target behaviour

When something unexpected happens:

The sheet suggests a global error handler in the runtime configuration or code, so no failure path is forgotten. It assumes a REST API backend, says to cover all failure modes as far as possible and use 5xx only for requests the server cannot fulfil, and points to Problem Details for HTTP APIs (RFC 7807, now RFC 9457 in its references) as a response format. In its samples, the generic body is a short message such as "An error occur, please retry", with an error flag header. It notes it may be wise to use 4xx codes when clients misbehave.

Its appendix says to use error messages without implementation details, and in general 4xx for client mistakes and 5xx for server failures.

Checklist for your team

Related: REST API security checklist, authorization basics, logging basics.

Limits

One OWASP page. We did not test any of the framework samples and give none here. We give no statistics. Which status code fits a given failure is your API's decision; the sheet gives only the broad 4xx and 5xx split.

By Omnistu.

Sources

Previous
Sending app emails that reach Gmail: what Google's sender guidelines require