---
title: "CWE-172: Improper Encoding or Decoding of Data"
url: https://radicalnotion.ai/cwe/cwe-172
type: cwe
description: "The product does not properly encode or decode data, resulting in unexpected values that are not equivalent to the original data."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-172: Improper Encoding or Decoding of Data

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

## Description

The product does not properly encode or decode data, resulting in unexpected values that are not equivalent to the original data.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Unexpected State | Unexpected values could be produced that are not equivalent to the incoming or outgoing data. |

## Potential mitigations

### 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-2004-1315 | Forum software improperly URL decodes the highlight parameter when extracting text to highlight, which allows remote attackers to execute arbitrary PHP code by double-encoding the highlight value so that special characters are inserted into the result. |
| CVE-2004-1939 | XSS protection mechanism attempts to remove "/" that could be used to close tags, but it can be bypassed using double encoded slashes (%252F) |
| CVE-2001-0709 | Server allows a remote attacker to obtain source code of ASP files via a URL encoded with Unicode. |
| CVE-2005-2256 | Hex-encoded path traversal variants - "%2e%2e", "%2e%2e%2f", "%5c%2e%2e" |

## Real CVEs with this weakness (sample of 12 of 25)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2019-10160 | python: regression of CVE-2019-9636 due to functional fix to allow port numbers in netloc | critical | 9.8 | - | No | 2019-06-07 |
| CVE-2016-6691 | - | critical | 9.8 | - | No | 2016-10-10 |
| CVE-2025-27110 | Libmodsecurity3 has possible bypass of encoded HTML entities | high | 7.9 | - | No | 2025-02-25 |
| CVE-2020-36213 | Update unsound DrainFilter and RString::retain | high | 7.5 | - | No | 2021-01-22 |
| CVE-2026-95101 | NGINX ngx\_http\_v3\_module vulnerability | medium | 6.9 | - | No | 2026-10-14 |
| CVE-2026-100891 | Trusted Domain Project OpenDMARC Internationalized Domain Name opendmarc\_policy.c opendmarc\_policy\_query\_dmarc encoding error | medium | 6.9 | - | No | 2026-09-28 |
| CVE-2026-48784 | Symfony: UrlGenerator Dot-Segment Encoding Skips Every Other Chained \`../\` or \`./\` → Generated URL Collapses Off-Route Under RFC 3986 Normalization | medium | 6.9 | - | No | 2026-07-14 |
| CVE-2019-12677 | Cisco Adaptive Security Appliance Software SSL VPN Denial of Service Vulnerability | medium | 6.5 | - | No | 2019-10-02 |
| CVE-2019-11721 | Mozilla: Domain spoofing through unicode latin 'kra' character | medium | 6.5 | - | No | 2019-07-23 |
| CVE-2026-61812 | ModSecurity: HTML decoder missing entities, leading to evasion | medium | 6.3 | - | No | 2026-11-09 |
| CVE-2026-42926 | NGINX ngx\_http\_proxy\_v2\_module vulnerability | medium | 6.3 | - | No | 2026-05-13 |
| CVE-2026-110306 | fast-uri vulnerable to URI scheme spoofing via percent-encoded scheme decoding | medium | 6.1 | - | No | 2026-10-20 |

## Related attack patterns (CAPEC)

- [CAPEC-120](https://radicalnotion.ai/capec/capec-120): Double Encoding
- [CAPEC-267](https://radicalnotion.ai/capec/capec-267): Leverage Alternate Encoding
- [CAPEC-3](https://radicalnotion.ai/capec/capec-3): Using Leading 'Ghost' Character Sequences to Bypass Input Filters
- [CAPEC-52](https://radicalnotion.ai/capec/capec-52): Embedding NULL Bytes
- [CAPEC-53](https://radicalnotion.ai/capec/capec-53): Postfix, Null Terminate, and Backslash
- [CAPEC-64](https://radicalnotion.ai/capec/capec-64): Using Slashes and URL Encoding Combined to Bypass Validation Logic
- [CAPEC-71](https://radicalnotion.ai/capec/capec-71): Using Unicode Encoding to Bypass Validation Logic
- [CAPEC-72](https://radicalnotion.ai/capec/capec-72): URL Encoding
- [CAPEC-78](https://radicalnotion.ai/capec/capec-78): Using Escaped Slashes in Alternate Encoding
- [CAPEC-80](https://radicalnotion.ai/capec/capec-80): Using UTF-8 Encoding to Bypass Validation Logic

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-707](https://radicalnotion.ai/cwe/cwe-707) | Improper Neutralization |
| Child | [CWE-173](https://radicalnotion.ai/cwe/cwe-173) | Improper Handling of Alternate Encoding |
| Child | [CWE-174](https://radicalnotion.ai/cwe/cwe-174) | Double Decoding of the Same Data |
| Child | [CWE-175](https://radicalnotion.ai/cwe/cwe-175) | Improper Handling of Mixed Encoding |
| Child | [CWE-176](https://radicalnotion.ai/cwe/cwe-176) | Improper Handling of Unicode Encoding |
| Child | [CWE-177](https://radicalnotion.ai/cwe/cwe-177) | Improper Handling of URL Encoding (Hex Encoding) |
| Can precede | [CWE-22](https://radicalnotion.ai/cwe/cwe-22) | Improper Limitation of a Pathname to a Restricted Directory |
| Can precede | [CWE-41](https://radicalnotion.ai/cwe/cwe-41) | Improper Resolution of Path Equivalence |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Encoding Error | - | - |

## Frequently asked questions

### What is CWE-172?

The product does not properly encode or decode data, resulting in unexpected values that are not equivalent to the original data.

### What CVEs are caused by CWE-172?

25 recorded CVEs are attributed to CWE-172, including CVE-2019-10160, CVE-2016-6691 and CVE-2025-27110.

### How do you prevent CWE-172?

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.

### What are the consequences of CWE-172?

Exploiting CWE-172 can lead to: Unexpected State.

### Is CWE-172 actively exploited?

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

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

---

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