CAPECattack pattern

CAPEC-3 Using Leading 'Ghost' Character Sequences to Bypass Input Filters

Medium Official page ↗
Abstraction
Detailed
Status
Draft
Likelihood of attack
Medium
Typical severity
Medium
CAPEC version
3.9

Description

Some APIs will strip certain leading characters from a string of parameters. An adversary can intentionally introduce leading "ghost" characters (extra characters that don't affect the validity of the request at the API layer) that enable the input to pass the filters and therefore process the adversary's input. This occurs when the targeted API will accept input data in several syntactic forms and interpret it in the equivalent semantic way, while the filter does not take into account the full spectrum of the syntactic forms acceptable to the targeted API.

Execution flow

1. [Explore] [Survey the application for user-controllable inputs] Using a browser, an automated tool or by inspecting the application, an adversary records all entry points to the application. 2. [Experiment] [Probe entry points to locate vulnerabilities] The adversary uses the entry points gathered in the "Explore" phase as a target list and injects various leading 'Ghost' character sequences to determine how to application filters them. 3. [Exploit] [Bypass input filtering] Using what the adversary learned about how the application filters input data, they craft specific input data that bypasses the filter. This can lead to directory traversal attacks, arbitrary shell command execution, corruption of files, etc.

Prerequisites

• The targeted API must ignore the leading ghost characters that are used to get past the filters for the semantics to be the same.

Skills required

• [Medium] The ability to make an API request, and knowledge of "ghost" characters that will not be filtered by any input validation. These "ghost" characters must be known to not affect the way in which the request will be interpreted.

Consequences

• Confidentiality, Access Control, Authorization: Gain Privileges • Integrity: Modify Data

Mitigations

• Use an allowlist rather than a denylist input validation. • Canonicalize all data prior to validation. • Take an iterative approach to input validation (defense in depth).

Related

Child of · CAPEC (1)

  • CAPEC-267 Leverage Alternate Encoding attack pattern

Weakness · CWE (12)

  • CWE-172 Improper Encoding or Decoding of Data weakness
  • CWE-173 Improper Handling of Alternate Encoding weakness
  • CWE-179 Incorrect Behavior Order: Early Validation weakness
  • CWE-180 Incorrect Behavior Order: Validate Before Canonicalize weakness
  • CWE-181 Incorrect Behavior Order: Validate Before Filter weakness
  • CWE-183 Permissive List of Allowed Inputs weakness
  • CWE-184 Incomplete List of Disallowed Inputs weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-41 Improper Resolution of Path Equivalence weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-707 Improper Neutralization weakness
  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness

Referenced by CWE · attack pattern (12)

  • CWE-172 Improper Encoding or Decoding of Data weakness
  • CWE-173 Improper Handling of Alternate Encoding weakness
  • CWE-179 Incorrect Behavior Order: Early Validation weakness
  • CWE-180 Incorrect Behavior Order: Validate Before Canonicalize weakness
  • CWE-181 Incorrect Behavior Order: Validate Before Filter weakness
  • CWE-183 Permissive List of Allowed Inputs weakness
  • CWE-184 Incomplete List of Disallowed Inputs weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-41 Improper Resolution of Path Equivalence weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-707 Improper Neutralization weakness
  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness