CWE-1023 Classe Incomplet

Incomplete Comparison with Missing Factors

This weakness occurs when a program compares two items but fails to check all the necessary attributes that define their true relationship. The incomplete check can cause the software to treat…

Définition

What is CWE-1023?

This weakness occurs when a program compares two items but fails to check all the necessary attributes that define their true relationship. The incomplete check can cause the software to treat different items as identical or make incorrect security decisions.
Incomplete comparisons happen when a developer writes a check that only validates a subset of an object's or user's identity. For example, a system might authenticate a user by checking only a username without verifying the associated password or session token, or it might compare data objects using only an ID field while ignoring a critical 'type' or 'state' field. This creates a logical gap where two distinct entities can be incorrectly evaluated as equivalent. This flaw directly undermines security and logic by allowing unauthorized access, privilege escalation, or data corruption. Attackers can exploit it by providing an entity that matches on the checked factors but differs maliciously on the unchecked ones. To prevent this, always ensure comparison functions validate every unique and security-relevant property that defines an entity's complete identity within that specific context.
Impact réel

Real-world CVEs caused by CWE-1023

  • PHP remote file inclusion in web application that filters "http" and "https" URLs, but not "ftp".

  • Product does not prevent access to restricted directories due to partial string comparison with a public directory

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    Consider an application in which Truck objects are defined to be the same if they have the same make, the same model, and were manufactured in the same year.

  2. 2

    Here, the equals() method only checks the make and model of the Truck objects, but the year of manufacture is not included.

  3. 3

    This example defines a fixed username and password. The AuthenticateUser() function is intended to accept a username and a password from an untrusted user, and check to ensure that it matches the username and password. If the username and password match, AuthenticateUser() is intended to indicate that authentication succeeded.

  4. 4

    In AuthenticateUser(), the strncmp() call uses the string length of an attacker-provided inPass parameter in order to determine how many characters to check in the password. So, if the attacker only provides a password of length 1, the check will only examine the first byte of the application's password before determining success.

  5. 5

    As a result, this partial comparison leads to improper authentication (CWE-287).

Exemple de code vulnérable

Vulnerable Java

Consider an application in which Truck objects are defined to be the same if they have the same make, the same model, and were manufactured in the same year.

Vulnérable Java
public class Truck {
  		private String make;
  		private String model;
  		private int year;
  		public boolean equals(Object o) {
  				if (o == null) return false;
  				if (o == this) return true;
  				if (!(o instanceof Truck)) return false;
  				Truck t = (Truck) o;
  				return (this.make.equals(t.getMake()) && this.model.equals(t.getModel()));
  		}
  }
Charge utile de l'attaquant

Any of these passwords would still cause authentication to succeed for the "admin" user:

Charge utile de l'attaquant
p
  pa
  pas
  pass
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-1023

  • Testing Thoroughly test the comparison scheme before deploying code into production. Perform positive testing as well as negative testing.
Signaux de détection

How to detect CWE-1023

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

This weakness occurs when a program compares two items but fails to check all the necessary attributes that define their true relationship. The incomplete check can cause the software to treat different items as identical or make incorrect security decisions.

Quelle est la gravité de CWE-1023 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

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

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir CWE-1023 ?

Thoroughly test the comparison scheme before deploying code into production. Perform positive testing as well as negative testing.

Comment Plexicus détecte et corrige CWE-1023 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-1023 à 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-1023 ?

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

Faiblesses associées

Weaknesses related to CWE-1023

CWE-697 Parent

Incorrect Comparison

This weakness occurs when a security-critical decision relies on a flawed comparison between two pieces of data. The incorrect logic can…

CWE-1024 Frère

Comparison of Incompatible Types

This vulnerability occurs when code directly compares two values of fundamentally different data types, which can lead to unreliable or…

CWE-1025 Frère

Comparison Using Wrong Factors

This weakness occurs when a program compares two items but checks the wrong properties or attributes. This flawed comparison leads to…

CWE-1039 Frère

Inadequate Detection or Handling of Adversarial Input Perturbations in Automated Recognition Mechanism

This vulnerability occurs when a system uses automated AI or machine learning to classify complex inputs like images, audio, or text, but…

CWE-1077 Frère

Floating Point Comparison with Incorrect Operator

This vulnerability occurs when code compares two floating-point numbers using direct equality operators (like == or !=) without accounting…

CWE-1254 Frère

Incorrect Comparison Logic Granularity

This vulnerability occurs when a system compares sensitive data, like passwords or authentication tokens, piece-by-piece instead of as a…

CWE-183 Frère

Permissive List of Allowed Inputs

This vulnerability occurs when an application's security filter uses an allowlist that is too broad, mistakenly permitting dangerous…

CWE-185 Frère

Incorrect Regular Expression

This vulnerability occurs when a regular expression is written incorrectly, causing it to match or validate data in unintended and…

CWE-581 Frère

Object Model Violation: Just One of Equals and Hashcode Defined

This vulnerability occurs when a Java class defines either the equals() method or the hashCode() method, but not both, breaking a…

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.