CAPEC-120: Double Encoding

Double Encoding

状态:Draft

Typical_Severify: Medium

攻击可能性:Low

描述

The adversary utilizes a repeating of the encoding process for a set of characters (that is, character encoding a character encoding of a character) to obfuscate the payload of a particular request. This may allow the adversary to bypass filters that attempt to detect illegal characters or strings, such as those that might be used in traversal or injection attacks. Filters may be able to catch illegal encoded strings, but may not catch doubly encoded strings. For example, a dot (.), often used in path traversal attacks and therefore often blocked by filters, could be URL encoded as %2E. However, many filters recognize this encoding and would still block the request. In a double encoding, the % in the above URL encoding would be encoded again as %25, resulting in %252E which some filters might not catch, but which could still be interpreted as a dot (.) by interpreters on the target.

相关攻击模式

ChildOf: CAPEC-267 |Leverage Alternate Encoding

Execution Flow Attack Setp

Setp 1 Explore

[Survey the application for user-controllable inputs] Using a browser, an automated tool or by inspecting the application, an attacker records all entry points to the application.

Setp 2 Experiment

[Probe entry points to locate vulnerabilities] Try double-encoding for parts of the input in order to try to get past the filters. For instance, by double encoding certain characters in the URL (e.g. dots and slashes) an adversary may try to get access to restricted resources on the web server or force browse to protected pages (thus subverting the authorization service). An adversary can also attempt other injection style attacks using this attack pattern: command injection, SQL injection, etc.

前置条件

The target's filters must fail to detect that a character has been doubly encoded but its interpreting engine must still be able to convert a doubly encoded character to an un-encoded character.

The application accepts and decodes URL string request.

The application performs insufficient filtering/canonicalization on the URLs.

所需资源

Tools that automate encoding of data can assist the adversary in generating encoded strings.

缓解措施

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

实例

Double Enconding Attacks can often be used to bypass Cross Site Scripting (XSS) detection and execute XSS attacks.:

%253Cscript%253Ealert('This is an XSS Attack')%253C%252Fscript%253E

Since <, <, and / are often sued to perform web attacks, these may be captured by XSS filters. The use of double encouding prevents the filter from working as intended and allows the XSS to bypass dectection. This can allow an adversary to execute malicious code.

相关CWE

173 | 候选编码方案处理不恰当

172 | 编码错误

177 | URL编码处理不恰当(Hex编码)

181 | 不正确的行为次序:在过滤之前验证

171 | 净化、规范化和比较错误

183 | 宽松定义的白名单

184 | 不完整的黑名单

21 | 路径遍历与路径等价的安全错误

74 | 输出中的特殊元素转义处理不恰当(注入)

20 | 输入验证不恰当

697 | 不充分的比较

692 | 黑名单不完全导致跨站脚本

内容历史记录

提交

2014-06-23 | CAPEC Content Team | The MITRE Corporation

修改

2017-08-04 | CAPEC Content Team | The MITRE Corporation

Updated Attack_Phases, Description Summary, Resources_Required

2018-07-31 | CAPEC Content Team | The MITRE Corporation

Updated Activation_Zone, Attack_Phases, Attack_Prerequisites, Description Summary, Examples-Instances, Injection_Vector, Payload, Payload_Activation_Impact, Related_Weaknesses, Solutions_and_Mitigations, Typical_Likelihood_of_Exploit