Verbose Error Response
Error stack traces and messages sent back in API responses
warningSecurity
verbose-error-responseSeverity depends on context. Warning for error.stack. Info for error.message.
Why this matters
Stack traces reveal file paths, dependency versions, and internal logic. Attackers use this information to find vulnerabilities and craft targeted exploits.
Example
app/api/data/route.tsexport async function GET() {
try {
const data = await fetchData();
return Response.json(data);
} catch (error) {
return Response.json(
{ error: error.message, stack: error.stack },
{ status: 500 }
);
}
}app/api/data/route.tsexport async function GET() {
try {
const data = await fetchData();
return Response.json(data);
} catch (error) {
console.error("fetchData failed:", error);
return Response.json(
{ error: "Internal server error" },
{ status: 500 }
);
}
}How to fix
Log the full error server-side for debugging. Return a generic error message to the client. Never send stack traces, file paths, or internal details in API responses.
Reference
- In the output
- Findings carry
"ruleId": "verbose-error-response"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line verbose-error-response- Silence a whole file
// prodlint-disable verbose-error-responseat the top of the file- How it works
- Matches text patterns. Source on GitHub