How to fix: Problem document exposes a stack trace or exception class
An RFC 9457 problem document exposes a stack trace or the internal exception class behind it. The trace member carries real stack frames, or the exception member names the class that threw.
Why it matters
A stack trace gives away the framework and its version, the absolute paths of deployed files, the internal package and class layout, and often the exact line where input handling failed. That is the map an attacker uses to pick which known vulnerability applies and where to aim the next request.
Spring Boot produces this shape when server.error.include-stacktrace is set to always, which is the default in some starter templates and is frequently left on after debugging. The problem-document format itself is fine and worth using; what must not travel with it are the trace and exception members. A stable error code plus a correlation id gives support everything it needs while keeping the internals server-side.
How to fix it
- 1Set server.error.include-stacktrace=never and server.error.include-exception=false in production (or the equivalent in your framework).
- 2Return a stable machine-readable error code and a correlation id in the problem document instead of the trace.
- 3Log the full exception server-side against that same correlation id.
- 4Test the error path in the production profile, not only in development, since the two usually differ.
Code examples
Spring Boot: keep traces server-side
server.error.include-stacktrace=never
server.error.include-exception=false
server.error.include-message=never
server.error.include-binding-errors=neverA safe problem document
{
"type": "https://api.example.com/errors/invalid-parameter",
"title": "Invalid parameter",
"status": 400,
"detail": "startDate must be before endDate",
"instance": "/v1/reports",
"correlationId": "0f2c1b7e-9a1d-4a44-8f2e-6b6d0f9a1c33"
}References
Detected automatically by VulnRadar. The check id is api-problem-json-trace-exposed, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is Problem document exposes a stack trace or exception class?
- VulnRadar rates this medium severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-problem-json-trace-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Problem document exposes a stack trace or exception class map to?
- It maps to CWE-209. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.