This weakness generally requires domain-specific interpretation using manual analysis. However, the number of potential error conditions may be too large to cover completely within limited time constraints.
Generation of Error Message Containing Sensitive Information
This vulnerability occurs when an application reveals sensitive details about its internal systems, user data, or environment within error messages shown to users.
What is CWE-209?
Real-world CVEs caused by CWE-209
-
POP3 server reveals a password in an error message after multiple APOP commands are sent. Might be resultant from another weakness.
-
Program reveals password in error message if attacker can trigger certain database errors.
-
Composite: application running with high privileges (CWE-250) allows user to specify a restricted file to process, which generates a parsing error that leaks the contents of the file (CWE-209).
-
Existence of user names can be determined by requesting a nonexistent blog and reading the error message.
-
Direct request to library file in web application triggers pathname leak in error message.
-
Malformed input to login page causes leak of full path when IMAP call fails.
-
Malformed regexp syntax leads to information exposure in error message.
-
verbose logging stores admin credentials in a world-readablelog file
Step-by-step attacker path
- 1
In the following example, sensitive information might be printed depending on the exception that occurs.
- 2
If an exception related to SQL is handled by the catch, then the output might contain sensitive information such as SQL query structure or private information. If this output is redirected to a web user, this may represent a security problem.
- 3
This code tries to open a database connection, and prints any exceptions that occur.
- 4
If an exception occurs, the printed message exposes the location of the configuration file the script is using. An attacker can use this information to target the configuration file (perhaps exploiting a Path Traversal weakness). If the file can be read, the attacker could gain credentials for accessing the database. The attacker may also be able to replace the file with a malicious one, causing the application to use an arbitrary database.
- 5
The following code generates an error message that leaks the full pathname of the configuration file.
Vulnerable Java
In the following example, sensitive information might be printed depending on the exception that occurs.
try {
/.../
}
catch (Exception e) {
System.out.println(e);
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-209
- Implementation Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files. Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
- Implementation Handle exceptions internally and do not display errors containing potentially sensitive information to a user.
- Implementation Use naming conventions and strong types to make it easier to spot when sensitive data is being used. When creating structures, objects, or other complex entities, separate the sensitive and non-sensitive data as much as possible.
- Implementation / Build and Compilation Debugging information should not make its way into a production release.
- Implementation / Build and Compilation Debugging information should not make its way into a production release.
- System Configuration Where available, configure the environment to use less verbose error messages. For example, in PHP, disable the display_errors setting during configuration, or at runtime using the error_reporting() function.
- System Configuration Create default error pages or messages that do not leak any information.
How to detect CWE-209
Automated methods may be able to detect certain idioms automatically, such as exposed stack traces or pathnames, but violation of business rules or privacy requirements is not typically feasible.
This weakness can be detected using dynamic tools and techniques that interact with the software using large test suites with many diverse inputs, such as fuzz testing (fuzzing), robustness testing, and fault injection. The software's operation may slow down, but it should not become unstable, crash, or generate incorrect results. Error conditions may be triggered with a stress-test by calling the software simultaneously from a large number of threads or processes, and look for evidence of any unexpected behavior.
Identify error conditions that are not likely to occur during normal usage and trigger them. For example, run the program under low memory conditions, run with insufficient privileges or permissions, interrupt a transaction before it is completed, or disable connectivity to basic network services such as DNS. Monitor the software for any unexpected behavior. If you trigger an unhandled exception or similar error that was discovered and handled by the application's environment, it may still indicate unexpected conditions that were not handled by the application itself.
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Plexicus auto-detects CWE-209 and opens a fix PR in under 60 seconds.
Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.
Frequently asked questions
What is CWE-209?
This vulnerability occurs when an application reveals sensitive details about its internal systems, user data, or environment within error messages shown to users.
How serious is CWE-209?
MITRE rates the likelihood of exploit as High — this weakness is actively exploited in the wild and should be prioritized for remediation.
What languages or platforms are affected by CWE-209?
MITRE lists the following affected platforms: PHP, Java.
How can I prevent CWE-209?
Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success. If errors must be…
How does Plexicus detect and fix CWE-209?
Plexicus's SAST engine matches the data-flow signature for CWE-209 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.
Where can I learn more about CWE-209?
MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/209.html. You can also reference OWASP and NIST documentation for adjacent guidance.
Weaknesses related to CWE-209
Exposure of Sensitive Information to an Unauthorized Actor
This weakness occurs when an application unintentionally reveals sensitive data to someone who shouldn't have access to it.
Exposure of Sensitive System Information Due to Uncleared Debug Information
This vulnerability occurs when hardware fails to erase sensitive data like cryptographic keys and intermediate values before entering…
Device Unlock Credential Sharing
This vulnerability occurs when the secret keys or passwords required to unlock a device's hidden features are shared between multiple…
Debug Messages Revealing Unnecessary Information
The product's debug messages or logs expose excessive internal system details, potentially revealing sensitive information that could aid…
Driving Intermediate Cryptographic State/Results to Hardware Module Outputs
This vulnerability occurs when a hardware cryptographic module leaks sensitive internal data through its output channels. Instead of only…
Insertion of Sensitive Information Into Sent Data
This vulnerability occurs when an application sends data to an external party, but accidentally includes sensitive information—like…
Observable Discrepancy
This vulnerability occurs when an application responds differently to unauthorized users based on internal conditions. Attackers can…
Exposure of Sensitive Information Due to Incompatible Policies
This vulnerability occurs when a system's data handling aligns with the developer's security rules but accidentally reveals information…
Insertion of Sensitive Information Into Debugging Code
This vulnerability occurs when developers embed sensitive data, such as passwords or API keys, within debugging statements like logs or…
Further reading
- MITRE — official CWE-209 https://cwe.mitre.org/data/definitions/209.html
- Information Leakage http://projects.webappsec.org/w/page/13246936/Information%20Leakage
- Top 25 Series - Rank 16 - Information Exposure Through an Error Message https://www.sans.org/blog/top-25-series-rank-16-information-exposure-through-an-error-message
Don't Let Security
Weigh You Down.
Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.