How to fix: Stack Trace Exposed in Response
A JavaScript or server-side stack trace was found in the HTTP response. AI-generated error handlers frequently pass exception objects directly to the HTTP response, leaking internal file paths, function names, and line numbers.
Why it matters
Stack traces reveal the technology stack, file system structure, library versions, and internal function names. This intelligence accelerates targeted attacks and helps attackers identify exploitable code paths.
AI-generated code like `res.json({ error: err.message, stack: err.stack })` is common in development but disastrous in production. Even `err.message` can leak internal details about database schemas, file paths, and logic.
How to fix it
- 1Never include err.stack or err.message in production HTTP responses.
- 2Log full details server-side with a correlation ID, return only the correlation ID to the client.
- 3Set NODE_ENV=production: many frameworks suppress detailed errors automatically in production mode.
- 4Add a global error handler that strips sensitive fields before responding.
Code examples
Safe error response
// Bad (AI-generated, leaks internals)
return Response.json({ error: err.message, stack: err.stack }, { status: 500 });
// Good
const correlationId = crypto.randomUUID();
console.error('[api]', { correlationId, error: err });
return Response.json({ error: 'Internal error', correlationId }, { status: 500 });References
Detected automatically by VulnRadar. The check id is vibe-expose-stacktrace, stable across every scan so you can filter or diff on it.
More ai code checks
- LowGeneric Error Messages Leak No Context
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalHardcoded Credential in Authentication Logic
- CriticalJWT 'none' Algorithm Accepted
- CriticalSQL String Concatenation Pattern Detected
Questions
- How severe is Stack Trace Exposed in Response?
- VulnRadar rates this medium severity in the ai code 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 vibe-expose-stacktrace, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Stack Trace Exposed in 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.