Verbose Error Response

Error stack traces and messages sent back in API responses

warningSecurityverbose-error-response

Severity 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

Flaggedapp/api/data/route.ts
export 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 }
    );
  }
}
Fixedapp/api/data/route.ts
export 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 --json and 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-response at the top of the file
How it works
Matches text patterns. Source on GitHub