Using Escaped Slashes in Alternate Encoding
Attack Pattern ID: 78 (Detailed Attack Pattern Completeness: Complete)Typical Severity: HighStatus: Draft
+ Description


This attack targets the use of the backslash in alternate encoding. An attacker 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 attacker tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.

Attack Execution Flow

  1. The attacker can send input data to the host target (e.g., via http request or command line request

  2. The attacker craft malicious input data which includes escaped slashes. The attacker may need multiple attempts before finding a successful combination.

+ Attack Prerequisites

The application accepts the backlash character as escape character.

The application server does incomplete input data decoding, filtering and validation.

+ Typical Likelihood of Exploit

Likelihood: High

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


For example, the byte pair \0 might result in a single zero byte (a NULL) being sent. Another example is \t, which is sometimes converted into a tab character. There is often an equivalent encoding between the back slash and the escaped back slash. This means that \/ results in a single forward slash. A single forward slash also results in a single forward slash. The encoding looks like this:

/ yields /
\/ yields /


An attack leveraging this pattern is very simple. If you believe the target may be filtering the slash, attempt to supply \/ and see what happens. Example command strings to try out include

CWD ..\/..\/..\/..\/winnt

which converts in many cases to

CWD ../../../../winnt

To probe for this kind of problem, a small C program that uses string output routines can be very useful. File system calls make excellent testing fodder. The simple snippet

int main(int argc, char* argv[])
puts("\/ \\ \? \. \| ");
return 0;

produces the output

/ \ ? . |

Clearly, the back slash is ignored, and thus we have hit on a number of alternative encodings to experiment with. Given our previous example, we can extend the attack to include other possibilities:

CWD ..\?\?\?\?\/..\/..\/..\/winnt
CWD \.\.\/\.\.\/\.\.\/\.\.\/winnt
CWD ..\|\|\|\|\/..\/..\/..\/winnt
+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Low

The attacker can naively try backslash character and discover that the target host uses it as escape character.

Skill or Knowledge Level: Medium

The attacker may need deep understanding of the host target in order to exploit the vulnerability. The attacker may also use automated tools to probe for this vulnerability.

+ Probing Techniques

An attacker can manually inject backslash characters in the data sent to the target host and observe the results of the request.

The attacker may also run scripts or automated tools against the target host to uncover a vulnerability related to the use of the backslash character.

+ Indicators-Warnings of Attack

A attacker can use a fuzzer in order to probe for this vulnerability. The fuzzer should generate suspicious network activity noticeable by an intrusion detection system.

+ Obfuscation Techniques

Alternative method of data encoding can be used.

+ Solutions and Mitigations

Verify that the user-supplied data does not use backslash character to escape malicious characters.

Assume all input is malicious. Create a white list that defines all valid input to the software system based on the requirements specifications. Input that does not match against the white list 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.

+ Attack Motivation-Consequences
  • Information Leakage
  • Denial of Service
  • Run Arbitrary Code
  • Information Leakage
  • Privilege Escalation
+ Injection Vector

The user supplied data (e.g., HTTP request)

+ Payload

The backslash character injected in the user supplied data. The backslash character can be obfuscated with alternate encoding.

+ Activation Zone

The command or request interpreter used on the host target may consider the backslash character as escape character.

+ Payload Activation Impact

The character following the backslash character will be escaped (i.e, unfiltered) and may cause harmful effects.

+ Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
180Incorrect Behavior Order: Validate Before CanonicalizeTargeted
181Incorrect Behavior Order: Validate Before FilterTargeted
173Failure to Handle Alternate EncodingTargeted
171Cleansing, Canonicalization, and Comparison ErrorsTargeted
172Encoding ErrorTargeted
73External Control of File Name or PathTargeted
21Pathname Traversal and Equivalence ErrorsTargeted
22Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')Targeted
74Failure to Sanitize Data into a Different Plane ('Injection')Targeted
20Improper Input ValidationTargeted
697Insufficient ComparisonTargeted
707Improper Enforcement of Message or Data StructureTargeted
+ Related Attack Patterns
NatureTypeIDNameDescriptionView(s) this relationship pertains toView\(s\)
PeerOfAttack PatternAttack Pattern43Exploiting Multiple Input Interpretation Layers 
Mechanism of Attack1000
PeerOfAttack PatternAttack Pattern64Using Slashes and URL Encoding Combined to Bypass Validation Logic 
Mechanism of Attack1000
PeerOfAttack PatternAttack Pattern71Using Unicode Encoding to Bypass Validation Logic 
Mechanism of Attack1000
ChildOfAttack PatternAttack Pattern79Using Slashes in Alternate Encoding 
Mechanism of Attack1000
ChildOfCategoryCategory126Path Traversal 
Mechanism of Attack (primary)1000
ChildOfAttack PatternAttack Pattern267Leverage Alternate Encoding 
Mechanism of Attack (primary)1000
+ Relevant Security Requirements

All client-supplied input must be validated through filtering and all output must be properly escaped.

+ Related Security Principles
  • Reluctance to Trust

+ Related Guidelines
  • Never trust user-supplied input.

+ Purposes
  • Penetration
  • Exploitation
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: HighAvailability Impact: Medium
+ Technical Context
Architectural Paradigms
+ References
G. Hoglund and G. McGraw. "Exploiting Software: How to Break Code". Addison-Wesley. February 2004.

CWE - Input Validation

+ Content History
G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004.Cigital, Inc2007-03-01
Eric DalciCigital, Inc2007-02-13Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software"
Sean BarnumCigital, Inc2007-03-07Review and revise
Richard StruseVOXEM, Inc2007-03-26Review and feedback leading to changes in Related Attack Patterns
Sean BarnumCigital, Inc2007-04-16Modified pattern content according to review and feedback