CWE-639 Base Incompleto High likelihood

Authorization Bypass Through User-Controlled Key

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another…

Definición

What is CWE-639?

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another user's information by manipulating an identifier they control.
This flaw typically appears in features that fetch user-specific data, like account pages or search results. The application uses a key—such as a database ID, account number, or session token—to locate the correct record. However, if this key is taken directly from a user-controllable source like a URL parameter, form field, or cookie without verifying the requesting user's permissions, an attacker can simply change the key value to access data belonging to someone else. Attackers often exploit this by tampering with sequential, predictable, or easily-guessed identifiers. For instance, using a simple integer like `user_id=1001` and changing it to `1002` to access another account. The core failure is that the system performs a lookup based on the provided key but skips the critical authorization check to confirm the authenticated user actually owns or has the right to view that specific record.
Impacto en el mundo real

Real-world CVEs caused by CWE-639

  • An educational application does not appropriately restrict file IDs to a particular user. The attacker can brute-force guess IDs, indicating IDOR.

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    Identifica una ruta de código que maneje entrada no confiable sin validación.

  2. 2

    Crea un payload que ejercite el comportamiento inseguro — inyección, traversal, overflow o abuso de lógica.

  3. 3

    Envía el payload a través de una solicitud normal y observa la reacción de la aplicación.

  4. 4

    Itera hasta que la respuesta filtre datos, ejecute código del atacante o escale privilegios.

Ejemplo de código vulnerable

Vulnerable C#

The following code uses a parameterized statement, which escapes metacharacters and prevents SQL injection vulnerabilities, to construct and execute a SQL query that searches for an invoice matching the specified identifier [1]. The identifier is selected from a list of all invoices associated with the current authenticated user.

Vulnerable C#
...
   conn = new SqlConnection(_ConnectionString);
   conn.Open();
   int16 id = System.Convert.ToInt16(invoiceID.Text);
   SqlCommand query = new SqlCommand( "SELECT * FROM invoices WHERE id = @id", conn);
   query.Parameters.AddWithValue("@id", id);
   SqlDataReader objReader = objCommand.ExecuteReader();
   ...
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-639

  • Architecture and Design For each and every data access, ensure that the user has sufficient privilege to access the record that is being requested.
  • Architecture and Design / Implementation Make sure that the key that is used in the lookup of a specific user's record is not controllable externally by the user or that any tampering can be detected.
  • Architecture and Design Use encryption in order to make it more difficult to guess other legitimate values of the key or associate a digital signature with the key so that the server can verify that there has been no tampering.
Señales de detección

How to detect CWE-639

Automated Static Analysis High

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-639 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-639?

This vulnerability occurs when an application's authorization system fails to verify that a user is allowed to access specific data before retrieving it, allowing an attacker to access another user's information by manipulating an identifier they control.

¿Qué gravedad tiene CWE-639?

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-639?

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-639?

For each and every data access, ensure that the user has sufficient privilege to access the record that is being requested. Make sure that the key that is used in the lookup of a specific user's record is not controllable externally by the user or that any tampering can be detected.

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

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

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/639.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.