The product performs a comparison that only examines a portion of a factor before determining whether there is a match, such as a substring, leading to resultant weaknesses.
View on MITREFor example, an attacker might succeed in authentication by providing a small password that matches the associated portion of the larger, correct password.
Thoroughly test the comparison scheme before deploying code into production. Perform positive testing as well as negative testing.
No detection method information available for this CWE.
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.
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.
Product does not prevent access to restricted directories due to partial string comparison with a public directory
View DetailsArgument parser of an IMAP server treats a partial command "body[p" as if it is "body.peek", leading to index error and out-of-bounds corruption.
View DetailsWeb browser only checks the hostname portion of a certificate when the hostname portion of the URI is not a fully qualified domain name (FQDN), which allows remote attackers to spoof trusted certificates.
View DetailsOne-character password by attacker checks only against first character of real password.
View DetailsOne-character password by attacker checks only against first character of real password.
View DetailsCWE-187: Partial String Comparison is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product performs a comparison that only examines a portion of a factor before determining whether there is a match, such as a substring, leading to resultant weaknesses. For example, an attacker might succeed in authentication by providing a small password that matches the associated portion of the larger, correct password.
If exploited, CWE-187 (Partial String Comparison) it can compromise Integrity and Access Control, leading to outcomes such as Alter Execution Logic and Bypass Protection Mechanism.
Recommended mitigations for CWE-187 include: Thoroughly test the comparison scheme before deploying code into production. Perform positive testing as well as negative testing.
CWE-187 commonly affects Not Language-Specific. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
MITRE documents real CVEs mapped to CWE-187, including CVE-2014-6394, CVE-2004-1012, CVE-2004-0765, CVE-2002-1374 and CVE-2000-0979. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
A CWE (Common Weakness Enumeration) like CWE-187 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.