Home > CAPEC List > CAPEC-3: Using Leading 'Ghost' Character Sequences to Bypass Input Filters (Version 2.11)  

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

Using Leading 'Ghost' Character Sequences to Bypass Input Filters
Definition in a New Window Definition in a New Window
Attack Pattern ID: 3
Abstraction: Detailed
Status: Draft
Completeness: Complete
Presentation Filter:
+ Summary

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.

+ Attack Steps
  1. Determine if the source code is available and if so, examine the filter logic.

  1. If the source code is not available, write a small program that loops through various possible inputs to given API call and tries a variety of alternate (but equivalent) encodings of strings with leading ghost characters. Knowledge of frameworks and libraries used and what filters they apply will help to make this search more structured.

  2. Observe the effects. See if the probes are getting past the filters. Identify a string that is semantically equivalent to that which an adversary wants to pass to the targeted API, but syntactically structured in a way as to get past the input filter. That encoding will contain certain ghost characters that will help it get past the filters. These ghost characters will be ignored by the targeted API.

  1. Once the "winning" alternate encoding using (typically leading) ghost characters is identified, an adversary can launch the attacks against the targeted API (e.g. directory traversal attack, arbitrary shell command execution, corruption of files)

+ Attack 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.

+ Typical Severity


+ Typical Likelihood of Exploit

Likelihood: Medium

+ Methods of Attack
  • Injection
  • API Abuse
+ Examples-Instances


Alternate Encoding with Ghost Characters in FTP and Web Servers

Some web and FTP servers fail to detect prohibited upward directory traversals if the user-supplied pathname contains extra characters such as an extra leading dot. For example, a program that will disallow access to the pathname "../test.txt" may erroneously allow access to that file if the pathname is specified as ".../test.txt". This attack succeeds because 1) the input validation logic fails to detect the triple-dot as a directory traversal attempt (since it isn't dot-dot), 2) some part of the input processing decided to strip off the "extra" dot, leaving the dot-dot behind.

Using the file system API as the target, the following strings are all equivalent to many programs:


As you can see, there are many ways to make a semantically equivalent request. All these strings ultimately result in a request for the file ../test.txt.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Medium

+ Solutions and Mitigations

Perform white list rather than black list input validation.

Canonicalize all data prior to validation.

Take an iterative approach to input validation (defense in depth).

+ Attack Motivation-Consequences
ScopeTechnical ImpactNote
Gain privileges / assume identity
Modify application data
+ Injection Vector

Web Form, URL, Network Socket, File

+ Payload

The payload is the parameter that an adversary is supplying to the targeted API that will allow the adversary to elevate privilege and subvert the authorization service.

+ Activation Zone

The targeted API is the activation zone. These attacks often target the file system or the shell to execute commands.

+ Payload Activation Impact

Failure in authorization service may lead to compromises in data confidentiality and integrity.

+ Purposes
  • Exploitation
+ CIA Impact
Confidentiality Impact: LowIntegrity Impact: LowAvailability Impact: High
+ Technical Context
Architectural Paradigms
+ References
[R.3.1] [REF-2] G. Hoglund and G. McGraw. "Exploiting Software: How to Break Code". Addison-Wesley. February 2004.
+ Content History
CAPEC Content TeamThe MITRE Corporation2014-06-23Internal_CAPEC_Team
CAPEC Content TeamThe MITRE Corporation2015-11-09Updated Attack_PhasesInternal
CAPEC Content TeamThe MITRE Corporation2015-12-07Updated Attack_PhasesInternal
CAPEC Content TeamThe MITRE Corporation2017-01-09Updated Attack_PhasesInternal
CAPEC Content TeamThe MITRE Corporation2017-05-01Updated Attack_PhasesInternal
CAPEC Content TeamThe MITRE Corporation2017-08-04Updated Attack_Phases, Description Summary, PayloadInternal

More information is available — Please select a different filter.
Page Last Updated or Reviewed: August 04, 2017