CWEweakness

CWE-159 Improper Handling of Invalid Use of Special Elements

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

Description

The product does not properly filter, remove, quote, or otherwise manage the invalid use of special elements in user-controlled input, which could cause adverse effect on its behavior and integrity.

Common consequences

• Integrity: Unexpected State

Potential mitigations

• Developers should anticipate that special elements will be injected/removed/manipulated in the input vectors of their software system. Use an appropriate combination of denylists and allowlists to ensure only valid, expected and appropriate input is processed by the system. • [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] While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88). • [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.

Observed examples

• CVE-2002-1362: Crash via message type without separator character • CVE-2000-0116: Extra "<" in front of SCRIPT tag bypasses XSS prevention.

Related

Observed example · CVE (2)

  • CVE-2002-1362 mICQ 0.4.9 and earlier allows remote attackers to cause a denial of service (crash) via malformed ICQ message types without a 0xFE… vulnerability
  • CVE-2000-0116 Firewall-1 does not properly filter script tags, which allows remote attackers to bypass the "Strip Script Tags" restriction by including… vulnerability

Child of · CWE (1)

  • CWE-138 Improper Neutralization of Special Elements weakness

Referenced by CVE · weakness (13)

  • CVE-2026-35536 In Tornado before 6.5.5, cookie attribute injection could occur because the domain, path, and samesite arguments to… vulnerability
  • CVE-2026-29106 SuiteCRM is an open-source, enterprise-ready Customer Relationship Management (CRM) software application. vulnerability
  • CVE-2026-2636 This vulnerability is caused by a CWE‑159: "Improper Handling of Invalid Use of Special Elements" weakness, which leads to an unrecoverable… vulnerability
  • CVE-2025-61984 ssh in OpenSSH before 10.1 allows control characters in usernames that originate from certain possibly untrusted sources, potentially… vulnerability
  • CVE-2025-52884 RISC Zero is a zero-knowledge verifiable general computing platform, with Ethereum integration. vulnerability
  • CVE-2024-51500 Meshtastic firmware is a device firmware for the Meshtastic project. vulnerability
  • CVE-2021-21707 In PHP versions 7.3.x below 7.3.33, 7.4.x below 7.4.26 and 8.0.x below 8.0.13, certain XML parsing functions, like simplexml_load_file(),… vulnerability
  • CVE-2021-42375 An incorrect handling of a special element in Busybox's ash applet leads to denial of service when processing a crafted shell command, due… vulnerability
  • CVE-2020-29022 Failure to Sanitize host header value on output in the GateManager Web server could allow an attacker to conduct web cache poisoning… vulnerability
  • CVE-2020-1646 On Juniper Networks Junos OS and Junos OS Evolved devices, processing a specific UPDATE for an EBGP peer can lead to a routing process… vulnerability
  • CVE-2020-1648 On Juniper Networks Junos OS and Junos OS Evolved devices, processing a specific BGP packet can lead to a routing process daemon (RPD)… vulnerability
  • CVE-2020-1653 On Juniper Networks Junos OS devices, a stream of TCP packets sent to the Routing Engine (RE) may cause mbuf leak which can lead to… vulnerability
  • CVE-2019-9505 The PrinterLogic Print Management software, versions up to and including 18.3.1.96, does not sanitize special characters allowing for… vulnerability

Referenced by CWE · child of (3)

  • CWE-166 Improper Handling of Missing Special Element weakness
  • CWE-167 Improper Handling of Additional Special Element weakness
  • CWE-168 Improper Handling of Inconsistent Special Elements weakness

Referenced by OWASP · mapped cwe (1)