CWE-464 Base Incomplet High likelihood

Addition of Data Structure Sentinel

This vulnerability occurs when a program unintentionally adds or modifies a special marker, known as a sentinel, within a data structure, leading to critical logic errors.

Définition

What is CWE-464?

This vulnerability occurs when a program unintentionally adds or modifies a special marker, known as a sentinel, within a data structure, leading to critical logic errors.
Data structures often use sentinel values as internal markers to define their boundaries or format. Common examples include the null terminator ('\0') at the end of a string or a special node marking the end of a linked list. These sentinels are control mechanisms for the program itself, not regular data. If an attacker or a logic flaw can inject or alter these markers, the program's fundamental understanding of its own data breaks down. To prevent this, you must rigorously validate all external inputs and implement strict bounds checking to ensure sentinel values are never written into data fields where they don't belong. Treat sentinels as reserved, protected control characters that your data processing logic must explicitly guard against, separating the trusted internal structure of your data from untrusted, user-supplied content.
Impact réel

Real-world CVEs caused by CWE-464

Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    Identifier un chemin de code qui traite des entrées non fiables sans validation.

  2. 2

    Élaborer une charge utile qui exploite le comportement non sécurisé — injection, traversal, débordement ou abus de logique.

  3. 3

    Délivrer la charge utile via une requête normale et observer la réaction de l'application.

  4. 4

    Itérer jusqu'à ce que la réponse divulgue des données, exécute le code de l'attaquant ou élève les privilèges.

Exemple de code vulnérable

Vulnerable C

The following example assigns some character values to a list of characters and prints them each individually, and then as a string. The third character value is intended to be an integer taken from user input and converted to an int.

Vulnérable C
char *foo;
  foo=malloc(sizeof(char)*5);
  foo[0]='a';
  foo[1]='a';
  foo[2]=fgetc(stdin);
  foo[3]='c';
  foo[4]='\0';
  printf("%c %c %c %c %c \n",foo[0],foo[1],foo[2],foo[3],foo[4]);
  printf("%s\n",foo);
Exemple de code sécurisé

Secure pseudo

Sécurisé 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.
Liste de contrôle de prévention

How to prevent CWE-464

  • Implementation / Architecture and Design Encapsulate the user from interacting with data sentinels. Validate user input to verify that sentinels are not present.
  • Implementation Proper error checking can reduce the risk of inadvertently introducing sentinel values into data. For example, if a parsing function fails or encounters an error, it might return a value that is the same as the sentinel.
  • Architecture and Design Use an abstraction library to abstract away risky APIs. This is not a complete solution.
  • Operation Use OS-level preventative functionality. This is not a complete solution.
Signaux de détection

How to detect CWE-464

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-464 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-464 ?

This vulnerability occurs when a program unintentionally adds or modifies a special marker, known as a sentinel, within a data structure, leading to critical logic errors.

Quelle est la gravité de CWE-464 ?

MITRE évalue la probabilité d'exploitation comme Élevée — cette faiblesse est activement exploitée et doit être priorisée pour la remédiation.

Quels langages ou plateformes sont affectés par CWE-464 ?

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

Comment puis-je prévenir CWE-464 ?

Encapsulate the user from interacting with data sentinels. Validate user input to verify that sentinels are not present. Proper error checking can reduce the risk of inadvertently introducing sentinel values into data. For example, if a parsing function fails or encounters an error, it might return a value that is the same as the sentinel.

Comment Plexicus détecte et corrige CWE-464 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-464 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-464 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/464.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-464

CWE-138 Parent

Improper Neutralization of Special Elements

This vulnerability occurs when an application accepts external input but fails to properly sanitize special characters or syntax that have…

CWE-140 Frère

Improper Neutralization of Delimiters

This vulnerability occurs when an application fails to properly handle or sanitize delimiter characters within data inputs, allowing them…

CWE-147 Frère

Improper Neutralization of Input Terminators

This vulnerability occurs when an application accepts external input but fails to properly handle special characters that downstream…

CWE-148 Frère

Improper Neutralization of Input Leaders

This vulnerability occurs when an application fails to properly validate or handle input that begins with special control characters or…

CWE-149 Frère

Improper Neutralization of Quoting Syntax

This vulnerability occurs when an application fails to properly validate or escape quote characters (like single ' or double " quotes) in…

CWE-150 Frère

Improper Neutralization of Escape, Meta, or Control Sequences

This vulnerability occurs when an application fails to properly sanitize or escape special character sequences in user-supplied input…

CWE-151 Frère

Improper Neutralization of Comment Delimiters

This vulnerability occurs when an application accepts user input and fails to properly sanitize characters that can be interpreted as…

CWE-152 Frère

Improper Neutralization of Macro Symbols

This vulnerability occurs when an application accepts user input containing macro symbols (like those used in templates or configuration…

CWE-153 Frère

Improper Neutralization of Substitution Characters

This vulnerability occurs when an application accepts user input and fails to properly sanitize special characters that can trigger…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.