CAPEC

Common Attack Pattern Enumeration and Classification
Common Attack Pattern Enumeration and Classification

A Community Knowledge Resource for Building Secure Software

Home > CAPEC List > Individual CAPEC Dictionary Definition (Release 1.1)   View the CAPEC List

Individual CAPEC Dictionary Definition (Release 1.1)
Individual CAPEC Dictionary Definition (Release 1.1)

Embedding Scripts in HTTP Query Strings
Attack Pattern ID
Pattern Abstraction: Detailed

32

Typical Severity

High

Description

Summary

A variant of cross-site scripting called "reflected" cross-site scripting, the HTTP Query Strings attack consists of passing a malicious script inside an otherwise valid HTTP request query string. This is of significant concern for sites that rely on dynamic, user-generated content such as bulletin boards, news sites, blogs, and web enabled administration GUIs. The malicious script may steal session data, browse history, probe files, or otherwise execute attacks on the client side. Once the attacker has prepared the malicious HTTP query it is sent to a victim user (perhaps by email, IM, or posted on an online forum), who clicks on a normal looking link that contains a poison query string. This technique can be made more effective through the use of services like http://tinyurl.com/, which makes very small URLs that will redirect to very large, complex ones. The victim will not know what he is really clicking on.

Attack Execution Flow

Explore
  1. Spider: Using an automated tool, an attacker follows all public links on a web site. He records all the links he finds.

    Attack Step Techniques
    DescriptionEnvironments
    Use a spidering tool to follow and record all links. Make special note of any links that include parameters in the URL.env-Web
    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
    Indicators of Susceptibility
    IDTypeDescriptionEnvironments
    c32s1i1PositiveURL parameters are used.env-Web
    c32s1i2InconclusiveNo parameters appear on the URL. Even though none appear, the web application may still use them if they are provided.env-Web
    c32s1i3NegativeApplications that have only static pages or that simply present information without accepting input are unlikely to be susceptible.env-Web
    Outcome
    IDTypeDescription
    c32s1o1SuccessA list of URLs, with their corresponding parameters is created by the attacker.
    Security Controls
    IDTypeDescription
    c32s1s1DetectiveMonitor velocity of page fetching in web logs. Humans who view a page and select a link from it will click far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them).
    c32s1s2DetectiveCreate links on some pages that are visually hidden from web browsers. Using IFRAMES, images, or other HTML techniques, the links can be hidden from web browsing humans, but visible to spiders and programs. A request for the page, then, becomes a good predictor of an automated tool probing the application.
    c32s1s3PreventativeActively monitor the application and either deny or redirect requests from origins that appear to be automated.
Experiment
  1. Attempt variations on input parameters: Possibly using an automated tool, an attacker requests variations on the URLs he spidered before. He sends parameters that include variations of script. He records all the responses from the server that include unmodified versions of his script..

    Attack Step Techniques
    DescriptionEnvironments
    Use a list of XSS probe strings to inject in parameters of known URLsenv-Web
    Use a proxy tool to record results of manual input of XSS probes in known URLs.env-Web
    Indicators of Susceptibility
    IDTypeDescriptionEnvironments
    c32s2i1PositiveThe output of pages includes some form of a URL parameter. E.g., ?error="File not Found" becomes "File not Found" in the title of the web page.env-Web
    c32s2i2PositiveInput parameters become part of JavaScript, VBScript, or other script in a web page.env-Web
    Outcomes
    IDTypeDescription
    c32s3o1SuccessThe attacker's cross-site scripting string is repeated back verbatim.
    c32s3o2FailureAll HTML-sensitive characters are consistently reencoded before being sent to the web browser.
    c32s3o3InconclusiveSome sensitive characters are consistently encoded, but others are not.
    Security Controls
    IDTypeDescription
    c32s3s1DetectiveMonitor 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 hackers use.
    c32s3s2PreventativeActively monitor the application and either deny or redirect requests from origins that appear to be generating XSS probes.
Exploit
  1. Steal session IDs or other credentials: After determining that a parameter is vulnerable, the attacker creates exploit URLs and tries to get victims to click on them. The attack vector can be through email, web pages (guest books, forums) or through application specific mechanisms (e.g., application workflow pages or elements)

    Attack Step Techniques
    DescriptionEnvironments
    Develop malicious javascript that is loaded by the victim's browser and sends document information to the attacker.env-Web
    Develop malicious javascript that takes commands from an attacker's server and then causes the browser to execute appropriately.env-Web
    Outcomes
    IDTypeDescription
    c32s4o1SuccessThe attacker gets the user's cookies or other session identifiers.
    c32s4o2SuccessThe attacker gets the content of the page the user is viewing.
    c32s4o3SuccessThe attacker causes the user's browser to visit a page with malicious content.
    Security Controls
    IDTypeDescription
    c32s4s1DetectiveMonitor server logs for scripting parameters.
    c32s4s2DetectiveMonitor 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 Referer headers most of the time. These can help indicate that the actual request is illegitimate.
Attack Prerequisites

Target client software must allow scripting such as Javascript. Server software must allow display of remote generated HTML without sufficient input or output validation.

Typical Likelihood of Exploit

High

Methods of Attack
  • Injection
  • Protocol Manipulation
Examples-Instances

Description


http://user:host@example.com:8080/oradb<script>alert('Hi')</script>

Description


Web applications that accept name value pairs in a HTTP Query string are inherently at risk to any value (or name for that matter) that an attacker would like to enter in the query string. This can be done manually via web browser or trivially scripted to post the query string to multiple sites. In the latter case, in the instance of many sites using similar infrastructure with predictable http queries being accepted and operated on (such as blogging software, Google applications, and so on), a single malicious payload can be scritped to target a wide variety of sites.
Web 2.0 type sites like Technorati and del.icio.us rely on user generated content like tags to build http links that are displayed to other users. del.icio.us allows users to identify sites, tag them with metadata and provide URL, descriptions and more data. This data is then echoed back to any other web browser that is interested in the link. If the data is not validated by the del.icio.us site properly then an abritrary code can be added into the standard http string sent to del.icio.us by the attacker, for example formatted as normal content with a URL and description and tagged as Java, and available to be clicked on (and executed by) any user browsing for Java content that clicks on this trojaned content.

Attacker Skill or Knowledge Required

Low → To place malicious payload on server via HTTP High → Exploiting any information gathered by HTTP Query on script host

Resources Required

Ability to send HTTP post to scripting host and collect output

Solutions and Mitigations

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

Design: Utilize strict type, character, and encoding enforcement

Design: Server side developers should not proxy content via XHR or other means, if a http proxy for remote content is setup on the server side, the client's browser has no way of discerning where the data is originating from.

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

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: Session tokens for specific host

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.

Implementation: Privileges are constrained, if a script is loaded, ensure system runs in chroot jail or other limited authority mode

Attack Motivation-Consequences
  • Information Leakage
  • Run Arbitrary Code
Context Description


“Attack Pattern: HTTP Query Strings
A query string takes variable = value pairs. These are passed to the target executable or script designated in the request. A variable can be injected with script. The script is processed and stored in a way that is later visible to a user."
[Hoglund and McGraw 04]

Injection Vector

Script delivered through standard web server, such as a web server with user-generated content.

Payload

HTTP Request Query String

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.

Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
79Failure to Sanitize Directives in a Web Page (aka 'Cross-site scripting' (XSS))Targeted
84Failure to Resolve Encoded URI Schemes in a Web PageTargeted
85Doubled Character XSS ManipulationsTargeted
20Insufficient Input ValidationTargeted
86Invalid Characters in IdentifiersTargeted
Purpose

Exploitation

CIA Impact
Confidentiality ImpactIntegrity ImpactAvailability Impact
HighHighLow
Technical Context
Architectural ParadigmFrameworkPlatformLanguage
Client-ServerAllAllAll
References

G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004.

Source
Submission(s)
SubmitterOrganizationDateComment
G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004.Cigital, Inc2007-01-01
Modification(s)
ModifierOrganizationDateComment
Gunnar PetersonCigital, Inc2007-02-28Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software"
Sean BarnumCigital, Inc2007-03-09Review and revise
Richard StruseVOXEM, Inc2007-03-26Review and feedback leading to changes in Name and Examples
Sean BarnumCigital, Inc2007-04-13Modified pattern content according to review and feedback
 
Page Last Updated: April 18, 2008