ClassDraft

CWE-172Encoding Error

Category: other

Description

The product does not properly encode or decode the data, resulting in unexpected values.

Common consequences· 1

  • Integrity — Unexpected State

Potential mitigations· 3

  • [Implementation]
  • [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.

Related CAPEC attack patterns· 10

CAPEC-120CAPEC-267CAPEC-3CAPEC-52CAPEC-53CAPEC-64CAPEC-71CAPEC-72CAPEC-78CAPEC-80

References

  1. https://cwe.mitre.org/data/definitions/172.html

Exploits (incoming)10

TypeTargetConfidenceTier
AttackPatternDouble Encodingcapec-120100%live
AttackPatternPostfix, Null Terminate, and Backslashcapec-53100%live
AttackPatternUsing UTF-8 Encoding to Bypass Validation Logiccapec-80100%live
AttackPatternUsing Slashes and URL Encoding Combined to Bypass Validation Logiccapec-64100%live
AttackPatternUsing Unicode Encoding to Bypass Validation Logiccapec-71100%live
AttackPatternUsing Escaped Slashes in Alternate Encodingcapec-78100%live
AttackPatternUsing Leading 'Ghost' Character Sequences to Bypass Input Filterscapec-3100%live
AttackPatternURL Encodingcapec-72100%live
AttackPatternEmbedding NULL Bytescapec-52100%live
AttackPatternLeverage Alternate Encodingcapec-267100%live

Related by meaning· 6

Nearest entities by semantic similarity across the cs-graph corpus.

CWE
Insufficient Verification of Data Authenticity
CWE
Origin Validation Error
CWE
Improper Input Validation
CWE
Improper Handling of Alternate Encoding
CWE
Use of Incorrect Byte Ordering
CWE
Inappropriate Encoding for Output Context
Sourced from MITRE CWE 4.20. Curated for EU compliance use cases by Adam Lundqvist, Founder at SQUR.