---
title: "CWE-159: Improper Handling of Invalid Use of Special Elements"
url: https://radicalnotion.ai/cwe/cwe-159
type: cwe
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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-159: Improper Handling of Invalid Use of Special Elements

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 11
- **Of those, in CISA KEV:** 0
- **New in 2026:** 2
- **CWE catalog version:** 4.21

## 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.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Unexpected State | - |

## Potential mitigations

### Mitigation

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 (Input Validation)

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 (Output Encoding)

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 (Input Validation)

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 | Description |
| --- | --- |
| CVE-2002-1362 | Crash via message type without separator character |
| CVE-2000-0116 | Extra "\<" in front of SCRIPT tag bypasses XSS prevention. |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2019-9505 | PrinterLogic Print Management Software does not sanitize special characters | critical | 9.8 | - | No | 2019-05-08 |
| CVE-2020-1653 | Junos OS: Kernel crash (vmcore) or FPC crash due to mbuf leak | high | 7.5 | - | No | 2020-07-17 |
| CVE-2020-1648 | Junos OS and Junos OS Evolved: RPD crash when processing a specific BGP packet | high | 7.5 | - | No | 2020-07-17 |
| CVE-2020-1646 | Junos OS and Junos OS Evolved: RPD crash while processing a specific BGP update information. | high | 7.5 | - | No | 2020-07-17 |
| CVE-2026-35536 | Tornado has cookie attribute injection via .RequestHandler.set\_cookie | high | 7.2 | - | No | 2026-04-03 |
| CVE-2026-2636 | Denial of Service in Microsoft OS | medium | 5.5 | - | No | 2026-02-25 |
| 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 to the shell mistaking specific characters for reserved characters. This may be used for DoS under rare conditions of filtered command input. | medium | 5.5 | - | No | 2021-11-15 |
| CVE-2021-21707 | Special characters break path parsing in XML functions | medium | 5.3 | - | No | 2021-11-29 |
| CVE-2020-29022 | Host Header Injection allowing web cache poisoning attacks | medium | 5.3 | - | No | 2021-02-16 |
| CVE-2025-61984 | openssh: OpenSSH: Control characters in usernames can lead to code execution via ProxyCommand | low | 3.6 | - | No | 2025-10-06 |
| CVE-2025-52884 | risc0-ethereum-contracts allows invalid commitment with digest value of zero to be accepted by Steel.validateCommitment | low | 1.7 | - | No | 2025-06-24 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-138](https://radicalnotion.ai/cwe/cwe-138) | Improper Neutralization of Special Elements |
| Child | [CWE-166](https://radicalnotion.ai/cwe/cwe-166) | Improper Handling of Missing Special Element |
| Child | [CWE-167](https://radicalnotion.ai/cwe/cwe-167) | Improper Handling of Additional Special Element |
| Child | [CWE-168](https://radicalnotion.ai/cwe/cwe-168) | Improper Handling of Inconsistent Special Elements |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Common Special Element Manipulations | - | - |
| Software Fault Patterns | Tainted input to command | SFP24 | - |

## Frequently asked questions

### 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?

11 recorded CVEs are attributed to CWE-159, including CVE-2019-9505, CVE-2020-1653 and CVE-2020-1648.

### 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?

11 recorded CVEs are caused by CWE-159; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/159.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-159). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
