CAPEC-64: Using Slashes and URL Encoding Combined to Bypass Validation Logic

Detailed Draft 严重程度: High 攻击可能性: High

CAPEC版本: 3.9

更新日期: 2023-01-24

攻击模式描述

This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple ways of encoding a URL and abuse the interpretation of the URL. A URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc.

执行流程

步骤 1 Explore

The attacker accesses the server using a specific URL.

步骤 2 Experiment

The attacker tries to encode some special characters in the URL. The attacker find out that some characters are not filtered properly.

步骤 3 Exploit

The attacker crafts a malicious URL string request and sends it to the server.

步骤 4 Exploit

The server decodes and interprets the URL string. Unfortunately since the input filtering is not done properly, the special characters have harmful consequences.

前提条件

  • The application accepts and decodes URL string request.
  • The application performs insufficient filtering/canonicalization on the URLs.

所需技能

Low An attacker can try special characters in the URL and bypass the URL validation.
Medium The attacker may write a script to defeat the input filtering mechanism.

后果影响

影响范围: Availability

技术影响: Resource Consumption

说明: Denial of Service

影响范围: Confidentiality Integrity Availability

技术影响: Execute Unauthorized Commands

说明: Run Arbitrary Code

影响范围: Confidentiality

技术影响: Read Data

影响范围: Confidentiality Access Control Authorization

技术影响: Gain Privileges

缓解措施

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. Test your decoding process against malicious input.

Be aware of the threat of alternative method of data encoding and obfuscation technique such as IP address encoding.

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.

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.

Regular expression can be used to match safe URL patterns. However, that may discard valid URL requests if the regular expression is too restrictive.

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

示例实例

See also: CVE-2001-1335

关键信息

CAPEC ID: CAPEC-64

抽象级别: Detailed

状态: Draft

典型严重程度: High

攻击可能性: High

相关攻击模式