CWE-209 Base Rascunho 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.

Definição

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 no 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

Como os atacantes a exploram

Trajeto do atacante passo a passo

  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.

Exemplo de código vulnerável

Vulnerable Java

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

Vulnerável Java
try {
  	/.../
  }
  catch (Exception e) {
  	System.out.println(e);
  }
Exemplo 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 verificação de prevenção

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.
Sinais de deteção

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

Correção automática do Plexicus

O Plexicus deteta automaticamente o CWE-209 e abre um PR de correção em menos de 60 segundos.

O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.

Perguntas frequentes

Frequently asked questions

O que é o 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.

Qual a gravidade do CWE-209?

A MITRE classifica a probabilidade de exploração como Alta — esta fraqueza é ativamente explorada em campo e deve ser priorizada para remediação.

Que linguagens ou plataformas são afetadas pelo CWE-209?

MITRE lists the following affected platforms: PHP, Java.

Como posso prevenir o 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…

Como é que o Plexicus deteta e corrige o CWE-209?

O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-209 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.

Onde posso saber mais sobre o CWE-209?

A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/209.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.

Fraquezas relacionadas

Weaknesses related to CWE-209

CWE-200 Pai

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 Irmão

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 Irmão

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 Irmão

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 Irmão

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 Irmão

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 Irmão

Observable Discrepancy

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

CWE-213 Irmão

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 Irmão

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…

Pronto quando você estiver

Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.

O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.