CWE-204 Base Incompleto

Observable Response Discrepancy

This vulnerability occurs when an application responds differently to similar requests, unintentionally leaking details about its internal state or logic to unauthorized users.

Definición

What is CWE-204?

This vulnerability occurs when an application responds differently to similar requests, unintentionally leaking details about its internal state or logic to unauthorized users.
Observable Response Discrepancy happens when an application's output—such as error messages, timing, or even subtle differences in page content—changes based on internal conditions. Attackers can probe these differences to infer sensitive information, like whether a username exists, if a file is present on the server, or the structure of a backend database, without triggering standard access controls. To prevent this, developers must ensure their applications provide consistent, generic responses in all scenarios that could reveal system state. This involves standardizing error messages, implementing uniform response times for all outcomes (success or failure), and avoiding any output that changes based on hidden internal data. Treating all failed operations identically from the user's perspective closes this common information leak.
Vulnerability Diagram CWE-204
Observable Response Discrepancy login: alice / wrong → "wrong password" login: zzz / wrong → "user not found" Server if !user → "no such user" else if !pw → "wrong pw" two distinguishable replies + different timing Username enumeration attacker harvests valid accounts Different responses for valid vs invalid identifiers leak existence.
Impacto en el mundo real

Real-world CVEs caused by CWE-204

  • This, and others, use ".." attacks and monitor error responses, so there is overlap with directory traversal.

  • Enumeration of valid usernames based on inconsistent responses

  • Account number enumeration via inconsistent responses.

  • User enumeration via discrepancies in error messages.

  • User enumeration via discrepancies in error messages.

  • Bulletin Board displays different error messages when a user exists or not, which makes it easier for remote attackers to identify valid users and conduct a brute force password guessing attack.

  • Operating System, when direct remote login is disabled, displays a different message if the password is correct, which allows remote attackers to guess the password via brute force methods.

  • Product allows remote attackers to determine if a port is being filtered because the response packet TTL is different than the default TTL.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    The following code checks validity of the supplied username and password and notifies the user of a successful or failed login.

  2. 2

    In the above code, there are different messages for when an incorrect username is supplied, versus when the username is correct but the password is wrong. This difference enables a potential attacker to understand the state of the login function, and could allow an attacker to discover a valid username by trying different values until the incorrect password message is returned. In essence, this makes it easier for an attacker to obtain half of the necessary authentication credentials.

  3. 3

    While this type of information may be helpful to a user, it is also useful to a potential attacker. In the above example, the message for both failed cases should be the same, such as:

Ejemplo de código vulnerable

Vulnerable Perl

The following code checks validity of the supplied username and password and notifies the user of a successful or failed login.

Vulnerable Perl
my $username=param('username'); 
  my $password=param('password'); 
  if (IsValidUsername($username) == 1) 
  { 
  	if (IsValidPassword($username, $password) == 1) 
  	{ 
  		print "Login Successful"; 
  	} 
  	else 
  	{ 
  		print "Login Failed - incorrect password"; 
  	} 
  } 
  else 
  { 
  	print "Login Failed - unknown username"; 
  }
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-204

  • Architecture and Design Compartmentalize the system to have "safe" areas where trust boundaries can be unambiguously drawn. Do not allow sensitive data to go outside of the trust boundary and always be careful when interfacing with a compartment outside of the safe area. Ensure that appropriate compartmentalization is built into the system design, and the compartmentalization allows for and reinforces privilege separation functionality. Architects and designers should rely on the principle of least privilege to decide the appropriate time to use privileges and the time to drop privileges.
  • 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.
Señales de detección

How to detect CWE-204

SAST High

Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.

DAST Moderate

Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.

Runtime Moderate

Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.

Code review Moderate

Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-204 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-204?

This vulnerability occurs when an application responds differently to similar requests, unintentionally leaking details about its internal state or logic to unauthorized users.

¿Qué gravedad tiene CWE-204?

MITRE no ha publicado una calificación de probabilidad de explotación para esta debilidad. Trátala como de impacto medio hasta que tu modelo de amenazas demuestre lo contrario.

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

MITRE no ha especificado plataformas afectadas para esta CWE — puede aplicar a la mayoría de los stacks de aplicaciones.

¿Cómo puedo prevenir CWE-204?

Compartmentalize the system to have "safe" areas where trust boundaries can be unambiguously drawn. Do not allow sensitive data to go outside of the trust boundary and always be careful when interfacing with a compartment outside of the safe area. Ensure that appropriate compartmentalization is built into the system design, and the compartmentalization allows for and reinforces privilege separation functionality. Architects and designers should rely on the principle of least privilege to…

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

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-204 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-204?

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

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.