Reflected cross-site scripting vulnerabilities arise when data is copied from a request and echoed into the application's immediate response in an unsafe way. An attacker can use the vulnerability to construct a request which, if issued by another application user, will cause JavaScript code supplied by the attacker to execute within the user's browser in the context of that user's session with the application.
The attacker-supplied code can perform a wide variety of actions, such as stealing the victim's session token or login credentials, performing arbitrary actions on the victim's behalf, and logging their keystrokes.
Users can be induced to issue the attacker's crafted request in various ways. For example, the attacker can send a victim a link containing a malicious URL in an email or instant message. They can submit the link to popular web sites that allow content authoring, for example in blog comments. And they can create an innocuous looking web site which causes anyone viewing it to make arbitrary cross-domain requests to the vulnerable application (using either the GET or the POST method).
The security impact of cross-site scripting vulnerabilities is dependent upon the nature of the vulnerable application, the kinds of data and functionality which it contains, and the other applications which belong to the same domain and organisation. If the application is used only to display non-sensitive public content, with no authentication or access control functionality, then a cross-site scripting flaw may be considered low risk. However, if the same application resides on a domain which can access cookies for other more security-critical applications, then the vulnerability could be used to attack those other applications, and so may be considered high risk. Similarly, if the organisation which owns the application is a likely target for phishing attacks, then the vulnerability could be leveraged to lend credibility to such attacks, by injecting Trojan functionality into the vulnerable application, and exploiting users' trust in the organisation in order to capture credentials for other applications which it owns. In many kinds of application, such as those providing online banking functionality, cross-site scripting should always be considered high risk.
Issue remediation
In most situations where user-controllable data is copied into application responses, cross-site scripting attacks can be prevented using two layers of defences:
Input should be validated as strictly as possible on arrival, given the kind of content which it is expected to contain. For example, personal names should consist of alphabetical and a small range of typographical characters, and be relatively short; a year of birth should consist of exactly four numerals; email addresses should match a well-defined regular expression. Input which fails the validation should be rejected, not sanitised.
User input should be HTML-encoded at any point where it is copied into application responses. All HTML metacharacters, including < > " ' and =, should be replaced with the corresponding HTML entities (< > etc).
In cases where the application's functionality allows users to author content using a restricted subset of HTML tags and attributes (for example, blog comments which allow limited formatting and linking), it is necessary to parse the supplied HTML to validate that it does not use any dangerous syntax; this is a non-trivial task.
The value of the AppId request parameter is copied into the HTML document as plain text between tags. The payload e039c<img%20src%3da%20onerror%3dalert(1)>ad60e05015f was submitted in the AppId parameter. This input was echoed as e039c<img src=a onerror=alert(1)>ad60e05015f in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Market request parameter is copied into the HTML document as plain text between tags. The payload 26ef9<img%20src%3da%20onerror%3dalert(1)>697cfa2dbf6 was submitted in the Market parameter. This input was echoed as 26ef9<img src=a onerror=alert(1)>697cfa2dbf6 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Options request parameter is copied into the HTML document as plain text between tags. The payload ff3e0<img%20src%3da%20onerror%3dalert(1)>8d9e28e188e was submitted in the Options parameter. This input was echoed as ff3e0<img src=a onerror=alert(1)>8d9e28e188e in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Query request parameter is copied into the HTML document as plain text between tags. The payload a79e8<img%20src%3da%20onerror%3dalert(1)>effdaf9c300 was submitted in the Query parameter. This input was echoed as a79e8<img src=a onerror=alert(1)>effdaf9c300 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Sources request parameter is copied into the HTML document as plain text between tags. The payload 8fc65<img%20src%3da%20onerror%3dalert(1)>d5b8e5dde47 was submitted in the Sources parameter. This input was echoed as 8fc65<img src=a onerror=alert(1)>d5b8e5dde47 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Version request parameter is copied into the HTML document as plain text between tags. The payload 2748f<img%20src%3da%20onerror%3dalert(1)>468f2243636 was submitted in the Version parameter. This input was echoed as 2748f<img src=a onerror=alert(1)>468f2243636 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Web.Count request parameter is copied into the HTML document as plain text between tags. The payload 32dea<img%20src%3da%20onerror%3dalert(1)>566dac5d476 was submitted in the Web.Count parameter. This input was echoed as 32dea<img src=a onerror=alert(1)>566dac5d476 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Web.Offset request parameter is copied into the HTML document as plain text between tags. The payload a7063<img%20src%3da%20onerror%3dalert(1)>0f1536afb5e was submitted in the Web.Offset parameter. This input was echoed as a7063<img src=a onerror=alert(1)>0f1536afb5e in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the Web.Options request parameter is copied into the HTML document as plain text between tags. The payload 87bb1<img%20src%3da%20onerror%3dalert(1)>317fc63cd42 was submitted in the Web.Options parameter. This input was echoed as 87bb1<img src=a onerror=alert(1)>317fc63cd42 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The value of the q request parameter is copied into the HTML document as plain text between tags. The payload c2aee<img%20src%3da%20onerror%3dalert(1)>2af30653633 was submitted in the q parameter. This input was echoed as c2aee<img src=a onerror=alert(1)>2af30653633 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response. The PoC attack demonstrated uses an event handler to introduce arbitrary JavaScript into the document.
The application publishes a Flash cross-domain policy which uses a wildcard to specify allowed domains, and allows access from specific other domains.
Using a wildcard to specify allowed domains means that any domain matching the wildcard expression can perform two-way interaction with this application. You should only use this policy if you fully trust every possible web site that may reside on a domain which matches the wildcard expression.
Allowing access from specific domains means that web sites on those domains can perform two-way interaction with this application. You should only use this policy if you fully trust the specific domains allowed by the policy.
Issue background
The Flash cross-domain policy controls whether Flash client components running on other domains can perform two-way interaction with the domain which publishes the policy. If another domain is allowed by the policy, then that domain can potentially attack users of the application. If a user is logged in to the application, and visits a domain allowed by the policy, then any malicious content running on that domain can potentially gain full access to the application within the security context of the logged in user.
Even if an allowed domain is not overtly malicious in itself, security vulnerabilities within that domain could potentially be leveraged by a third-party attacker to exploit the trust relationship and attack the application which allows access.
Issue remediation
You should review the domains which are allowed by the Flash cross-domain policy and determine whether it is appropriate for the application to fully trust both the intentions and security posture of those domains.
Request
GET /crossdomain.xml HTTP/1.0 Host: api.bing.com
Response
HTTP/1.0 200 OK Cache-Control: no-cache Content-Length: 634 Content-Type: text/xml Last-Modified: Fri, 01 Oct 2010 21:58:33 GMT ETag: A06DD1053D1686DFCEF21D90E3BAD7190000027A P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND", policyref="http://privacy.msn.com/w3c/p3p.xml" Date: Sat, 27 Aug 2011 16:00:23 GMT Connection: close Set-Cookie: _MD=alg=m2&C=2011-08-27T16%3a00%3a22; expires=Tue, 06-Sep-2011 16:00:22 GMT; domain=.bing.com; path=/
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <allow-http-request-headers-from domain="*.bing.com" he ...[SNIP]... <allow-access-from domain="*.bing.com"/> ...[SNIP]... <allow-access-from domain="blstc.msn.com"/> ...[SNIP]... <allow-access-from domain="stc.sandblu.msn-int.com"/> ...[SNIP]...
The application publishes a Silverlight cross-domain policy which uses a wildcard to specify allowed domains.
Using a wildcard to specify allowed domains means that any domain matching the wildcard expression can perform two-way interaction with this application. You should only use this policy if you fully trust every possible web site that may reside on a domain which matches the wildcard expression.
Issue background
The Silverlight cross-domain policy controls whether Silverlight client components running on other domains can perform two-way interaction with the domain which publishes the policy. If another domain is allowed by the policy, then that domain can potentially attack users of the application. If a user is logged in to the application, and visits a domain allowed by the policy, then any malicious content running on that domain can potentially gain full access to the application within the security context of the logged in user.
Even if an allowed domain is not overtly malicious in itself, security vulnerabilities within that domain could potentially be leveraged by a third-party attacker to exploit the trust relationship and attack the application which allows access.
Issue remediation
You should review the domains which are allowed by the Silverlight cross-domain policy and determine whether it is appropriate for the application to fully trust both the intentions and security posture of those domains.
Request
GET /clientaccesspolicy.xml HTTP/1.0 Host: api.bing.com
Response
HTTP/1.0 200 OK Cache-Control: no-cache Content-Length: 348 Content-Type: text/xml Last-Modified: Tue, 09 Feb 2010 19:32:41 GMT ETag: 3B4046BBE5F127E45C1A35A93B86C3890000015C P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND", policyref="http://privacy.msn.com/w3c/p3p.xml" Date: Sat, 27 Aug 2011 16:00:23 GMT Connection: close
The file robots.txt is used to give instructions to web robots, such as search engine crawlers, about locations within the web site which robots are allowed, or not allowed, to crawl and index.
The presence of the robots.txt does not in itself present any kind of security vulnerability. However, it is often used to identify restricted or private areas of a site's contents. The information in the file may therefore help an attacker to map out the site's contents, especially if some of the locations identified are not linked from elsewhere in the site. If the application relies on robots.txt to protect access to these areas, and does not enforce proper access control over them, then this presents a serious vulnerability.
Issue remediation
The robots.txt file is not itself a security threat, and its correct use can represent good practice for non-security reasons. You should not assume that all web robots will honour the file's instructions. Rather, assume that attackers will pay close attention to any locations identified in the file. Do not rely on robots.txt to provide any kind of protection over unauthorised access.
Request
GET /robots.txt HTTP/1.0 Host: api.bing.com
Response
HTTP/1.0 200 OK Content-Length: 2268 Content-Type: text/plain Last-Modified: Wed, 20 Jul 2011 20:34:26 GMT X-Akamai-TestID: b8a09b6536cd4ed8a098dc16afc98616 Cache-Control: public, max-age=15552000 Date: Sat, 27 Aug 2011 16:00:23 GMT Connection: close