CWE-209 Base Borrador High likelihood

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.

Definición

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.
When an application fails, it often generates error messages to help with debugging. However, if these messages aren't carefully filtered, they can leak critical secrets like database connection strings, server file paths, user passwords, API keys, or internal system configurations. Attackers can deliberately trigger these errors to gather intelligence, making your system an open book for reconnaissance and paving the way for more targeted attacks. To prevent this, applications must implement generic, user-friendly error messages in production environments. All detailed debugging information, stack traces, and system data should be logged securely on the server side where only authorized administrators can access them. This practice, often called 'security through obscurity,' is a fundamental layer of defense that denies attackers the information they need to exploit other weaknesses in your application.
Vulnerability Diagram CWE-209
Error Message with Sensitive Information Bad input id=' 500 stack trace PSQLException: syntax error at /app/src/Repo.kt:142 SELECT * FROM "users" WHERE id=' DB: prod-db-1.internal version: PostgreSQL 14.1 deployed at /opt/myapp/… Recon gold paths, vers, schema Detailed errors leak schema, paths, versions and SQL fragments.
Impacto en el mundo real

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

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    In the following example, sensitive information might be printed depending on the exception that occurs.

  2. 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. 3

    This code tries to open a database connection, and prints any exceptions that occur.

  4. 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. 5

    The following code generates an error message that leaks the full pathname of the configuration file.

Ejemplo de código vulnerable

Vulnerable Java

In the following example, sensitive information might be printed depending on the exception that occurs.

Vulnerable Java
try {
  	/.../
  }
  catch (Exception e) {
  	System.out.println(e);
  }
Ejemplo de código seguro

Secure pseudo

Seguro pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Lista de prevención

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.
Señales de detección

How to detect CWE-209

Manual Analysis High

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.

Automated Analysis Moderate

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.

Automated Dynamic Analysis Moderate

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.

Manual Dynamic Analysis

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

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.)

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-209 y abre un PR de corrección en menos de 60 segundos.

Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.

Preguntas frecuentes

Frequently asked questions

¿Qué es 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.

¿Qué gravedad tiene CWE-209?

MITRE califica la probabilidad de explotación como Alta — esta debilidad se explota activamente en la práctica y debe priorizarse para su remediación.

¿Qué lenguajes o plataformas se ven afectados por CWE-209?

MITRE lists the following affected platforms: PHP, Java.

¿Cómo puedo prevenir 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…

¿Cómo detecta y corrige Plexicus CWE-209?

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-209 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.

¿Dónde puedo aprender más sobre CWE-209?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/209.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.

Debilidades relacionadas

Weaknesses related to CWE-209

CWE-200 Padre

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.

CWE-1258 Hermano

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…

CWE-1273 Hermano

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…

CWE-1295 Hermano

Debug Messages Revealing Unnecessary Information

The product's debug messages or logs expose excessive internal system details, potentially revealing sensitive information that could aid…

CWE-1431 Hermano

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…

CWE-201 Hermano

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…

CWE-203 Hermano

Observable Discrepancy

This vulnerability occurs when an application responds differently to unauthorized users based on internal conditions. Attackers can…

CWE-213 Hermano

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…

CWE-215 Hermano

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…

Listo cuando tú lo estés

Deja de pagar por desarrollador.
Empieza a cerrar el bucle.

Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.