Sensitive Data Exposure Through Verbose API Error Messages
What it is
A medium-severity vulnerability where APIs return overly detailed error messages that expose sensitive information about the system architecture, database structure, file paths, internal configurations, or user data. These verbose error messages can provide attackers with valuable reconnaissance information to plan targeted attacks, understand system internals, and identify potential attack vectors.
💡 Why This Fix Works
The vulnerable code exposes sensitive information through error messages including database details (error.sqlMessage, query strings), file system paths (err.path), and stack traces. The secure version implements centralized error handling that logs detailed errors server-side only while returning generic error messages to clients, preventing information disclosure to potential attackers.
Why it happens
Typical mistakes in app/data layers enable this vulnerability.
Root causes
Fixes
Detect This Vulnerability in Your Code
Sourcery automatically identifies sensitive data exposure through verbose api error messages and many other security issues in your codebase.