Skip to main content
MediumContentOWASP A05:2021CWE-209

How to fix: Stack trace exposed in HTTP response

A server error response contains a full stack trace, revealing file paths, line numbers, framework versions, and application structure.

Why it matters

Exposed stack traces reveal internal file paths, function names, dependency versions, and server architecture, information attackers use to identify known CVEs, craft targeted exploits, and understand application structure before attacking.

Stack traces should be logged server-side and never included in HTTP responses to clients.

How to fix it

  1. 1Catch all errors and return generic messages to clients
  2. 2Log full stack traces to a server-side logging system (Datadog, Sentry)
  3. 3Set production error handling to never expose internal details

Code examples

Suppress stack traces in production

JavaScript
// Express.js: generic error handler in production
app.use((err, req, res, next) => {
  const isDev = process.env.NODE_ENV !== 'production';
  res.status(err.status || 500).json({
    message: isDev ? err.message : 'Internal server error',
    stack: isDev ? err.stack : undefined,
  });
});

References

Detected automatically by VulnRadar. The check id is exposed-stack-trace, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is Stack trace exposed in HTTP response?
VulnRadar rates this medium severity in the content 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 exposed-stack-trace, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Stack trace exposed in HTTP response 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.

Propose a checkHow a check is built

Scan your own site for stack trace exposed in http response

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Stack trace exposed in HTTP response | VulnRadar