CWE-159: Improper Handling of Invalid Use of Special Elements
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.
Last updated
Overview
CWE-159 (Improper Handling of Invalid Use of Special Elements) is a class-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Real-world CVEs
12 recorded CVEs are caused by CWE-159 (Improper Handling of Invalid Use of Special Elements). The highest-severity and most recent are shown first. 2 new CWE-159 CVEs have been recorded so far in 2026 (2 in 2025).
- CVE-2019-9505Critical · CVSS 9.8 · EPSS 88th2019-05-08
- CVE-2024-51500High · CVSS 7.5 · EPSS 32th2024-11-04
- CVE-2020-1653High · CVSS 7.5 · EPSS 73th2020-07-17
- CVE-2020-1648
Junos OS and Junos OS Evolved: RPD crash when processing a specific BGP packet
High · CVSS 7.5 · EPSS 67th2020-07-17 - CVE-2020-1646High · CVSS 7.5 · EPSS 59th2020-07-17
- CVE-2026-35536High · CVSS 7.2 · EPSS 15th2026-04-03
- CVE-2026-2636
Denial of Service in Microsoft OS
Medium · CVSS 5.5 · EPSS 33th2026-02-25 - CVE-2021-42375Medium · CVSS 5.5 · EPSS 30th2021-11-15
- CVE-2021-21707Medium · CVSS 5.3 · EPSS 98th2021-11-29
- CVE-2020-29022Medium · CVSS 5.3 · EPSS 53th2021-02-16
- CVE-2025-61984Low · CVSS 3.6 · EPSS 20th2025-10-06
- CVE-2025-52884
risc0-ethereum-contracts allows invalid commitment with digest value of zero to be accepted by Steel.validateCommitment
Low · CVSS 1.7 · EPSS 27th2025-06-24
Common consequences
What can happen when CWE-159 is exploited.
Unexpected State
Affects: Integrity
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
How to prevent it
Practical mitigations for CWE-159, grouped by where in the lifecycle they apply.
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.
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.
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).
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.
Illustrative examples
Real CVEs that MITRE cites as examples of this weakness.
- CVE-2002-1362 — Crash via message type without separator character
- CVE-2000-0116 — Extra "<" in front of SCRIPT tag bypasses XSS prevention.
Terminology & mappings
Mapped taxonomies
- PLOVER: Common Special Element Manipulations
- Software Fault Patterns: Tainted input to command (SFP24)
Frequently asked questions
Common questions about CWE-159.
- What is CWE-159?
- 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.
- What CVEs are caused by CWE-159?
- 12 recorded CVEs are attributed to CWE-159, including CVE-2019-9505, CVE-2024-51500, CVE-2020-1653.
- How do you prevent CWE-159?
- 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.
- What are the consequences of CWE-159?
- Exploiting CWE-159 can lead to: Unexpected State.
- Is CWE-159 actively exploited?
- 12 recorded CVEs are caused by CWE-159; none are currently in CISA's KEV catalog of actively exploited flaws.
References
- MITRE CWE definition (CWE-159) (opens in a new tab)
- CWE-159 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-159
Get alerted the moment a new CWE-159 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.