Base · Medium

CWE-178: Improper Handling of Case Sensitivity

The product does not properly account for differences in case sensitivity when accessing or determining the properties of a resource, leading to inconsistent results.

CWE-178 · Base Level ·18 CVEs ·3 Mitigations

Description

The product does not properly account for differences in case sensitivity when accessing or determining the properties of a resource, leading to inconsistent results.

Improperly handled case sensitive data can lead to several possible consequences, including:

Potential Impact

Access Control

Bypass Protection Mechanism

Demonstrative Examples

In the following example, an XSS neutralization method intends to replace script tags in user-supplied input with a safe equivalent:
Bad
public String preventXSS(String input, String mask) {return input.replaceAll("script", mask);}
The code only works when the "script" tag is in all lower-case, forming an incomplete denylist (CWE-184). Equivalent tags such as "SCRIPT" or "ScRiPt" will not be neutralized by this method, allowing an XSS attack.

Mitigations & Prevention

Architecture and Design

Avoid making decisions based on names of resources (e.g. files) if those resources can have alternate names.

Implementation

Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across relat

Implementation

Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

Real-World CVE Examples

CVE IDDescription
CVE-2000-0499Application server allows attackers to bypass execution of a jsp page and read the source code using an upper case JSP extension in the request.
CVE-2000-0497The server is case sensitive, so filetype handlers treat .jsp and .JSP as different extensions. JSP source code may be read because .JSP defaults to the filetype "text".
CVE-2000-0498The server is case sensitive, so filetype handlers treat .jsp and .JSP as different extensions. JSP source code may be read because .JSP defaults to the filetype "text".
CVE-2001-0766A URL that contains some characters whose case is not matched by the server's filters may bypass access restrictions because the case-insensitive file system will then handle the request after it bypa
CVE-2001-0795Server allows remote attackers to obtain source code of CGI scripts via URLs that contain MS-DOS conventions such as (1) upper case letters or (2) 8.3 file names.
CVE-2001-1238Task Manager does not allow local users to end processes with uppercase letters named (1) winlogon.exe, (2) csrss.exe, (3) smss.exe and (4) services.exe via the Process tab which could allow local use
CVE-2003-0411chain: Code was ported from a case-sensitive Unix platform to a case-insensitive Windows platform where filetype handlers treat .jsp and .JSP as different extensions. JSP source code may be read becau
CVE-2002-0485Leads to interpretation error
CVE-1999-0239Directories may be listed because lower case web requests are not properly handled by the server.
CVE-2005-0269File extension check in forum software only verifies extensions that contain all lowercase letters, which allows remote attackers to upload arbitrary files via file extensions that include uppercase l
CVE-2004-1083Web server restricts access to files in a case sensitive manner, but the filesystem accesses files in a case insensitive manner, which allows remote attackers to read privileged files using alternate
CVE-2002-2119Case insensitive passwords lead to search space reduction.
CVE-2004-2214HTTP server allows bypass of access restrictions using URIs with mixed case.
CVE-2004-2154Mixed upper/lowercase allows bypass of ACLs.
CVE-2005-4509Bypass malicious script detection by using tokens that aren't case sensitive.

Showing 15 of 18 observed examples.

Taxonomy Mappings

  • PLOVER: — Case Sensitivity (lowercase, uppercase, mixed case)

Frequently Asked Questions

What is CWE-178?

CWE-178 (Improper Handling of Case Sensitivity) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product does not properly account for differences in case sensitivity when accessing or determining the properties of a resource, leading to inconsistent results.

How can CWE-178 be exploited?

Attackers can exploit CWE-178 (Improper Handling of Case Sensitivity) to bypass protection mechanism. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-178?

Key mitigations include: Avoid making decisions based on names of resources (e.g. files) if those resources can have alternate names.

What is the severity of CWE-178?

CWE-178 is classified as a Base-level weakness (Medium abstraction). It has been observed in 18 real-world CVEs.