{"@ID": "187", "@Name": "Partial String Comparison", "@Abstraction": "Variant", "@Structure": "Simple", "@Status": "Incomplete", "Description": "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.", "Extended_Description": "For example, an attacker might succeed in authentication by providing a small password that matches the associated portion of the larger, correct password.", "Related_Weaknesses": {"Related_Weakness": {"@Nature": "ChildOf", "@CWE_ID": "1023", "@View_ID": "1000", "@Ordinal": "Primary"}}, "Weakness_Ordinalities": {"Weakness_Ordinality": {"Ordinality": "Primary"}}, "Applicable_Platforms": {"Language": {"@Class": "Not Language-Specific", "@Prevalence": "Undetermined"}, "Technology": {"@Class": "Not Technology-Specific", "@Prevalence": "Undetermined"}}, "Modes_Of_Introduction": {"Introduction": {"Phase": "Implementation"}}, "Common_Consequences": {"Consequence": {"Scope": ["Integrity", "Access Control"], "Impact": ["Alter Execution Logic", "Bypass Protection Mechanism"]}}, "Potential_Mitigations": {"Mitigation": {"Phase": "Testing", "Description": "Thoroughly test the comparison scheme before deploying code into production. Perform positive testing as well as negative testing."}}, "Demonstrative_Examples": {"Demonstrative_Example": {"Intro_Text": "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.", "Example_Code": [{"@Nature": "Bad", "@Language": "C", "xhtml:div": {"xhtml:br": [null, null, null, null, null, null, null, null], "xhtml:i": "/* Ignore CWE-259 (hard-coded password) and CWE-309 (use of password system for authentication) for this example. */", "xhtml:div": [{"@style": "margin-left:1em;", "xhtml:div": [{"@style": "margin-left:1em;", "xhtml:br": null, "#text": "logEvent(\"Auth failure of username using strlen of inUser\");return(AUTH_FAIL);"}, {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "logEvent(\"Auth success of password using strlen of inUser\");return(AUTH_SUCCESS);"}, {"@style": "margin-left:1em;", "xhtml:br": null, "#text": "logEvent(\"Auth fail of password using sizeof\");return(AUTH_FAIL);"}], "xhtml:br": [null, null], "#text": "if (strncmp(username, inUser, strlen(inUser))) {}if (! strncmp(pass, inPass, strlen(inPass))) {}else {}"}, {"@style": "margin-left:1em;", "xhtml:div": {"xhtml:br": [null, null, null, null, null], "xhtml:div": [{"@style": "margin-left:1em;", "#text": "ExitError(\"Usage: Provide a username and password\");"}, {"@style": "margin-left:1em;", "#text": "DoAuthenticatedTask(argv[1]);"}, {"@style": "margin-left:1em;", "#text": "ExitError(\"Authentication failed\");"}], "#text": "int authResult;\n                           if (argc < 3) {}authResult = AuthenticateUser(argv[1], argv[2]);if (authResult == AUTH_SUCCESS) {}else {}"}}], "#text": "char *username = \"admin\";char *pass = \"password\";\n                     int AuthenticateUser(char *inUser, char *inPass) {}\n                     int main (int argc, char **argv) {}"}}, {"@Nature": "Attack", "xhtml:div": {"xhtml:br": [null, null, null], "#text": "ppapaspass"}}], "Body_Text": ["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.", "As a result, this partial comparison leads to improper authentication (CWE-287).", "Any of these passwords would still cause authentication to succeed for the \"admin\" user:", "This significantly reduces the search space for an attacker, making brute force attacks more feasible.", "The same problem also applies to the username, so values such as \"a\" and \"adm\" will succeed for the username.", "While this demonstrative example may not seem realistic, see the Observed Examples for CVE entries that effectively reflect this same weakness."]}}, "Observed_Examples": {"Observed_Example": [{"Reference": "CVE-2014-6394", "Description": "Product does not prevent access to restricted directories due to partial string comparison with a public directory", "Link": "https://www.cve.org/CVERecord?id=CVE-2014-6394"}, {"Reference": "CVE-2004-1012", "Description": "Argument 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.", "Link": "https://www.cve.org/CVERecord?id=CVE-2004-1012"}, {"Reference": "CVE-2004-0765", "Description": "Web 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.", "Link": "https://www.cve.org/CVERecord?id=CVE-2004-0765"}, {"Reference": "CVE-2002-1374", "Description": "One-character password by attacker checks only against first character of real password.", "Link": "https://www.cve.org/CVERecord?id=CVE-2002-1374"}, {"Reference": "CVE-2000-0979", "Description": "One-character password by attacker checks only against first character of real password.", "Link": "https://www.cve.org/CVERecord?id=CVE-2000-0979"}]}, "Taxonomy_Mappings": {"Taxonomy_Mapping": {"@Taxonomy_Name": "PLOVER", "Entry_Name": "Partial Comparison"}}, "Mapping_Notes": {"Usage": "Allowed", "Rationale": "This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.", "Comments": "Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.", "Reasons": {"Reason": {"@Type": "Acceptable-Use"}}}, "Notes": {"Note": {"@Type": "Relationship", "#text": "This is conceptually similar to other weaknesses, such as insufficient verification and regular expression errors. It is primary to some weaknesses."}}, "Content_History": {"Submission": {"Submission_Name": "PLOVER", "Submission_Date": "2006-07-19", "Submission_Version": "Draft 3", "Submission_ReleaseDate": "2006-07-19"}, "Modification": [{"Modification_Name": "Eric Dalci", "Modification_Organization": "Cigital", "Modification_Date": "2008-07-01", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Potential_Mitigations, Time_of_Introduction"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2008-09-08", "Modification_Version": "1.0", "Modification_ReleaseDate": "2008-09-09", "Modification_Comment": "updated Description, Relationships, Other_Notes, Taxonomy_Mappings, Weakness_Ordinalities"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2009-12-28", "Modification_Version": "1.7", "Modification_ReleaseDate": "2009-12-28", "Modification_Comment": "updated Demonstrative_Examples, Observed_Examples, Other_Notes, Relationship_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-03-29", "Modification_Version": "1.12", "Modification_ReleaseDate": "2011-03-30", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-06-01", "Modification_Version": "1.13", "Modification_ReleaseDate": "2011-06-01", "Modification_Comment": "updated Common_Consequences, Demonstrative_Examples"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2011-06-27", "Modification_Version": "2.0", "Modification_ReleaseDate": "2011-06-27", "Modification_Comment": "updated Common_Consequences"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-05-11", "Modification_Version": "2.2", "Modification_ReleaseDate": "2012-05-15", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2012-10-30", "Modification_Version": "2.3", "Modification_ReleaseDate": "2012-10-30", "Modification_Comment": "updated Potential_Mitigations"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2014-07-30", "Modification_Version": "2.8", "Modification_ReleaseDate": "2014-07-31", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2017-11-08", "Modification_Version": "3.0", "Modification_ReleaseDate": "2017-11-08", "Modification_Comment": "updated Applicable_Platforms"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2018-03-27", "Modification_Version": "3.1", "Modification_ReleaseDate": "2018-03-27", "Modification_Comment": "updated Name, Observed_Examples, Relationships, Type"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2019-01-03", "Modification_Version": "3.2", "Modification_ReleaseDate": "2019-01-03", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2020-02-24", "Modification_Version": "4.0", "Modification_ReleaseDate": "2020-02-24", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-01-31", "Modification_Version": "4.10", "Modification_ReleaseDate": "2023-01-31", "Modification_Comment": "updated Description"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-04-27", "Modification_Version": "4.11", "Modification_ReleaseDate": "2023-04-27", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-06-29", "Modification_Version": "4.12", "Modification_ReleaseDate": "2023-06-29", "Modification_Comment": "updated Mapping_Notes"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2025-12-11", "Modification_Version": "4.19", "Modification_ReleaseDate": "2025-12-11", "Modification_Comment": "updated Applicable_Platforms"}], "Previous_Entry_Name": {"@Date": "2018-03-27", "#text": "Partial Comparison"}}}
