ClassDraft

CWE-138Improper Neutralization of Special Elements

Category: other

Description

The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could be interpreted as control elements or syntactic markers when they are sent to a downstream component. Most languages and protocols have their own special elements such as characters and reserved words. These special elements can carry control implications. If product does not prevent external control or influence over the inclusion of such special elements, the control flow of the program may be altered from what was intended. For example, both Unix and Windows interpret the symbol < ("less than") as meaning "read input from a file".

Common consequences· 1

  • Confidentiality / Integrity / Availability / Other — Execute Unauthorized Code or Commands, Alter Execution Logic, DoS: Crash, Exit, or Restart

Potential mitigations· 5

  • [Implementation]Developers should anticipate that special elements (e.g. delimiters, symbols) will be injected into input vectors of their product. One defense is to create an allowlist (e.g. a regular expression) that defines valid input according to the requirements specifications. Strictly filter any input that does not match against the allowlist. Properly encode your output, and quote any elements that have special meaning to the component with which you are communicating.
  • [Implementation]
  • [Implementation]Use and specify an appropriate output encoding to ensure that the special elements are well-defined. A normal byte sequence in one encoding could be a special element in another.
  • [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.
  • [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).

Related CAPEC attack patterns· 3

CAPEC-105CAPEC-15CAPEC-34

References

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

Exploits (incoming)3

TypeTargetConfidenceTier
AttackPatternHTTP Request Splittingcapec-105100%live
AttackPatternHTTP Response Splittingcapec-34100%live
AttackPatternCommand Delimiterscapec-15100%live

(incoming)7

TypeTargetConfidenceTier
KEVEntryNagios XI OS Command Injectionkev-cve-2021-252960%live
KEVEntryNagios XI OS Command Injectionkev-cve-2021-252970%live
KEVEntryNagios XI OS Command Injectionkev-cve-2021-252980%live
KEVEntryAccellion FTA SQL Injection Vulnerabilitykev-cve-2021-271010%live
KEVEntryRealtek Jungle SDK Remote Code Execution Vulnerabilitykev-cve-2021-353940%live
KEVEntrydotCMS Unrestricted Upload of File Vulnerabilitykev-cve-2022-263520%live
KEVEntrySynacor Zimbra Collaboration Suite (ZCS) Cross-Site Scripting (XSS) Vulnerabilitykev-cve-2022-279260%live

Related by meaning· 6

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

CWE
Improper Neutralization of Expression/Command Delimiters
CWE
Improper Neutralization of Parameter/Argument Delimiters
CWE
Improper Neutralization of Wildcards or Matching Symbols
CWE
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
CWE
Improper Neutralization of Leading Special Elements
CWE
Improper Neutralization of Internal Special Elements
Sourced from MITRE CWE 4.20. Curated for EU compliance use cases by Adam Lundqvist, Founder at SQUR.