Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CAPEC-72:URL Encoding
Attack Pattern ID:72
Version:v3.9
Attack Pattern Name:URL Encoding
Abstraction:Detailed
Status:Draft
Likelihood of Attack:High
Typical Severity:High
DetailsContent HistoryRelated WeaknessesReports
▼Description
This attack targets the encoding of the URL. An adversary can take advantage of the multiple way of encoding an URL and abuse the interpretation of the URL.
▼Extended Description

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 adversary 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. The adversary could also subvert the meaning of the URL string request by encoding the data being sent to the server through a GET request. For instance an adversary may subvert the meaning of parameters used in a SQL request and sent through the URL string (See Example section).

▼Alternate Terms
▼Relationships
NatureTypeIDName
ChildOfS267Leverage Alternate Encoding
Nature: ChildOf
Type: Standard
ID: 267
Name: Leverage Alternate Encoding
▼Execution Flow
Explore
1.

Survey web application for URLs with parameters

Using a browser, an automated tool or by inspecting the application, an adversary records all URLs that contain parameters.

Technique
Use a spidering tool to follow and record all links and analyze the web pages to find entry points. Make special note of any links that include parameters in the URL.
Experiment
1.

Probe URLs to locate vulnerabilities

The adversary uses the URLs gathered in the "Explore" phase as a target list and tests parameters with different encodings of special characters to see how the web application will handle them.

Technique
Use URL encodings of special characters such as semi-colons, backslashes, or question marks that might be filtered out normally.
Combine the use of URL encodings with other encoding techniques such as the triple dot and escape slashes.
Exploit
1.

Inject special characters into URL parameters

Using the information gathered in the "Experiment" phase, the adversary injects special characters into the URL using URL encoding. This can lead to path traversal, cross-site scripting, SQL injection, etc.

Technique
▼Prerequisites
The application should accepts and decodes URL input.
The application performs insufficient filtering/canonicalization on the URLs.
▼Skills Required
Low

An adversary can try special characters in the URL and bypass the URL validation.


Medium

The adversary may write a script to defeat the input filtering mechanism.

▼Resources Required
▼Indicators
If the first decoding process has left some invalid or denylisted characters, that may be a sign that the request is malicious.
Traffic filtering with IDS (or proxy) can detect requests with suspicious URLs. IDS may use signature based identification to reveal such URL based attacks.
▼Consequences
ScopeLikelihoodImpactNote
ConfidentialityN/ARead DataN/A
AvailabilityN/AResource ConsumptionDenial of Service
ConfidentialityIntegrityAvailabilityN/AExecute Unauthorized CommandsRun Arbitrary Code
ConfidentialityAccess ControlAuthorizationN/AGain PrivilegesN/A
Scope: Confidentiality
Likelihood: N/A
Impact: Read Data
Note: N/A
Scope: Availability
Likelihood: N/A
Impact: Resource Consumption
Note: Denial of Service
Scope: Confidentiality, Integrity, Availability
Likelihood: N/A
Impact: Execute Unauthorized Commands
Note: Run Arbitrary Code
Scope: Confidentiality, Access Control, Authorization
Likelihood: N/A
Impact: Gain Privileges
Note: N/A
▼Mitigations
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).
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.
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. (See related guideline section)
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.
▼Example Instances
▼Related Weaknesses
IDName
CWE-177Improper Handling of URL Encoding (Hex Encoding)
CWE-172Encoding Error
CWE-173Improper Handling of Alternate Encoding
CWE-20Improper Input Validation
CWE-73External Control of File Name or Path
CWE-74Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
ID: CWE-177
Name: Improper Handling of URL Encoding (Hex Encoding)
ID: CWE-172
Name: Encoding Error
ID: CWE-173
Name: Improper Handling of Alternate Encoding
ID: CWE-20
Name: Improper Input Validation
ID: CWE-73
Name: External Control of File Name or Path
ID: CWE-74
Name: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
▼Taxonomy Mappings
Taxonomy NameEntry IDEntry Name
▼Notes
▼References
Reference ID: REF-1
Title: Exploiting Software: How to Break Code
Author: G. Hoglund, G. McGraw
Publication:
Publisher:Addison-Wesley
Edition:
URL:
URL Date:
Day:N/A
Month:02
Year:2004
Reference ID: REF-495
Title: URL Encoded Attacks - Attacks using the common web browser
Author: Gunter Ollmann
Publication:
Publisher:CGISecurity.com
Edition:
URL:http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html
URL Date:
Day:N/A
Month:N/A
Year:N/A
Reference ID: REF-496
Title: RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax
Author: T. Berners-Lee, R. Fielding, L. Masinter
Publication:
Publisher:
Edition:
URL:http://www.ietf.org/rfc/rfc3986.txt
URL Date:
Day:N/A
Month:01
Year:2005
Reference ID: REF-497
Title: RFC 1738 - Uniform Resource Locators (URL)
Author: T. Berners-Lee, L. Masinter, M. McCahill
Publication:
Publisher:
Edition:
URL:http://www.ietf.org/rfc/rfc1738.txt
URL Date:
Day:N/A
Month:12
Year:1994
Reference ID: REF-498
Title: HTML URL Encoding Reference
Author:
Publication:
W3Schools.com
Publisher:Refsnes Data
Edition:
URL:http://www.w3schools.com/tags/ref_urlencode.asp
URL Date:
Day:N/A
Month:N/A
Year:N/A
Reference ID: REF-499
Title: The URLEncode and URLDecode Page
Author:
Publication:
Publisher:Albion Research Ltd
Edition:
URL:http://www.albionresearch.com/misc/urlencode.php
URL Date:
Day:N/A
Month:N/A
Year:N/A
Reference ID: REF-500
Title: Secure Programming for Linux and Unix HOWTO
Author: David Wheeler
Publication:
Publisher:
Edition:
URL:http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/filter-html.html#VALIDATING-URIS
URL Date:
Day:N/A
Month:N/A
Year:N/A
Details not found