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: Alter Execution LogicBypass Protection Mechanism
java/* Ignore CWE-259 (hard-coded password) and CWE-309 (use of password system for authentication) for this example. /
c
bash