CWE-188 Base Borrador Low likelihood

Reliance on Data/Memory Layout

This vulnerability occurs when software incorrectly assumes how data is structured in memory or within network packets, leading to unexpected behavior when those underlying layouts change.

Definición

What is CWE-188?

This vulnerability occurs when software incorrectly assumes how data is structured in memory or within network packets, leading to unexpected behavior when those underlying layouts change.
At the system level, memory layout is not universal. Different compilers, architectures, or platform updates can change how variables are ordered, aligned, or padded in memory. For example, one system might place two variables adjacent to each other, while another inserts space between them for performance alignment. If your code assumes a specific, fixed arrangement—like calculating offsets between variables—it will break when ported or run in a different environment, potentially reading corrupt data or causing crashes. In network protocols, similar risks exist when parsing messages. Developers often use fixed offsets relative to known header fields to locate specific data. However, new protocol versions, optional extensions, or edge cases can introduce unexpected padding or reorder fields. This causes the software to misinterpret packet contents, treating one type of data (like a length field) as another (like payload data), which can lead to security flaws like information disclosure or denial of service.
Impacto en el mundo real

Real-world CVEs caused by CWE-188

Todavía no hay CVEs públicos enlazados a esta CWE en el catálogo de MITRE.

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

In this example function, the memory address of variable b is derived by adding 1 to the address of variable a. This derived address is then used to assign the value 0 to b.

Vulnerable C
void example() {
  	char a;
  	char b;
  	*(&a + 1) = 0;
  }
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-188

  • Implementation / Architecture and Design In flat address space situations, never allow computing memory addresses as offsets from another memory address.
  • Architecture and Design Fully specify protocol layout unambiguously, providing a structured grammar (e.g., a compilable yacc grammar).
  • Testing Testing: Test that the implementation properly handles each case in the protocol grammar.
Señales de detección

How to detect CWE-188

Fuzzing High

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

Auto-corrección de Plexicus

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

This vulnerability occurs when software incorrectly assumes how data is structured in memory or within network packets, leading to unexpected behavior when those underlying layouts change.

¿Qué gravedad tiene CWE-188?

MITRE califica la probabilidad de explotación como Baja — la explotación es poco frecuente, pero la debilidad debe corregirse cuando se descubra.

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

MITRE lists the following affected platforms: C, C++.

¿Cómo puedo prevenir CWE-188?

In flat address space situations, never allow computing memory addresses as offsets from another memory address. Fully specify protocol layout unambiguously, providing a structured grammar (e.g., a compilable yacc grammar).

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

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

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