CAPECattack pattern

CAPEC-79 Using 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 encoding of the Slash characters. An adversary 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 adversary 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.

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 looks for areas where user input is used to access resources on the target host. The adversary attempts different encodings of slash characters to bypass input filters. 3. [Exploit] [Traverse application directories] Once the adversary determines how to bypass filters that filter out slash characters, they will manipulate the user input to include slashes in order to traverse directories and access resources that are not intended for the user.

Prerequisites

• 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.

Skills required

• [Low] An adversary can try variation of the slashes characters. • [Medium] An adversary can use more sophisticated tool or script to scan a website and find a path filtering problem.

Consequences

• Confidentiality: Read Data • Confidentiality, Integrity, Availability: Execute Unauthorized Commands • Confidentiality, Access Control, Authorization: Gain Privileges

Mitigations

• 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 safely 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 encoding. (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 an allowlist that defines all valid input to the application based on the requirements specifications. Input that does not match against the allowlist should not be permitted to enter into the system.

Related

Child of · CAPEC (1)

  • CAPEC-267 Leverage Alternate Encoding attack pattern

Weakness · CWE (11)

  • 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-185 Incorrect Regular Expression weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-200 Exposure of Sensitive Information to an Unauthorized Actor 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 (11)

  • 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-185 Incorrect Regular Expression weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-200 Exposure of Sensitive Information to an Unauthorized Actor 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