CAPEC-3: Using Leading 'Ghost' Character Sequences to Bypass Input Filters
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.
- Likelihood of attack
- Medium
- Typical severity
- Medium
- Abstraction
- DetailedA low-level, detailed pattern, often for a particular technology.
Mechanism of attack: Manipulate Data Structures
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
- MediumThe 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
- ConfidentialityAccess ControlAuthorization
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 weaknesses (CWE)
- CWE-20Improper Input Validation
- CWE-41Improper Resolution of Path Equivalence
- CWE-74Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
- CWE-172Encoding Error
- CWE-173Improper Handling of Alternate Encoding
- CWE-179Incorrect Behavior Order: Early Validation
- CWE-180Incorrect Behavior Order: Validate Before Canonicalize
- CWE-181Incorrect Behavior Order: Validate Before Filter
- CWE-183Permissive List of Allowed Inputs
- CWE-184Incomplete List of Disallowed Inputs
- CWE-697Incorrect Comparison
- CWE-707Improper Neutralization