Using Slashes in Alternate Encoding |
Attack Pattern ID: 79 (Detailed Attack Pattern Completeness: Complete) | Typical Severity: High | Status: Draft |
Summary
This attack targets the encoding of the Slash characters. An attacker would try to exploit common filtering problems related to the use of the slashes characters to gain access to resources on the target host. Directory-driven systems, such as file systems and databases, typically use the slash character to indicate traversal between directories or other container components. For murky historical reasons, PCs (and, as a result, Microsoft OSs) choose to use a backslash, whereas the UNIX world typically makes use of the forward slash. The schizophrenic result is that many MS-based systems are required to understand both forms of the slash. This gives the attacker many opportunities to discover and abuse a number of common filtering problems. The goal of this pattern is to discover server software that only applies filters to one version, but not the other.
Attack Execution Flow
The attacker has access to a resource path and required to use slashes as resource delimiter.
The attacker tries variation and combination of the slashes characters in different encoding format.
The attacker found an unfiltered combination which maps to a valid path and accesses unauthorized resources (directories, files, etc.)
The application server accepts paths to locate resources.
The application server does insufficient input data validation on the resource path requested by the user.
The access right to resources are not set properly.
Description
The two following requests are equivalent on most Web servers:
is equivalent to
Multiple encoding conversion problems can also be leveraged as various slashes are instantiated in URL-encoded, UTF-8, or unicode. Consider the strings
where %5C is equivalent to the \ character.
Skill or Knowledge Level: Low
An attacker can try variation of the slashes characters.
Skill or Knowledge Level: Medium
An attacker can use more sophisticated tool or script to scan a website and find a path filtering problem.
An attacker can try different encoding formats for the slashes characters and see if they produce the same filtering results.
Automated tools such as fuzzer can be used to test the URL decoding and filtering. Custom scripts can also be used. For example, a good script for verifying the correct interpretation of UTF-8 encoded characters can be found at http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
If the first path decoding process has left some invalid or blacklisted characters, that may be a sign that the request is malicious.
Traffic filtering with IDS (or proxy) can detect request with suspicious URLs. IDS may use signature based identification to reveal such URL based attacks.
A attacker can use a fuzzer in order to probe for a UTF-8 encoding vulnerability. The fuzzer should generate suspiscious network activity.
Typically the obfuscation here is the use of different alternate encoding format (UTF-8, Unicode, etc,)
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. Refer to the RFCs to safelly decode URL.
When client input is required from web-based forms, avoid using the "GET" method to submit data, as the method causes the form data to be appended to the URL and is easily manipulated. Instead, use the "POST method whenever possible.
There are tools to scan HTTP requests to the server for valid URL such as URLScan from Microsoft (http://www.microsoft.com/technet/security/tools/urlscan.mspx)
Be aware of the threat of alternative method of data encoding and obfuscation technique such as IP address endoding. (See related guideline section)
Test your path decoding process against malicious input.
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.
Assume all input is malicious. Create a white list that defines all valid input to the application based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system.
The injection vector is a string path with malicious slashes characters. Alternate encoding format can also be used to code the slashes characters.
CWE-ID | Weakness Name | Weakness Relationship Type |
---|---|---|
173 | Failure to Handle Alternate Encoding | Targeted |
171 | Cleansing, Canonicalization, and Comparison Errors | Targeted |
180 | Incorrect Behavior Order: Validate Before Canonicalize | Targeted |
181 | Incorrect Behavior Order: Validate Before Filter | Targeted |
20 | Improper Input Validation | Targeted |
74 | Failure to Sanitize Data into a Different Plane ('Injection') | Targeted |
73 | External Control of File Name or Path | Targeted |
21 | Pathname Traversal and Equivalence Errors | Targeted |
22 | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | Targeted |
185 | Incorrect Regular Expression | Secondary |
200 | Information Exposure | Secondary |
697 | Insufficient Comparison | Targeted |
707 | Improper Enforcement of Message or Data Structure | Targeted |
Nature | Type | ID | Name | Description | View(s) this relationship pertains to![]() |
---|---|---|---|---|---|
PeerOf | ![]() | 43 | Exploiting Multiple Input Interpretation Layers | Mechanism of Attack1000 | |
PeerOf | ![]() | 71 | Using Unicode Encoding to Bypass Validation Logic | Mechanism of Attack1000 | |
ChildOf | ![]() | 126 | Path Traversal | Mechanism of Attack (primary)1000 | |
ChildOf | ![]() | 267 | Leverage Alternate Encoding | Mechanism of Attack (primary)1000 | |
PeerOf | ![]() | 64 | Using Slashes and URL Encoding Combined to Bypass Validation Logic | Mechanism of Attack1000 | |
ParentOf | ![]() | 64 | Using Slashes and URL Encoding Combined to Bypass Validation Logic | Mechanism of Attack1000 | |
PeerOf | ![]() | 72 | URL Encoding | Mechanism of Attack1000 | |
ParentOf | ![]() | 78 | Using Escaped Slashes in Alternate Encoding | Mechanism of Attack1000 |
UTF-8 and Unicode FAQ for Unix/Linux, by Markus Kuhn - http://www.cl.cam.ac.uk/~mgk25/unicode.html
URL encoded attacks, by Gunter Ollmann - http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html
Submissions | ||||
---|---|---|---|---|
Submitter | Organization | Date | ||
G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004. | Cigital, Inc | 2007-03-01 |
Modifications | |||||
---|---|---|---|---|---|
Modifier | Organization | Date | Comments | ||
Eric Dalci | Cigital, Inc | 2007-02-13 | Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software" | ||
Sean Barnum | Cigital, Inc | 2007-03-07 | Review and revise | ||
Richard Struse | VOXEM, Inc | 2007-03-26 | Review and feedback leading to changes in Related Attack Patterns | ||
Sean Barnum | Cigital, Inc | 2007-04-16 | Modified pattern content according to review and feedback |