CWE-172: Encoding Error
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
The product does not properly encode or decode the data, resulting in unexpected values.
常见后果
影响范围: Integrity
技术影响: Unexpected State
潜在缓解措施
阶段: Implementation
策略: Input Validation
阶段: 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.
观察示例
参考: 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"
引入模式
| 阶段 | 说明 |
|---|---|
| Implementation | - |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| PLOVER | - | Encoding Error | - |
关键信息
CWE ID: CWE-172
抽象级别: Class
结构: Simple
状态: Draft