CAPECattack pattern
CAPEC-78 Using Escaped Slashes in Alternate Encoding
High
Official page ↗
- Abstraction
- Detailed
- Status
- Draft
- Likelihood of attack
- High
- Typical severity
- High
- CAPEC version
- 3.9
Description
This attack targets the use of the backslash in alternate encoding. An adversary can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the adversary tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.
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 attempts to escape multiple different special characters using a backslash.
3. [Exploit] [Manipulate input] Once the adversary determines how to bypass filters that filter out special characters using an escaped slash, they will manipulate the user input in a way that is not intended by the application.
Prerequisites
• The application accepts the backlash character as escape character.
• The application server does incomplete input data decoding, filtering and validation.
Skills required
• [Low] The adversary can naively try backslash character and discover that the target host uses it as escape character.
• [Medium] The adversary may need deep understanding of the host target in order to exploit the vulnerability. The adversary may also use automated tools to probe for this vulnerability.
Consequences
• Confidentiality: Read Data
• Availability: Resource Consumption
• Confidentiality, Integrity, Availability: Execute Unauthorized Commands
• Confidentiality, Access Control, Authorization: Bypass Protection Mechanism
Mitigations
• Verify that the user-supplied data does not use backslash character to escape malicious characters.
• Assume all input is malicious. Create an allowlist that defines all valid input to the software system based on the requirements specifications. Input that does not match against the allowlist should not be permitted to enter into the system.
• Be aware of the threat of alternative method of data encoding.
• Regular expressions can be used to filter out backslash. Make sure you decode before filtering and validating the untrusted input data.
• In the case of path traversals, use the principle of least privilege when determining access rights to file systems. Do not allow users to access directories/files that they should not access.
• Any security checks should occur after the data has been decoded and validated as correct data format. Do not repeat decoding process, if bad character are left after decoding process, treat the data as suspicious, and fail the validation process.
• Avoid making decisions based on names of resources (e.g. files) if those resources can have alternate names.
Related
Child of · CAPEC (1)
- CAPEC-267 Leverage Alternate Encoding attack pattern
Weakness · CWE (10)
- CWE-172 Improper Encoding or Decoding of Data weakness
- CWE-173 Improper Handling of Alternate Encoding weakness
- CWE-180 Incorrect Behavior Order: Validate Before Canonicalize weakness
- CWE-181 Incorrect Behavior Order: Validate Before Filter weakness
- CWE-20 Improper Input Validation weakness
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory weakness
- CWE-697 Incorrect Comparison weakness
- CWE-707 Improper Neutralization weakness
- CWE-73 External Control of File Name or Path weakness
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness
Referenced by CWE · attack pattern (10)
- CWE-172 Improper Encoding or Decoding of Data weakness
- CWE-173 Improper Handling of Alternate Encoding weakness
- CWE-180 Incorrect Behavior Order: Validate Before Canonicalize weakness
- CWE-181 Incorrect Behavior Order: Validate Before Filter weakness
- CWE-20 Improper Input Validation weakness
- CWE-22 Improper Limitation of a Pathname to a Restricted Directory weakness
- CWE-697 Incorrect Comparison weakness
- CWE-707 Improper Neutralization weakness
- CWE-73 External Control of File Name or Path weakness
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness