CWEweakness

CWE-182 Collapse of Data into Unsafe Value

Official page ↗
Abstraction
Base
Structure
Simple
Status
Draft
Languages
Not Language-Specific
CWE version
5.0

Description

The product filters data in a way that causes it to be reduced or "collapsed" into an unsafe value that violates an expected security property.

Common consequences

• Access Control: Bypass Protection Mechanism

Potential mitigations

• [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 related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. • [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. • Canonicalize the name to match that of the file system's representation of the name. This can sometimes be achieved with an available API (e.g. in Win32 the GetFullPathName function).

Detection methods

• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Observed examples

• CVE-2004-0815: "/.////" in pathname collapses to absolute path. • CVE-2005-3123: "/.//..//////././" is collapsed into "/.././" after ".." and "//" sequences are removed. • CVE-2002-0325: ".../...//" collapsed to "..." due to removal of "./" in web server. • CVE-2002-0784: Chain: HTTP server protects against ".." but allows "." variants such as "////./../.../". If the server removes "/.." sequences, the result would collapse into an unsafe value "////../" (CWE-182). • CVE-2005-2169: Chain: ".../...//" bypasses protection mechanism using regexp's that remove "../" resulting in collapse into an unsafe value "../" (CWE-182) and resultant path traversal. • CVE-2001-1157: XSS protection mechanism strips a <script> sequence that is nested in another <script> sequence.

Related

Observed example · CVE (6)

  • CVE-2005-3123 Directory traversal vulnerability in GNUMP3D before 2.9.6 allows remote attackers to read arbitrary files via crafted sequences such as… vulnerability
  • CVE-2005-2169 Directory traversal vulnerability in source.php in Quick & Dirty PHPSource Printer 1.1 and earlier allows remote attackers to read… vulnerability
  • CVE-2004-0815 The unix_clean_name function in Samba 2.2.x through 2.2.11, and 3.0.x before 3.0.2a, trims certain directory names down to absolute paths,… vulnerability
  • CVE-2002-0784 Directory traversal vulnerability in Lysias Lidik web server 0.7b allows remote attackers to list directories via an HTTP request with a ... vulnerability
  • CVE-2002-0325 Directory traversal vulnerability in BadBlue before 1.6.1 allows remote attackers to read arbitrary files via a ... vulnerability
  • CVE-2001-1157 Baltimore Technologies WEBsweeper 4.0 and 4.02 does not properly filter Javascript from HTML pages, which could allow remote attackers to… vulnerability

Can precede · CWE (3)

  • CWE-33 Path Traversal: '....' (Multiple Dot) weakness
  • CWE-34 Path Traversal: '....//' weakness
  • CWE-35 Path Traversal: '.../...//' weakness

Child of · CWE (1)

  • CWE-790 Improper Filtering of Special Elements weakness

Referenced by CVE · weakness (4)

  • CVE-2026-111896 phpMyFAQ from 4.2.0-alpha before 4.2.0-beta contains a stored cross-site scripting vulnerability in SvgSanitizer that allows FAQ editors to… vulnerability
  • CVE-2026-47241 Net::IMAP implements Internet Message Access Protocol (IMAP) client functionality in Ruby. vulnerability
  • CVE-2024-25617 Squid is an open source caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. vulnerability
  • CVE-2020-7921 Improper serialization of internal state in the authorization subsystem in MongoDB Server's authorization subsystem permits a user with… vulnerability

Referenced by CWE · can precede (1)

  • CWE-185 Incorrect Regular Expression weakness