<?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=Krzysztof+Kotowicz</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=Krzysztof+Kotowicz"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Krzysztof_Kotowicz"/>
		<updated>2026-04-05T16:10:21Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=PHP_CSRF_Guard&amp;diff=140824</id>
		<title>PHP CSRF Guard</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=PHP_CSRF_Guard&amp;diff=140824"/>
				<updated>2012-12-06T14:05:19Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: patched csrfguard_validate_token bypass vulnerability&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Code Snippet=&lt;br /&gt;
&lt;br /&gt;
If you need to protect against CSRF attacks in your code, this little helper can reduce the risk:&lt;br /&gt;
&lt;br /&gt;
 session_start(); //if you are copying this code, this line makes it work.&lt;br /&gt;
&lt;br /&gt;
 function store_in_session($key,$value)&lt;br /&gt;
 {&lt;br /&gt;
 	if (isset($_SESSION))&lt;br /&gt;
 	{&lt;br /&gt;
 		$_SESSION[$key]=$value;&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 function unset_session($key)&lt;br /&gt;
 {&lt;br /&gt;
 	$_SESSION[$key]=' ';&lt;br /&gt;
 	unset($_SESSION[$key]);&lt;br /&gt;
 }&lt;br /&gt;
 function get_from_session($key)&lt;br /&gt;
 {&lt;br /&gt;
 	if (isset($_SESSION))&lt;br /&gt;
 	{&lt;br /&gt;
 		return $_SESSION[$key];&lt;br /&gt;
 	}&lt;br /&gt;
 	else {  return false; } //no session data, no CSRF risk&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 function csrfguard_generate_token($unique_form_name)&lt;br /&gt;
 {&lt;br /&gt;
 	if (function_exists(&amp;quot;hash_algos&amp;quot;) and in_array(&amp;quot;sha512&amp;quot;,hash_algos()))&lt;br /&gt;
 	{&lt;br /&gt;
 		$token=hash(&amp;quot;sha512&amp;quot;,mt_rand(0,mt_getrandmax()));&lt;br /&gt;
 	}&lt;br /&gt;
 	else&lt;br /&gt;
 	{&lt;br /&gt;
 		$token=' ';&lt;br /&gt;
 		for ($i=0;$i&amp;lt;128;++$i)&lt;br /&gt;
 		{&lt;br /&gt;
 			$r=mt_rand(0,35);&lt;br /&gt;
 			if ($r&amp;lt;26)&lt;br /&gt;
 			{&lt;br /&gt;
 				$c=chr(ord('a')+$r);&lt;br /&gt;
 			}&lt;br /&gt;
 			else&lt;br /&gt;
 			{ &lt;br /&gt;
 				$c=chr(ord('0')+$r-26);&lt;br /&gt;
 			} &lt;br /&gt;
 			$token.=$c;&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	store_in_session($unique_form_name,$token);&lt;br /&gt;
 	return $token;&lt;br /&gt;
 }&lt;br /&gt;
 function csrfguard_validate_token($unique_form_name,$token_value)&lt;br /&gt;
 {&lt;br /&gt;
 	$token=get_from_session($unique_form_name);&lt;br /&gt;
 	if ($token===false)&lt;br /&gt;
 	{&lt;br /&gt;
 		return true;&lt;br /&gt;
 	}&lt;br /&gt;
 	elseif ($token===$token_value)&lt;br /&gt;
 	{&lt;br /&gt;
 		$result=true;&lt;br /&gt;
 	}&lt;br /&gt;
 	else&lt;br /&gt;
 	{ &lt;br /&gt;
 		$result=false;&lt;br /&gt;
 	} &lt;br /&gt;
 	unset_session($unique_form_name);&lt;br /&gt;
 	return $result;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 function csrfguard_replace_forms($form_data_html)&lt;br /&gt;
 {&lt;br /&gt;
 	$count=preg_match_all(&amp;quot;/&amp;lt;form(.*?)&amp;gt;(.*?)&amp;lt;\\/form&amp;gt;/is&amp;quot;,$form_data_html,$matches,PREG_SET_ORDER);&lt;br /&gt;
 	if (is_array($matches))&lt;br /&gt;
 	{&lt;br /&gt;
 		foreach ($matches as $m)&lt;br /&gt;
 		{&lt;br /&gt;
 			if (strpos($m[1],&amp;quot;nocsrf&amp;quot;)!==false) { continue; }&lt;br /&gt;
 			$name=&amp;quot;CSRFGuard_&amp;quot;.mt_rand(0,mt_getrandmax());&lt;br /&gt;
 			$token=csrfguard_generate_token($name);&lt;br /&gt;
 			$form_data_html=str_replace($m[0],&lt;br /&gt;
 				&amp;quot;&amp;lt;form{$m[1]}&amp;gt;&lt;br /&gt;
 &amp;lt;input type='hidden' name='CSRFName' value='{$name}' /&amp;gt;&lt;br /&gt;
 &amp;lt;input type='hidden' name='CSRFToken' value='{$token}' /&amp;gt;{$m[2]}&amp;lt;/form&amp;gt;&amp;quot;,$form_data_html);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	return $form_data_html;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 function csrfguard_inject()&lt;br /&gt;
 {&lt;br /&gt;
 	$data=ob_get_clean();&lt;br /&gt;
 	$data=csrfguard_replace_forms($data);&lt;br /&gt;
 	echo $data;&lt;br /&gt;
 }&lt;br /&gt;
 function csrfguard_start()&lt;br /&gt;
 {&lt;br /&gt;
 	if (count($_POST))&lt;br /&gt;
 	{&lt;br /&gt;
 		if (!isset($_POST['CSRFName']))&lt;br /&gt;
 		{&lt;br /&gt;
 			trigger_error(&amp;quot;No CSRFName found, probable invalid request.&amp;quot;,E_USER_ERROR);		&lt;br /&gt;
 		} &lt;br /&gt;
 		$name =$_POST['CSRFName'];&lt;br /&gt;
 		$token=$_POST['CSRFToken'];&lt;br /&gt;
 		if (!csrfguard_validate_token($name, $token))&lt;br /&gt;
 		{ &lt;br /&gt;
 			trigger_error(&amp;quot;Invalid CSRF token.&amp;quot;,E_USER_ERROR);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	ob_start();&lt;br /&gt;
 	register_shutdown_function(csrfguard_inject);	&lt;br /&gt;
 }&lt;br /&gt;
 csrfguard_start();&lt;br /&gt;
&lt;br /&gt;
=Description and Usage=&lt;br /&gt;
The first three functions, are an abstraction over how session variables are stored. Replace them if you don't use native PHP sessions.&lt;br /&gt;
&lt;br /&gt;
The '''generate''' function, creates a random secure one-time CSRF token. If SHA512 is available, it is used, otherwise a 512 bit random string in the same format is generated. This function also stores the generated token under a unique name in session variable.&lt;br /&gt;
&lt;br /&gt;
The '''validate''' function, checks under the unique name for the token. There are three states:&lt;br /&gt;
* Sessions not active: validate succeeds (no CSRF risk)&lt;br /&gt;
* Token found but not the same, or token not found: validation fails&lt;br /&gt;
* Token found and the same: validation succeeds&lt;br /&gt;
Either case, this function removes the token from sessions, ensuring one-timeness.&lt;br /&gt;
 &lt;br /&gt;
The '''replace''' function, receives a portion of html data, finds all &amp;lt;form&amp;gt; occurrences and adds two hidden fields to them: CSRFName and CSRFToken. If any of these forms has an attribute or value '''''nocsrf'''''', the addition won't be performed (note that using default inject and detect breaks with this).&lt;br /&gt;
&lt;br /&gt;
The other two functions, '''inject''' and '''start''' are a demonstration of how to use the other functions. Using output buffering on your entire output is not recommended (some libraries might dump output buffering). This default behavior, enforces CSRF tokens on all forms using POST method. It is assumed that no sensitive operations with GET method are performed in the application, as required by [http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1 RFC 2616].&lt;br /&gt;
&lt;br /&gt;
To test this code, append the following HTML to it:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;form method='post'&amp;gt;&lt;br /&gt;
 &amp;lt;input type='text' name='test' value='&amp;lt;?php echo &amp;quot;testing&amp;quot;?&amp;gt;' /&amp;gt;&lt;br /&gt;
 &amp;lt;input type='submit' /&amp;gt;&lt;br /&gt;
 &amp;lt;/form&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;form class='nocsrf'&amp;gt;&lt;br /&gt;
 &amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Author and License=&lt;br /&gt;
This piece of code is by [mailto:abbas.naderi@owasp.org Abbas Naderi Afooshteh] from OWASP under Creative Commons 3.0 License.&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119322</id>
		<title>HTML5 Security Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119322"/>
				<updated>2011-10-19T02:32:42Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: small additions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction  =&lt;br /&gt;
&lt;br /&gt;
The following cheat sheet serves as a guide for implementing HTML 5 in a secure fashion. &lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing  ==&lt;br /&gt;
&lt;br /&gt;
*Validate URLs passed to &amp;lt;tt&amp;gt;XMLHttpRequest.open&amp;lt;/tt&amp;gt;, current browsers allow these URLs to be cross domain. &lt;br /&gt;
*Ensure that URLs responding with &amp;lt;tt&amp;gt;Access-Control-Allow-Origin: *&amp;lt;/tt&amp;gt; do not include any sensitive content or information that might aid attacker in further attacks. Use &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header only on chosen URLs that need to be accessed cross-domain. Don't use the header for the whole domain. &lt;br /&gt;
*Take special care when using &amp;lt;tt&amp;gt;Access-Control-Allow-Credentials: true&amp;lt;/tt&amp;gt; response header. Whitelist the allowed Origins and never echo back the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; request header in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt;. &lt;br /&gt;
*Allow only selected, trusted domains in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header. Prefer whitelisting domains over blacklisting or allowing any domain (either through &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; wildcard or echoing the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; header content). &lt;br /&gt;
*Keep in mind that CORS does not prevent the requested data from going to an un-authenticated location - it's still important for the server to perform usual [[Cross-Site Request Forgery (CSRF)|CSRF]] prevention. &lt;br /&gt;
*While the RFC recommends a pre-flight request with the &amp;lt;tt&amp;gt;OPTIONS&amp;lt;/tt&amp;gt; verb, current implementations might not perform this request, so it's important that &amp;quot;ordinary&amp;quot; (&amp;lt;tt&amp;gt;GET&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;POST&amp;lt;/tt&amp;gt;) requests perform any access control necessary.&lt;br /&gt;
&lt;br /&gt;
== Local Storage (a.k.a. Offline Storage, Web Storage)  ==&lt;br /&gt;
&lt;br /&gt;
*Underlying storage mechanism may vary from one user agent to the next. In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored. Therefore, it's recommended not to store any sensitive information in local storage. &lt;br /&gt;
*Pay extra attention to “localStorage.getItem” and “setItem” calls implemented in HTML5 page. It helps in detecting sensitive information storage and their usage at run-time.&lt;br /&gt;
&lt;br /&gt;
== WebDatabase  ==&lt;br /&gt;
&lt;br /&gt;
*Underlying storage mechanism may vary from one user agent to the next. In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored. Therefore, it's recommended not to store any sensitive information in local storage. &lt;br /&gt;
*If utilized, WebDatabase content on client side can be vulnerable to SQLInjection and needs to have proper validation and parametrization.&lt;br /&gt;
&lt;br /&gt;
== Web Workers  ==&lt;br /&gt;
&lt;br /&gt;
*Web Workers are allowed to use &amp;lt;tt&amp;gt;XMLHttpRequest&amp;lt;/tt&amp;gt; object to perform in-domain and Cross Origin Resource Sharing requests. See relevant section of this Cheat Sheet to ensure CORS security. &lt;br /&gt;
*While Web Workers don't have access to DOM of the calling page, malicious Web Workers can use excessive CPU for computation, leading to Denial of Service condition or abuse Cross Origin Resource Sharing for further exploitation. Ensure code in all Web Workers scripts is not malevolent. Don't allow creating Web Worker scripts from user supplied input. &lt;br /&gt;
*Validate messages exchanged with a Web Worker. Do not try to exchange snippets of Javascript for evaluation e.g. via eval() as that could introduce a&amp;amp;nbsp;[[DOM Based XSS|DOM Based XSS]]&amp;amp;nbsp;vulnerability.&lt;br /&gt;
&lt;br /&gt;
== WebSockets  ==&lt;br /&gt;
&lt;br /&gt;
*Drop backward compatibility in implemented client/servers and use only protocol versions above hybi-00. Popular Hixie-76 version and olders are outdated and insecure. &lt;br /&gt;
*While it is relatively easy to tunnel TCP services through WebSockets (e.g. VNC, FTP), doing so enables access to these tunneled services for the in-browser attacker in case of a Cross-Site-Scripting attack. These services might also be called directly from a malicious page or program. &lt;br /&gt;
*The protocol doesn't handle authorization and/or authentication. Application-level protocols should handle that separately in case sensitive data is being transferred. &lt;br /&gt;
*Endpoints exposed through &amp;lt;tt&amp;gt;ws://&amp;lt;/tt&amp;gt; protocol are easily reversible to plaintext. Only &amp;lt;tt&amp;gt;wss://&amp;lt;/tt&amp;gt; (WebSockets over SSH) should be used for protection against Man-In-The-Middle attacks &lt;br /&gt;
*Spoofing the client is possible outside browser, so WebSockets server should be able to handle incorrect/malicious input. Always validate input coming from the remote site, as it might have been altered. &lt;br /&gt;
*When implementing servers, check the &amp;lt;tt&amp;gt;Origin:&amp;lt;/tt&amp;gt; header in Websockets handshake. Though it might be spoofed outside browser, browsers always add the Origin of the page which initiated Websockets connection. &lt;br /&gt;
*As WebSockets client in browser is accessible through Javascript calls, all Websockets communication can be spoofed or hijacked through [[Cross Site Scripting Flaw|Cross-Site-Scripting]]. Always validate data coming through WebSockets connection.&lt;br /&gt;
&lt;br /&gt;
== Geolocation  ==&lt;br /&gt;
&lt;br /&gt;
*The Geolocation RFC recommends that the user agent ask the user's permission before calculating location, but whether or how this decision is remembered varies from browser to browser. Some user agents require the user to visit the page again in order to turn off the ability to get the user's location without asking, so for privacy reasons, it's recommended to require user input before calling &amp;lt;tt&amp;gt;getCurrentPosition&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;watchPosition&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Use the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute of an &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt; for untrusted content  ==&lt;br /&gt;
&lt;br /&gt;
*The &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute of an &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt; enables restrictions on content within a &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt;. The following restrictions are active when the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute is set:&lt;br /&gt;
&lt;br /&gt;
#All markup is treated as being from a unique origin &lt;br /&gt;
#All forms and scripts are disabled &lt;br /&gt;
#All links are prevented from targeting other browsing contexts &lt;br /&gt;
#All plugins are disabled&lt;br /&gt;
&lt;br /&gt;
It is possible to have a [http://www.whatwg.org/specs/web-apps/current-work/multipage/the-iframe-element.html#attr-iframe-sandbox fine-grained control] over &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt; capabilities using the value of the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute.&lt;br /&gt;
&lt;br /&gt;
== Web Messaging  ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging provides a means of messaging between documents from different origins in a way which is generally safer than JSON-P, however, there are still some recommendations to keep in mind: &lt;br /&gt;
&lt;br /&gt;
*When posting a message, explicitly state the expected origin as the second argument to &amp;lt;tt&amp;gt;postMessage&amp;lt;/tt&amp;gt; rather than &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; in order to prevent sending the message to an unknown origin after a redirect or some other means of the target window's origin changing. &lt;br /&gt;
*The receiving page should '''always''': &lt;br /&gt;
**Check the &amp;lt;tt&amp;gt;origin&amp;lt;/tt&amp;gt; attribute of the sender to verify the data is originating from the expected location, and &lt;br /&gt;
**Perform input validation on the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; attribute of the event to ensure it's in the desired format.&lt;br /&gt;
*Don't assume you have control over data attribute. Single [[Cross-site_Scripting_(XSS)|Cross Site Scripting]] flaw in sending page allows attacker to send messages of any given format.&lt;br /&gt;
*Both pages should only interpret the exchanged messages as '''data'''. Never evaluate passed messages as code (e.g. via eval() )&amp;amp;nbsp;or insert it to a page DOM (e.g. via&amp;amp;nbsp;innerHTML) as that would create a DOM based XSS vulnerability. For more information see [[DOM based XSS Prevention Cheat Sheet|DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== XHR and DOM abuses  ==&lt;br /&gt;
&lt;br /&gt;
*XHR calls allow dynamic loading of streams into existing DOM under HTML5 framework, it can open up vulnerabilities like DOM based XSS and DOM driven open redirect and forwards. It is imperative to secure calls and streams. For more information see [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== HTML5 Widgets  ==&lt;br /&gt;
&lt;br /&gt;
*If the application allows loading of widgets within the HTML5 page structure, then it is important to make sure that they are not sharing the same DOM. Each widget should be running in its own sandbox/DOM running in separate iframe.&lt;br /&gt;
&lt;br /&gt;
== Progressive Enhancements and Graceful Degradation Risks  ==&lt;br /&gt;
&lt;br /&gt;
*The best practice now is to determine the capabilities that a browser supports and augment with some type of substitute for capabilities that are not directly supported. This may mean an onion-like element, e.g. falling through to a Flash Player if the &amp;amp;lt;video&amp;amp;gt; tag is unsupported, or it may mean additional scripting code from various sources that should be code reviewed.&lt;br /&gt;
&lt;br /&gt;
= Related Cheat Sheets  =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}} &lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Mark Roxbury - mark.roxberry [at] owasp.org &lt;br /&gt;
&lt;br /&gt;
Krzysztof Kotowicz - krzysztof [at] kotowicz.net &lt;br /&gt;
&lt;br /&gt;
Will Stranathan - will [at] cltnc.us &lt;br /&gt;
&lt;br /&gt;
Shreeraj Shah - shreeraj.shah [at] blueinfy.net &lt;br /&gt;
&lt;br /&gt;
[[Category:How_To]] [[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119133</id>
		<title>HTML5 Security Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119133"/>
				<updated>2011-10-15T09:31:43Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: added some points&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS  =&lt;br /&gt;
&lt;br /&gt;
= Introduction  =&lt;br /&gt;
&lt;br /&gt;
= HTML 5  =&lt;br /&gt;
&lt;br /&gt;
== Browser Securability Chart  ==&lt;br /&gt;
&lt;br /&gt;
There are a few sites charting browser capabilities as they relate to the HTML 5 / CSS 3 standard. I have not seen any that mention security. There may not be a need for it, but the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute of &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt;'s will be ignored in browsers except those HTML 5 compliant browsers which support it. If there are differences in implementations, there will be differences in security configuration / settings. &lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing  ==&lt;br /&gt;
&lt;br /&gt;
*Validate URLs passed to &amp;lt;tt&amp;gt;XMLHttpRequest.open&amp;lt;/tt&amp;gt;, current browsers allow these URLs to be cross domain. &lt;br /&gt;
*Ensure that URLs responding with &amp;lt;tt&amp;gt;Access-Control-Allow-Origin: *&amp;lt;/tt&amp;gt; do not include any sensitive content or information that might aid attacker in further attacks. Use &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header only on chosen URLs that need to be accessed cross-domain. Don't use the header for the whole domain. &lt;br /&gt;
*Take special care when using &amp;lt;tt&amp;gt;Access-Control-Allow-Credentials: true&amp;lt;/tt&amp;gt; response header. Whitelist the allowed Origins and never echo back the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; request header in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt;. &lt;br /&gt;
*Allow only selected, trusted domains in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header. Prefer whitelisting domains over blacklisting or allowing any domain (either through &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; wildcard or echoing the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; header content). &lt;br /&gt;
*Keep in mind that CORS does not prevent the requested data from going to an un-authenticated location - it's still important for the server to perform usual [[Cross-Site Request Forgery (CSRF)|CSRF]] prevention. &lt;br /&gt;
*While the RFC recommends a pre-flight request with the &amp;lt;tt&amp;gt;OPTIONS&amp;lt;/tt&amp;gt; verb, current implementations might not perform this request, so it's important that &amp;quot;ordinary&amp;quot; (&amp;lt;tt&amp;gt;GET&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;POST&amp;lt;/tt&amp;gt;) requests perform any access control necessary.&lt;br /&gt;
&lt;br /&gt;
== Local Storage (a.k.a. Offline Storage, Web Storage)  ==&lt;br /&gt;
&lt;br /&gt;
*Underlying storage mechanism may vary from one user agent to the next. In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored. Therefore, it's recommended not to store any sensitive information in local storage. &lt;br /&gt;
*Pay extra attention to “localStorage.getItem” and “setItem” calls implemented in HTML5 page. It helps in detecting sensitive information storage and their usage at run-time.&lt;br /&gt;
&lt;br /&gt;
== WebDatabase  ==&lt;br /&gt;
&lt;br /&gt;
*Underlying storage mechanism may vary from one user agent to the next. In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored. Therefore, it's recommended not to store any sensitive information in local storage. &lt;br /&gt;
*If utilized, WebDatabase content on client side can be vulnerable to SQLInjection and needs to have proper validation and parametrization.&lt;br /&gt;
&lt;br /&gt;
== Web Workers  ==&lt;br /&gt;
&lt;br /&gt;
*Web Workers are allowed to use &amp;lt;tt&amp;gt;XMLHttpRequest&amp;lt;/tt&amp;gt; object to perform in-domain and Cross Origin Resource Sharing requests. See relevant section of this Cheat Sheet to ensure CORS security. &lt;br /&gt;
*While Web Workers don't have access to DOM of the calling page, malicious Web Workers can use excessive CPU for computation, leading to Denial of Service condition or abuse Cross Origin Resource Sharing for further exploitation. Ensure code in all Web Workers scripts is not malevolent. Don't allow creating Web Worker scripts from user supplied input. &lt;br /&gt;
*Validate messages exchanged with a Web Worker. Do not try to exchange snippets of Javascript for evaluation e.g. via eval() as that could introduce a&amp;amp;nbsp;[[DOM_Based_XSS|DOM Based XSS]]&amp;amp;nbsp;vulnerability.&lt;br /&gt;
&lt;br /&gt;
== WebSockets  ==&lt;br /&gt;
&lt;br /&gt;
*Drop backward compatibility in implemented client/servers and use only protocol versions above hybi-00. Popular Hixie-76 version and olders are outdated and insecure. &lt;br /&gt;
*While it is relatively easy to tunnel TCP services through WebSockets (e.g. VNC, FTP), doing so enables access to these tunneled services for the in-browser attacker in case of a Cross-Site-Scripting attack. These services might also be called directly from a malicious page or program. &lt;br /&gt;
*The protocol doesn't handle authorization and/or authentication. Application-level protocols should handle that separately in case sensitive data is being transferred. &lt;br /&gt;
*Endpoints exposed through &amp;lt;tt&amp;gt;ws://&amp;lt;/tt&amp;gt; protocol are easily reversible to plaintext. Only &amp;lt;tt&amp;gt;wss://&amp;lt;/tt&amp;gt; (WebSockets over SSH) should be used for protection against Man-In-The-Middle attacks &lt;br /&gt;
*Spoofing the client is possible outside browser, so WebSockets server should be able to handle incorrect/malicious input. Always validate input coming from the remote site, as it might have been altered. &lt;br /&gt;
*When implementing servers, check the &amp;lt;tt&amp;gt;Origin:&amp;lt;/tt&amp;gt; header in Websockets handshake. Though it might be spoofed outside browser, browsers always add the Origin of the page which initiated Websockets connection. &lt;br /&gt;
*As WebSockets client in browser is accessible through Javascript calls, all Websockets communication can be spoofed or hijacked through [[Cross Site Scripting Flaw|Cross-Site-Scripting]]. Always validate data coming through WebSockets connection.&lt;br /&gt;
&lt;br /&gt;
== Geolocation  ==&lt;br /&gt;
&lt;br /&gt;
*The Geolocation RFC recommends that the user agent ask the user's permission before calculating location, but whether or how this decision is remembered varies from browser to browser. Some user agents require the user to visit the page again in order to turn off the ability to get the user's location without asking, so for privacy reasons, it's recommended to require user input before calling &amp;lt;tt&amp;gt;getCurrentPosition&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;watchPosition&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Use the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute for untrusted content (iFrame)  ==&lt;br /&gt;
&lt;br /&gt;
[[http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox]] &lt;br /&gt;
&lt;br /&gt;
== Web Messaging  ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging provides a means of messaging between documents from different origins in a way which is generally safer than JSON-P, however, there are still some recommendations to keep in mind: &lt;br /&gt;
&lt;br /&gt;
*When posting a message, explicitly state the expected origin as the second argument to &amp;lt;tt&amp;gt;postMessage&amp;lt;/tt&amp;gt; rather than &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; in order to prevent sending the message to an unknown origin after a redirect or some other means of the target window's origin changing. &lt;br /&gt;
*The receiving page should '''always''': &lt;br /&gt;
**Check the &amp;lt;tt&amp;gt;origin&amp;lt;/tt&amp;gt; attribute of the sender to verify the data is originating from the expected location, and &lt;br /&gt;
**Perform input validation on the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; attribute of the event to ensure it's in the desired format.&lt;br /&gt;
**Don't assume you have control over data attribute. Single&amp;amp;nbsp;[[Cross-Site_Scripting|Cross Site Scripting]] flaw in sending page allows attacker to send messages of any given format.&amp;lt;br&amp;gt; &lt;br /&gt;
*Both pages should only interpret the exchanged messages as '''data'''. Never evaluate passed messages as code (e.g. via eval() )&amp;amp;nbsp;or insert it to a page DOM (e.g. via&amp;amp;nbsp;innerHTML) as that would create a DOM based XSS vulnerability. For more information see [[DOM_based_XSS_Prevention_Cheat_Sheet|DOM based XSS Prevention Cheat Sheet]].&amp;lt;span class=&amp;quot;Apple-tab-span&amp;quot; style=&amp;quot;white-space:pre&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== XHR and DOM abuses  ==&lt;br /&gt;
&lt;br /&gt;
*XHR calls allow dynamic loading of streams into existing DOM under HTML5 framework, it can open up vulnerabilities like DOM based XSS and DOM driven open redirect and forwards. It is imperative to secure calls and streams. For more information see [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== HTML5 Widgets  ==&lt;br /&gt;
&lt;br /&gt;
*If the application allows loading of widgets within the HTML5 page structure, then it is important to make sure that they are not sharing the same DOM. Each widget should be running in its own sandbox/DOM running in separate iframe.&lt;br /&gt;
&lt;br /&gt;
== Progressive Enhancements and Graceful Degradation Risks  ==&lt;br /&gt;
&lt;br /&gt;
*The best practice now is to determine the capabilities that a browser supports and augment with some type of substitute for capabilities that are not directly supported. This may mean an onion-like element, e.g. falling through to a Flash Player if the &amp;amp;lt;video&amp;amp;gt; tag is unsupported, or it may mean additional scripting code from various sources that should be code reviewed.&lt;br /&gt;
&lt;br /&gt;
= Related Cheat Sheets  =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}} &lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Mark Roxbury - mark.roxberry [at] owasp.org &lt;br /&gt;
&lt;br /&gt;
Krzysztof Kotowicz - krzysztof [at] kotowicz.net &lt;br /&gt;
&lt;br /&gt;
Will Stranathan - will [at] cltnc.us &lt;br /&gt;
&lt;br /&gt;
Shreeraj Shah - shreeraj.shah [at] blueinfy.net &lt;br /&gt;
&lt;br /&gt;
[[Category:How_To]] [[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119132</id>
		<title>HTML5 Security Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=119132"/>
				<updated>2011-10-15T09:14:53Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: filled-out webworkers section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
&lt;br /&gt;
= Introduction  =&lt;br /&gt;
&lt;br /&gt;
= HTML 5  =&lt;br /&gt;
&lt;br /&gt;
== Browser Securability Chart  ==&lt;br /&gt;
&lt;br /&gt;
There are a few sites charting browser capabilities as they relate to the HTML 5 / CSS 3 standard. I have not seen any that mention security. There may not be a need for it, but the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute of &amp;lt;tt&amp;gt;iframe&amp;lt;/tt&amp;gt;'s will be ignored in browsers except those HTML 5 compliant browsers which support it. If there are differences in implementations, there will be differences in security configuration / settings. &lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing  ==&lt;br /&gt;
&lt;br /&gt;
* Validate URLs passed to &amp;lt;tt&amp;gt;XMLHttpRequest.open&amp;lt;/tt&amp;gt;, current browsers allow these URLs to be cross domain. &lt;br /&gt;
* Ensure that URLs responding with &amp;lt;tt&amp;gt;Access-Control-Allow-Origin: *&amp;lt;/tt&amp;gt; do not include any sensitive content or information that might aid attacker in further attacks. Use &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header only on chosen URLs that need to be accessed cross-domain. Don't use the  header for the whole domain. &lt;br /&gt;
* Take special care when using &amp;lt;tt&amp;gt;Access-Control-Allow-Credentials: true&amp;lt;/tt&amp;gt; response header. Whitelist the allowed Origins and never echo back the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; request header in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Allow only selected, trusted domains in &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header. Prefer whitelisting domains over blacklisting or allowing any domain (either through &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; wildcard or echoing the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; header content).&lt;br /&gt;
* Keep in mind that CORS does not prevent the requested data from going to an un-authenticated location - it's still important for the server to perform usual [[Cross-Site Request Forgery (CSRF)|CSRF]] prevention.&lt;br /&gt;
* While the RFC recommends a pre-flight request with the &amp;lt;tt&amp;gt;OPTIONS&amp;lt;/tt&amp;gt; verb, current implementations might not perform this request, so it's important that &amp;amp;quot;ordinary&amp;amp;quot; (&amp;lt;tt&amp;gt;GET&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;POST&amp;lt;/tt&amp;gt;) requests perform any access control necessary.&lt;br /&gt;
&lt;br /&gt;
== Local Storage (a.k.a. Offline Storage, Web Storage)  ==&lt;br /&gt;
* Underlying storage mechanism may vary from one user agent to the next.  In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored.  Therefore, it's recommended not to store any sensitive information in local storage.&lt;br /&gt;
* Pay extra attention to “localStorage.getItem” and “setItem” calls implemented in HTML5 page. It helps in detecting sensitive information storage and their usage at run-time.&lt;br /&gt;
&lt;br /&gt;
== WebDatabase  ==&lt;br /&gt;
* Underlying storage mechanism may vary from one user agent to the next.  In other words, any authentication your application requires can be bypassed by a user with local privileges to the machine on which the data is stored.  Therefore, it's recommended not to store any sensitive information in local storage.&lt;br /&gt;
* If utilized, WebDatabase content on client side can be vulnerable to SQLInjection and needs to have proper validation and parametrization.&lt;br /&gt;
&lt;br /&gt;
== Web Workers ==&lt;br /&gt;
* Web Workers are allowed to use &amp;lt;tt&amp;gt;XMLHttpRequest&amp;lt;/tt&amp;gt; object to perform in-domain and Cross Origin Resource Sharing requests. See relevant section of this Cheat Sheet to ensure CORS security.&lt;br /&gt;
* While Web Workers don't have access to DOM of the calling page, malicious Web Workers can use excessive CPU for computation, leading to Denial of Service condition or abuse Cross Origin Resource Sharing for further exploitation. Ensure code in all Web Workers scripts is not malevolent. Don't allow creating Web Worker scripts from user supplied input.&lt;br /&gt;
* Validate messages exchanged with a Web Worker. Do not try to exchange snippets of Javascript for evaluation e.g. via eval()&lt;br /&gt;
&lt;br /&gt;
== WebSockets  ==&lt;br /&gt;
&lt;br /&gt;
* Drop backward compatibility in implemented client/servers and use only protocol versions above hybi-00. Popular Hixie-76 version and olders are outdated and insecure. &lt;br /&gt;
* While it is relatively easy to tunnel TCP services through WebSockets (e.g. VNC, FTP), doing so enables access to these tunneled services for the in-browser attacker in case of a Cross-Site-Scripting attack. These services might also be called directly from a malicious page or program. &lt;br /&gt;
* The protocol doesn't handle authorization and/or authentication. Application-level protocols should handle that separately in case sensitive data is being transferred. &lt;br /&gt;
* Endpoints exposed through &amp;lt;tt&amp;gt;ws://&amp;lt;/tt&amp;gt; protocol are easily reversible to plaintext. Only &amp;lt;tt&amp;gt;wss://&amp;lt;/tt&amp;gt; (WebSockets over SSH) should be used for protection against Man-In-The-Middle attacks &lt;br /&gt;
* Spoofing the client is possible outside browser, so WebSockets server should be able to handle incorrect/malicious input. Always validate input coming from the remote site, as it might have been altered. &lt;br /&gt;
* When implementing servers, check the &amp;lt;tt&amp;gt;Origin:&amp;lt;/tt&amp;gt; header in Websockets handshake. Though it might be spoofed outside browser, browsers always add the Origin of the page which initiated Websockets connection. &lt;br /&gt;
* As WebSockets client in browser is accessible through Javascript calls, all Websockets communication can be spoofed or hijacked through [[Cross Site Scripting Flaw|Cross-Site-Scripting]]. Always validate data coming through WebSockets connection.&lt;br /&gt;
&lt;br /&gt;
== Geolocation ==&lt;br /&gt;
* The Geolocation RFC recommends that the user agent ask the user's permission before calculating location, but whether or how this decision is remembered varies from browser to browser.  Some user agents require the user to visit the page again in order to turn off the ability to get the user's location without asking, so for privacy reasons, it's recommended to require user input before calling &amp;lt;tt&amp;gt;getCurrentPosition&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;watchPosition&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Use the &amp;lt;tt&amp;gt;sandbox&amp;lt;/tt&amp;gt; attribute for untrusted content (iFrame)  ==&lt;br /&gt;
&lt;br /&gt;
[[http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox]] &lt;br /&gt;
&lt;br /&gt;
== Web Messaging ==&lt;br /&gt;
Web Messaging provides a means of messaging between documents from different origins in a way which is generally safer than JSON-P, however, there are still some recommendations to keep in mind:&lt;br /&gt;
* When posting a message, explicitly state the expected origin as the second argument to &amp;lt;tt&amp;gt;postMessage&amp;lt;/tt&amp;gt; rather than &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; in order to prevent sending the message to an unknown origin after a redirect or some other means of the target window's origin changing.&lt;br /&gt;
* The receiving page should '''always''':&lt;br /&gt;
** Check the &amp;lt;tt&amp;gt;origin&amp;lt;/tt&amp;gt; attribute of the sender to verify the data is originating from the expected location, and&lt;br /&gt;
** Perform input validation on the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; attribute of the event to ensure it's in the desired format&lt;br /&gt;
&lt;br /&gt;
== XHR and DOM abuses ==&lt;br /&gt;
&lt;br /&gt;
* XHR calls allow dynamic loading of streams into existing DOM under HTML5 framework, it can open up vulnerabilities like DOM based XSS and DOM driven open redirect and forwards. It is imperative to secure calls and streams. For more information see [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== HTML5 Widgets ==&lt;br /&gt;
&lt;br /&gt;
* If the application allows loading of widgets within the HTML5 page structure, then it is important to make sure that they are not sharing the same DOM. Each widget should be running in its own sandbox/DOM running in separate iframe.&lt;br /&gt;
&lt;br /&gt;
== Progressive Enhancements and Graceful Degradation Risks  ==&lt;br /&gt;
&lt;br /&gt;
* The best practice now is to determine the capabilities that a browser supports and augment with some type of substitute for capabilities that are not directly supported. This may mean an onion-like element, e.g. falling through to a Flash Player if the &amp;amp;lt;video&amp;amp;gt; tag is unsupported, or it may mean additional scripting code from various sources that should be code reviewed. &lt;br /&gt;
&lt;br /&gt;
= Related Cheat Sheets  =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}} &lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Mark Roxbury - mark.roxberry [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
Krzysztof Kotowicz - krzysztof [at] kotowicz.net&lt;br /&gt;
&lt;br /&gt;
Will Stranathan - will [at] cltnc.us&lt;br /&gt;
&lt;br /&gt;
Shreeraj Shah - shreeraj.shah [at] blueinfy.net&lt;br /&gt;
&lt;br /&gt;
[[Category:How_To]] [[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML_5_Cheat_Sheet&amp;diff=117030</id>
		<title>HTML 5 Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HTML_5_Cheat_Sheet&amp;diff=117030"/>
				<updated>2011-09-09T10:44:15Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction  =&lt;br /&gt;
&lt;br /&gt;
= HTML 5  =&lt;br /&gt;
&lt;br /&gt;
== Browser Securability Chart  ==&lt;br /&gt;
&lt;br /&gt;
There are a few sites charting browser capabilities as they related to the HTML 5 / CSS 3 standard. I have not seen any that mention security. There may not be a need for it, but e.g. 'sandbox' will be ignored in down browsers, but which HTML 5 compliant browsers support it. If there are differences in implementations, my assumption is that there will be differences in security configuration / settings. &lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing  ==&lt;br /&gt;
&lt;br /&gt;
*Validate URLs passed to XMLHttpRequest.open, current browsers allow these URLS to be cross domain. &lt;br /&gt;
*Ensure that URLs responding with Access-Control-Allow-Origin: * do not include any sensitive content or information that might aid attacker in further attacks. Use Access-Control-Allow-Origin header only on chosen URLs that need to be accessed cross-domain. Don't use that header for the whole domain. &lt;br /&gt;
*Take special care when using Access-Control-Allow-Credentials: true response header. Whitelist the allowed Origins and never echo back the Origin request header in Access-Control-Allow-Origin.&amp;lt;br&amp;gt; &lt;br /&gt;
*Allow only selected, trusted domains in Access-Control-Allow-Origin header. Prefer whitelisting domains over blacklisting or allowing any domain (either through * wildcard or echoing the Origin header content).&lt;br /&gt;
&lt;br /&gt;
== Input Validation  ==&lt;br /&gt;
&lt;br /&gt;
== Local Storage (a.k.a. Offline Storage, Web Storage)  ==&lt;br /&gt;
&lt;br /&gt;
== WebDatabase  ==&lt;br /&gt;
&lt;br /&gt;
== WebSockets  ==&lt;br /&gt;
&lt;br /&gt;
*Drop backward compatibility in implemented client/servers and use only protocol versions above hybi-00. Popular Hixie-76 version and olders are outdated and insecure. &lt;br /&gt;
*While it is relatively easy to tunnel TCP services through WebSockets (e.g. VNC, FTP), doing so enables access to these tunneled services for the in-browser attacker in case of a Cross-Site-Scripting attack. These services might also be called directly from a malicious page or program. &lt;br /&gt;
*The protocol doesn't handle authorisation and/or authentication. Application-level protocols should handle that separately in case sensitive data is being transferred. &lt;br /&gt;
*Endpoints exposed through ws:/ protocol are easily reversible to plaintext. Only wss:// (WebSockets over SSH) should be used for protection against Man-In-The-Middle attacks &lt;br /&gt;
*Spoofing the client is possible outside browser, so WebSockets server should be able to handle incorrect/malicious input. Always validate input coming from the remote site, as it might have been altered. &lt;br /&gt;
*When implementing servers, check the Origin: header in Websockets handshake. Though it might be spoofed outside browser, browsers always add the Origin of the page which initiated Websockets connection. &lt;br /&gt;
*As WebSockets client in browser is accessible through Javascript calls, all Websockets communication can be spoofed or hijacked through Cross-Site-Scripting. Always validate data coming through WebSockets connection.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Geolocation  ==&lt;br /&gt;
&lt;br /&gt;
== Use the &amp;quot;sandbox&amp;quot; attribute for untrusted content (iFrame)  ==&lt;br /&gt;
&lt;br /&gt;
[[http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox]] &lt;br /&gt;
&lt;br /&gt;
== Content Deliverability  ==&lt;br /&gt;
&lt;br /&gt;
CDN or src links to foreign domains = know your content &lt;br /&gt;
&lt;br /&gt;
== Progressive Enhancements and Graceful Degradation Risks  ==&lt;br /&gt;
&lt;br /&gt;
The best practice now is to determine the capabilities that a browser supports and augment with some type of substitute for capabilities that are not directly supported. This may mean an onion-like element, e.g. falling through to a Flash Player if the &amp;amp;lt;video&amp;amp;gt; tag is unsupported, or it may mean additional scripting code from various sources that should be code reviewed. &lt;br /&gt;
&lt;br /&gt;
= CSS 3  =&lt;br /&gt;
&lt;br /&gt;
I haven't seen any specific to CSS 3 and it's been a while since I worried about url /&amp;amp;nbsp;!import. I think privacy leaks are the most well know - e.g. querying global history using&amp;amp;nbsp;:visited (https://bugzilla.mozilla.org/show_bug.cgi?id=147777) &lt;br /&gt;
&lt;br /&gt;
= Javascript and Javascript Frameworks  =&lt;br /&gt;
&lt;br /&gt;
Do we have cheatsheets for Javascript (e.g. use closures, protect the global namespace) or any of the frameworks like JQuery, script.aculo.us, Prototype, Mootools &lt;br /&gt;
&lt;br /&gt;
= Related Cheat Sheets  =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}} &lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Krzysztof Kotowicz - krzysztof [at] kotowicz.net &lt;br /&gt;
&lt;br /&gt;
[[Category:How_To]] [[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML_5_Cheat_Sheet&amp;diff=117029</id>
		<title>HTML 5 Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=HTML_5_Cheat_Sheet&amp;diff=117029"/>
				<updated>2011-09-09T10:43:57Z</updated>
		
		<summary type="html">&lt;p&gt;Krzysztof Kotowicz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction  =&lt;br /&gt;
&lt;br /&gt;
= HTML 5  =&lt;br /&gt;
&lt;br /&gt;
== Browser Securability Chart  ==&lt;br /&gt;
&lt;br /&gt;
There are a few sites charting browser capabilities as they related to the HTML 5 / CSS 3 standard. I have not seen any that mention security. There may not be a need for it, but e.g. 'sandbox' will be ignored in down browsers, but which HTML 5 compliant browsers support it. If there are differences in implementations, my assumption is that there will be differences in security configuration / settings. &lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Validate URLs passed to XMLHttpRequest.open, current browsers allow these URLS to be cross domain.&lt;br /&gt;
*Ensure that URLs responding with Access-Control-Allow-Origin: * do not include any sensitive content or information that might aid attacker in further attacks. Use Access-Control-Allow-Origin header only on chosen URLs that need to be accessed cross-domain. Don't use that header for the whole domain.&lt;br /&gt;
*Take special care when using Access-Control-Allow-Credentials: true response header. Whitelist the allowed Origins and never echo back the Origin request header in Access-Control-Allow-Origin.&amp;lt;br&amp;gt;&lt;br /&gt;
*Allow only selected, trusted domains in Access-Control-Allow-Origin header. Prefer whitelisting domains over blacklisting or allowing any domain (either through * wildcard or echoing the Origin header content).&lt;br /&gt;
&lt;br /&gt;
== Input Validation  ==&lt;br /&gt;
&lt;br /&gt;
== Local Storage (a.k.a. Offline Storage, Web Storage)  ==&lt;br /&gt;
&lt;br /&gt;
== WebDatabase  ==&lt;br /&gt;
&lt;br /&gt;
== WebSockets  ==&lt;br /&gt;
&lt;br /&gt;
*Drop backward compatibility in implemented client/servers and use only protocol versions above hybi-00. Popular Hixie-76 version and olders are outdated and insecure.&lt;br /&gt;
*While it is relatively easy to tunnel TCP services through WebSockets (e.g. VNC, FTP), doing so enables access to these tunneled services for the in-browser attacker in case of a Cross-Site-Scripting attack. These services might also be called directly from a malicious page or program.&lt;br /&gt;
*The protocol doesn't handle authorisation and/or authentication. Application-level protocols should handle that separately in case sensitive data is being transferred.&lt;br /&gt;
*Endpoints exposed through ws:/ protocol are easily reversible to plaintext. Only wss:// (WebSockets over SSH) should be used for protection against Man-In-The-Middle attacks&lt;br /&gt;
*Spoofing the client is possible outside browser, so WebSockets server should be able to handle incorrect/malicious input. Always validate input coming from the remote site, as it might have been altered.&lt;br /&gt;
*When implementing servers, check the Origin: header in Websockets handshake. Though it might be spoofed outside browser, browsers always add the Origin of the page which initiated Websockets connection.&lt;br /&gt;
*As WebSockets client in browser is accessible through Javascript calls, all Websockets communication can be spoofed or hijacked through Cross-Site-Scripting. Always validate data coming through WebSockets connection.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Geolocation  ==&lt;br /&gt;
&lt;br /&gt;
== Use the &amp;quot;sandbox&amp;quot; attribute for untrusted content (iFrame)  ==&lt;br /&gt;
&lt;br /&gt;
[[http://blog.whatwg.org/whats-next-in-html-episode-2-sandbox]] &lt;br /&gt;
&lt;br /&gt;
== Content Deliverability  ==&lt;br /&gt;
&lt;br /&gt;
CDN or src links to foreign domains = know your content &lt;br /&gt;
&lt;br /&gt;
== Progressive Enhancements and Graceful Degradation Risks  ==&lt;br /&gt;
&lt;br /&gt;
The best practice now is to determine the capabilities that a browser supports and augment with some type of substitute for capabilities that are not directly supported. This may mean an onion-like element, e.g. falling through to a Flash Player if the &amp;amp;lt;video&amp;amp;gt; tag is unsupported, or it may mean additional scripting code from various sources that should be code reviewed. &lt;br /&gt;
&lt;br /&gt;
= CSS 3  =&lt;br /&gt;
&lt;br /&gt;
I haven't seen any specific to CSS 3 and it's been a while since I worried about url /&amp;amp;nbsp;!import. I think privacy leaks are the most well know - e.g. querying global history using&amp;amp;nbsp;:visited (https://bugzilla.mozilla.org/show_bug.cgi?id=147777) &lt;br /&gt;
&lt;br /&gt;
= Javascript and Javascript Frameworks  =&lt;br /&gt;
&lt;br /&gt;
Do we have cheatsheets for Javascript (e.g. use closures, protect the global namespace) or any of the frameworks like JQuery, script.aculo.us, Prototype, Mootools &lt;br /&gt;
&lt;br /&gt;
= Related Cheat Sheets  =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}} &lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Krzysztof Kotowicz - krzysztof [at] kotowicz.net&lt;br /&gt;
&lt;br /&gt;
[[Category:How_To]] [[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Krzysztof Kotowicz</name></author>	</entry>

	</feed>