CWEweakness
CWE-172 Improper Encoding or Decoding of Data
- Abstraction
- Class
- Structure
- Simple
- Status
- Draft
- Languages
- Not Language-Specific
- CWE version
- 5.0
Description
The product does not properly encode or decode data, resulting in unexpected values that are not equivalent to the original data.
Common consequences
• Integrity: Unexpected State — Unexpected values could be produced that are not equivalent to the incoming or outgoing data.
Potential mitigations
• [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-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"
Related
Attack pattern · CAPEC (10)
- CAPEC-120 Double Encoding attack pattern
- CAPEC-267 Leverage Alternate Encoding attack pattern
- CAPEC-3 Using Leading 'Ghost' Character Sequences to Bypass Input Filters attack pattern
- CAPEC-52 Embedding NULL Bytes attack pattern
- CAPEC-53 Postfix, Null Terminate, and Backslash attack pattern
- CAPEC-64 Using Slashes and URL Encoding Combined to Bypass Validation Logic attack pattern
- CAPEC-71 Using Unicode Encoding to Bypass Validation Logic attack pattern
- CAPEC-72 URL Encoding attack pattern
- CAPEC-78 Using Escaped Slashes in Alternate Encoding attack pattern
- CAPEC-80 Using UTF-8 Encoding to Bypass Validation Logic attack pattern
Observed example · CVE (4)
- CVE-2005-2256 Encoded directory traversal vulnerability in phpPgAdmin 3.1 to 3.5.3 allows remote attackers to access arbitrary files via "%2e%2e%2f"… vulnerability
- CVE-2004-1315 viewtopic.php in phpBB 2.x before 2.0.11 improperly URL decodes the highlight parameter when extracting words and phrases to highlight,… vulnerability
- CVE-2004-1939 Cross-site scripting (XSS) vulnerability in Zaep AntiSpam 2.0 allows remote attackers to inject arbitrary web script or HTML via double… vulnerability
- CVE-2001-0709 Microsoft IIS 4.0 and before, when installed on a FAT partition, allows a remote attacker to obtain source code of ASP files via a URL… vulnerability
Can precede · CWE (2)
Child of · CWE (1)
- CWE-707 Improper Neutralization weakness
Referenced by CAPEC · weakness (10)
- CAPEC-120 Double Encoding attack pattern
- CAPEC-267 Leverage Alternate Encoding attack pattern
- CAPEC-3 Using Leading 'Ghost' Character Sequences to Bypass Input Filters attack pattern
- CAPEC-52 Embedding NULL Bytes attack pattern
- CAPEC-53 Postfix, Null Terminate, and Backslash attack pattern
- CAPEC-64 Using Slashes and URL Encoding Combined to Bypass Validation Logic attack pattern
- CAPEC-71 Using Unicode Encoding to Bypass Validation Logic attack pattern
- CAPEC-72 URL Encoding attack pattern
- CAPEC-78 Using Escaped Slashes in Alternate Encoding attack pattern
- CAPEC-80 Using UTF-8 Encoding to Bypass Validation Logic attack pattern
Referenced by CVE · weakness (23)
- CVE-2026-110306 fast-uri is a dependency-free RFC 3986 URI parser and serializer for Node.js. vulnerability
- CVE-2026-95101 Description NGINX Plus and NGINX Open Source have a vulnerability in the ngx_http_v3_module module. vulnerability
- CVE-2026-104774 OWASP Coraza WAF is a golang modsecurity compatible web application firewall library. vulnerability
- CVE-2026-106122 The RabbitMQ Java client library allows Java and JVM-based applications to connect to and interact with RabbitMQ nodes. vulnerability
- CVE-2026-100891 A vulnerability has been found in Trusted Domain Project OpenDMARC up to 1.4.2. vulnerability
- CVE-2026-86818 fast-uri is a dependency-free RFC 3986 URI parser for Node.js, used by Fastify and ajv, that added a mailto scheme parser in version 4.1.3. vulnerability
- CVE-2026-48784 Symfony is a PHP framework for web and console applications and a set of reusable PHP components. vulnerability
- CVE-2026-42926 When NGINX Open Source is configured to proxy HTTP/2 traffic by setting proxy_http_version to 2, and also uses proxy_set_body, an attacker… vulnerability
- CVE-2025-12758 Versions of the package validator before 13.15.22 are vulnerable to Incomplete Filtering of One or More Instances of Special Elements in… vulnerability
- CVE-2025-27110 Libmodsecurity is one component of the ModSecurity v3 project. vulnerability
- CVE-2024-48909 SpiceDB is an open source database for scalably storing and querying fine-grained authorization data. vulnerability
- CVE-2021-33604 URL encoding error in development mode handler in com.vaadin:flow-server versions 2.0.0 through 2.6.1 (Vaadin 14.0.0 through 14.6.1), 3.0.0… vulnerability
- CVE-2019-12677 A vulnerability in the Secure Sockets Layer (SSL) VPN feature of Cisco Adaptive Security Appliance (ASA) Software could allow an… vulnerability
- CVE-2019-10153 A flaw was discovered in fence-agents, prior to version 4.3.4, where using non-ASCII characters in a guest VM's comment or other fields… vulnerability
- CVE-2019-10160 A security regression of CVE-2019-9636 was discovered in python since commit d537ab0ff9767ef024f26246899728f0116b1ec3 affecting versions… vulnerability
- CVE-2018-3777 Insufficient URI encoding in restforce before 3.0.0 allows attacker to inject arbitrary parameters into Salesforce API requests. vulnerability
- CVE-2018-2415 SAP NetWeaver Application Server Java Web Container and HTTP Service (Engine API, from 7.10 to 7.11, 7.30, 7.31, 7.40, 7.50; J2EE Engine… vulnerability
- CVE-2018-7289 An issue was discovered in armadito-windows-driver/src/communication.c in Armadito 0.12.7.2. vulnerability
- CVE-2018-7173 A large loop in JBIG2Stream::readSymbolDictSeg in xpdf 4.00 allows an attacker to cause denial of service via a specific file due to… vulnerability
- CVE-2016-6691 service/jni/com_android_server_wifi_Gbk2Utf.cpp in the Qualcomm Wi-Fi gbk2utf module in Android before 2016-10-05 allows remote attackers… vulnerability
- CVE-2016-3827 codecs/hevcdec/SoftHEVC.cpp in libstagefright in mediaserver in Android 6.0.1 before 2016-08-01 mishandles decoder errors, which allows… vulnerability
- CVE-2016-3828 decoder/ih264d_api.c in mediaserver in Android 6.x before 2016-08-01 mishandles invalid PPS and SPS NAL units, which allows remote… vulnerability
- CVE-2016-3829 The ih264d decoder in mediaserver in Android 6.x before 2016-08-01 does not initialize certain structure members, which allows remote… vulnerability