<?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=Hendrik+Brummermann</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=Hendrik+Brummermann"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Hendrik_Brummermann"/>
		<updated>2026-05-16T23:19:53Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=HTML5_Security_Cheat_Sheet&amp;diff=200285</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=200285"/>
				<updated>2015-09-09T14:42:09Z</updated>
		
		<summary type="html">&lt;p&gt;Hendrik Brummermann: CSP has dropped the X- prefix a long time ago&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; __NOTOC__&lt;br /&gt;
&amp;lt;div style=&amp;quot;width:100%;height:160px;border:0,margin:0;overflow: hidden;&amp;quot;&amp;gt;[[File:Cheatsheets-header.jpg|link=]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;padding: 0;margin:0;margin-top:10px;text-align:left;&amp;quot; |-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot;  style=&amp;quot;border-right: 1px dotted gray;padding-right:25px;&amp;quot; |&lt;br /&gt;
Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' &lt;br /&gt;
= Introduction  =&lt;br /&gt;
 __TOC__{{TOC hidden}}&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;
= Communication APIs =&lt;br /&gt;
&lt;br /&gt;
== Web Messaging ==&lt;br /&gt;
&lt;br /&gt;
Web Messaging (also known as Cross Domain Messaging) provides a means of messaging between documents from different origins in a way that is generally safer than the multiple hacks used in the past to accomplish this task. 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.&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 that it's in the desired format.&lt;br /&gt;
* Don't assume you have control over the &amp;lt;tt&amp;gt;data&amp;lt;/tt&amp;gt; attribute. A single [[Cross-site_Scripting_(XSS)|Cross Site Scripting]] flaw in the sending page allows an 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 &amp;lt;tt&amp;gt;eval()&amp;lt;/tt&amp;gt;) or insert it to a page DOM (e.g. via &amp;lt;tt&amp;gt;innerHTML&amp;lt;/tt&amp;gt;), 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;
* To assign the data value to an element, instead of using a insecure method like &amp;lt;tt&amp;gt;element.innerHTML = data;&amp;lt;/tt&amp;gt;, use the safer option: &amp;lt;tt&amp;gt;element.textContent = data;&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Check the origin properly exactly to match the FQDN(s) you expect. Note that the following code: &amp;lt;tt&amp;gt; if(message.orgin.indexOf(&amp;quot;.owasp.org&amp;quot;)!=-1) { /* ... */ }&amp;lt;/tt&amp;gt; is very insecure and will not have the desired behavior as &amp;lt;tt&amp;gt;www.owasp.org.attacker.com&amp;lt;/tt&amp;gt; will match.&lt;br /&gt;
* If you need to embed external content/untrusted gadgets and allow user-controlled scripts (which is highly discouraged), consider using a JavaScript rewriting framework such as [http://code.google.com/p/google-caja/ Google Caja] or check the information on [[#Sandboxed frames|sandboxed frames]].&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; this behavior can lead to code injection by a remote attacker. Pay extra attention to absolute URLs.&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 the &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;
* Allow only selected, trusted domains in the &amp;lt;tt&amp;gt;Access-Control-Allow-Origin&amp;lt;/tt&amp;gt; header. Prefer whitelisting domains over blacklisting or allowing any domain (do not use &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; wildcard nor blindly return the &amp;lt;tt&amp;gt;Origin&amp;lt;/tt&amp;gt; header content without any checks).&lt;br /&gt;
* Keep in mind that CORS does not prevent the requested data from going to an unauthenticated 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;
* Discard requests received over plain HTTP with HTTPS origins to prevent mixed content bugs.&lt;br /&gt;
* Don't rely only on the Origin header for Access Control checks. Browser always sends this header in CORS requests, but may be spoofed outside the browser. Application-level protocols should be used to protect sensitive data.&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 (hiby-00) and older are outdated and insecure. &lt;br /&gt;
* The recommended version supported in latest versions of all current browsers is [http://tools.ietf.org/html/rfc6455 RFC 6455] (supported by Firefox 11+, Chrome 16+, Safari 6, Opera 12.50, and IE10).&lt;br /&gt;
* While it's 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;
* Process the messages received by the websocket as data. Don't try to assign it directly to the DOM nor evaluate as code. If the response is JSON, never use the insecure eval() function; use the safe option JSON.parse() instead.&lt;br /&gt;
* Endpoints exposed through the &amp;lt;tt&amp;gt;ws://&amp;lt;/tt&amp;gt; protocol are easily reversible to plain text. Only &amp;lt;tt&amp;gt;wss://&amp;lt;/tt&amp;gt; (WebSockets over SSL/TLS) should be used for protection against Man-In-The-Middle attacks.&lt;br /&gt;
* Spoofing the client is possible outside a browser, so the 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 the Websockets handshake. Though it might be spoofed outside a browser, browsers always add the Origin of the page that initiated the Websockets connection.&lt;br /&gt;
* As a WebSockets client in a 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 a WebSockets connection.&lt;br /&gt;
&lt;br /&gt;
== Server-Sent Events ==&lt;br /&gt;
&lt;br /&gt;
* Validate URLs passed to the &amp;lt;tt&amp;gt;EventSource&amp;lt;/tt&amp;gt; constructor, even though only same-origin URLs are allowed.&lt;br /&gt;
* As mentioned before, process the messages (&amp;lt;tt&amp;gt;event.data&amp;lt;/tt&amp;gt;) as data and never evaluate the content as HTML or script code.&lt;br /&gt;
* Always check the origin attribute of the message (&amp;lt;tt&amp;gt;event.origin&amp;lt;/tt&amp;gt;) to ensure the message is coming from a trusted domain. Use a whitelist approach.&lt;br /&gt;
&lt;br /&gt;
= Storage APIs =&lt;br /&gt;
&lt;br /&gt;
== Local Storage ==&lt;br /&gt;
&lt;br /&gt;
*Also known as Offline Storage, Web Storage. 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;
*Use the object sessionStorage instead of localStorage if persistent storage is not needed. sessionStorage object is available only to that window/tab until the window is closed.&lt;br /&gt;
*A single [[Cross-site_Scripting_(XSS)|Cross Site Scripting]] can be used to steal all the data in these objects, so again it's recommended not to store sensitive information in local storage.&lt;br /&gt;
*A single [[Cross-site_Scripting_(XSS)|Cross Site Scripting]] can be used to load malicious data into these objects too, so don't consider objects in these to be trusted.&lt;br /&gt;
*Pay extra attention to “localStorage.getItem” and “setItem” calls implemented in HTML5 page. It helps in detecting when developers build solutions that put sensitive information in local storage, which is a bad practice.&lt;br /&gt;
*Do not store session identifiers in local storage as the data is always accesible by JavaScript. Cookies can mitigate this risk using the &amp;lt;tt&amp;gt;httpOnly&amp;lt;/tt&amp;gt; flag.&lt;br /&gt;
*There is no way to restrict the visibility of an object to a specific path like with the attribute path of HTTP Cookies, every object is shared within an origin and protected with the Same Origin Policy. Avoid host multiple applications on the same origin, all of them would share the same localStorage object, use different subdomains instead.&lt;br /&gt;
&lt;br /&gt;
== Client-side databases  ==&lt;br /&gt;
&lt;br /&gt;
* On November 2010, the W3C announced Web SQL Database (relational SQL database) as a deprecated specification. A new standard Indexed Database API or IndexedDB (formerly WebSimpleDB) is actively developed, which provides key/value database storage and methods for performing advanced queries.&lt;br /&gt;
* Underlying storage mechanisms 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 the client side can be vulnerable to SQL injection and needs to have proper validation and parameterization.&lt;br /&gt;
* Like Local Storage, a single [[Cross-site_Scripting_(XSS)|Cross Site Scripting]] can be used to load malicious data into a web database as well. Don't consider data in these to be trusted.&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. 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;
= 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;
= Sandboxed frames  =&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;
* 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;
*# 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 features that triggers automatically are blocked.&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;
* In old versions of user agents where this feature is not supported, this attribute will be ignored. Use this feature as an additional layer of protection or check if the browser supports sandboxed frames and only show the untrusted content if supported.&lt;br /&gt;
* Apart from this attribute, to prevent Clickjacking attacks and unsolicited framing it is encouraged to use the header &amp;lt;tt&amp;gt;X-Frame-Options&amp;lt;/tt&amp;gt; which supports the &amp;lt;tt&amp;gt;deny&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;same-origin&amp;lt;/tt&amp;gt; values. Other solutions like framebusting &amp;lt;tt&amp;gt;if(window!== window.top) { window.top.location = location; }&amp;lt;/tt&amp;gt; are not recommended.&lt;br /&gt;
&lt;br /&gt;
= Offline Applications =&lt;br /&gt;
&lt;br /&gt;
* Whether the user agent requests permission to the user to store data for offline browsing and when this cache is deleted varies from one browser to the next. Cache poisoning is an issue if a user connects through insecure networks, so for privacy reasons it is encouraged to require user input before sending any &amp;lt;tt&amp;gt;manifest&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
* Users should only cache trusted websites and clean the cache after browsing through open or insecure networks.&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;
= HTTP Headers to enhance security =&lt;br /&gt;
&lt;br /&gt;
== X-Frame-Options ==&lt;br /&gt;
&lt;br /&gt;
* This header can be used to prevent ClickJacking in modern browsers.&lt;br /&gt;
* Use the &amp;lt;tt&amp;gt;same-origin&amp;lt;/tt&amp;gt; attribute to allow being framed from urls of the same origin or &amp;lt;tt&amp;gt;deny&amp;lt;/tt&amp;gt; to block all. Example: &amp;lt;tt&amp;gt;X-Frame-Options: DENY&amp;lt;/tt&amp;gt;&lt;br /&gt;
* For more information on Clickjacking Defense please see the [[Clickjacking Defense Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== X-XSS-Protection ==&lt;br /&gt;
&lt;br /&gt;
* Enable XSS filter (only works for Reflected XSS).&lt;br /&gt;
* Example: &amp;lt;tt&amp;gt;X-XSS-Protection: 1; mode=block&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Strict Transport Security ==&lt;br /&gt;
&lt;br /&gt;
* Force every browser request to be sent over TLS/SSL (this can prevent SSL strip attacks).&lt;br /&gt;
* Use includeSubDomains.&lt;br /&gt;
* Example: Strict-Transport-Security: max-age=8640000; includeSubDomains&lt;br /&gt;
&lt;br /&gt;
== Content Security Policy ==&lt;br /&gt;
&lt;br /&gt;
* Policy to define a set of content restrictions for web resources which aims to mitigate web application vulnerabilities such as Cross Site Scripting.&lt;br /&gt;
* Example:  Content-Security-Policy: allow 'self'; img-src *; object-src media.example.com; script-src js.example.com&lt;br /&gt;
&lt;br /&gt;
== Origin ==&lt;br /&gt;
&lt;br /&gt;
* Sent by CORS/WebSockets requests.&lt;br /&gt;
* There is a proposal to use this header to mitigate CSRF attacks, but is not yet implemented by vendors for this purpose.&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! First        !! Last         !! Email&lt;br /&gt;
|-&lt;br /&gt;
| Mark         || Roxberry     || 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;
| Juan         || Galiana Lara || jgaliana [at] owasp.org&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Cheatsheets ==&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation_Body}}&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Hendrik Brummermann</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=97784</id>
		<title>XSS (Cross Site Scripting) Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=97784"/>
				<updated>2010-12-28T16:42:25Z</updated>
		
		<summary type="html">&lt;p&gt;Hendrik Brummermann: removed wrong leading &amp;quot; ...&amp;quot; in tag example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
This article provides a simple positive model for preventing [[XSS]] using output escaping/encoding properly. While there are a huge number of XSS attack vectors, following a few simple rules can completely defend against this serious attack. This article does not explore the technical or business impact of XSS. Suffice it to say that it can lead to an attacker gaining the ability to do anything a victim can do through their browser.&lt;br /&gt;
&lt;br /&gt;
These rules apply to all the different varieties of XSS. Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate escaping on the server-side. The use of an escaping/encoding library like the one in [[ESAPI]] is strongly recommended as there are many special cases. [[DOM Based XSS]] can be addressed by applying these rules on the client on untrusted data.&lt;br /&gt;
&lt;br /&gt;
For a great cheatsheet on the attack vectors related to XSS, please refer to the excellent [http://ha.ckers.org/xss.html XSS Cheat Sheet] by RSnake. More background on browser security and the various browsers can be found in the [http://code.google.com/p/browsersec/ Browser Security Handbook].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Untrusted Data ==&lt;br /&gt;
&lt;br /&gt;
Untrusted data is most often data that comes from the HTTP request, in the form of URL parameters, form fields, headers, or cookies. But data that comes from databases, web services, and other sources is frequently untrusted from a security perspective.  That is, it might not have been perfectly validated. The [[Searching for Code in J2EE/Java|OWASP Code Review Guide]] has a decent list of methods that return untrusted data in various languages, but you should be careful about your own methods as well.&lt;br /&gt;
&lt;br /&gt;
Untrusted data should always be treated as though it contains an attack. That means you should not send it '''anywhere''' without taking steps to make sure that any attacks are detected and neutralized. As applications get more and more interconnected, the likelihood of a buried attack being decoded or executed by a downstream interpreter increases rapidly.&lt;br /&gt;
&lt;br /&gt;
Traditionally, [[Data Validation|input validation]] has been the preferred approach for handling untrusted data. However, input validation is not a great solution for injection attacks. First, input validation is typically done when the data is received, before the destination is known. That means that we don't know which characters might be significant in the target interpreter.  Second, and possibly even more importantly, applications must allow potentially harmful characters in. For example, should poor Mr. O'Malley be prevented from registering in the database simply because SQL considers ' a special character?&lt;br /&gt;
&lt;br /&gt;
While input validation is important and should always be performed, it is not a complete solution for injection attacks. It's better to think of input validation as [[Defense in depth|defense in depth]] and use '''escaping''' as described below as the primary defense.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Escaping (aka Output Encoding) ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;[http://www.w3.org/TR/charmod/#sec-Escaping Escaping]&amp;quot; is a technique used to ensure that characters are treated as data, not as characters that are relevant to the interpreter's parser. There are lots of different types of escaping, sometimes confusingly called output &amp;quot;encoding.&amp;quot;  Some of these techniques define a special &amp;quot;escape&amp;quot; character, and other techniques have a more sophisticated syntax that involves several characters.&lt;br /&gt;
&lt;br /&gt;
Do not confuse output escaping with the notion of Unicode character [http://www.w3.org/TR/charmod/#sec-Digital encoding], which involves mapping a Unicode character to a sequence of bits. This level of encoding is automatically decoded, and does '''not''' defuse attacks. However, if there are misunderstandings about the intended charset between the server and browser, it may cause unintended characters to be communicated, possibly enabling XSS attacks. This is why it is still important to [http://www.w3.org/TR/charmod/#sec-Encodings specify] the Unicode character encoding (charset), such as UTF-8, for all communications.&lt;br /&gt;
&lt;br /&gt;
Escaping is the primary means to make sure that untrusted data can't be used to convey an injection attack. There is '''no harm''' in escaping data properly - it will still render in the browser properly. Escaping simply lets the interpreter know that the data is not intended to be executed, and therefore prevents attacks from working.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Injection Theory ==&lt;br /&gt;
&lt;br /&gt;
[[Injection Flaws|Injection]] is an attack that involves breaking out of a data context and switching into a code context through the use of special characters that are significant in the interpreter being used. A data context is like &amp;amp;lt;div&amp;gt;data context&amp;lt;/div&amp;gt;. If the attacker's data gets placed into the data context, they might break out like this &amp;amp;lt;div&amp;gt;data &amp;amp;lt; script&amp;gt;alert(&amp;quot;attack&amp;quot;)&amp;lt;/script&amp;gt; context&amp;lt;/div&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
XSS is a form of injection where the interpreter is the browser and attacks are buried in an HTML document. HTML is easily the worst mashup of code and data of all time, as there are so many possible places to put code and so many different valid encodings. HTML is particularly difficult because it is not only hierarchical, but also contains many different parsers (XML, HTML, JavaScript, VBScript, CSS, URL, etc...).&lt;br /&gt;
&lt;br /&gt;
To really understand what's going on with XSS, you have to consider injection into the hierarchical structure of the [http://www.w3schools.com/HTMLDOM/default.asp HTML DOM]. Given a place to insert data into an HTML document (that is, a place where a developer has allowed untrusted data to be included in the DOM), there are two ways to inject code:&lt;br /&gt;
&lt;br /&gt;
;Injecting UP:The most common way is to close the current context and start a new code context.  For example, this is what you do when you close an HTML attribute with a &amp;quot;&amp;gt; and start a new &amp;amp;lt;script&amp;gt; tag. This attack closes the original context (going up in the hierarchy) and then starts a new tag that will allow script code to execute. Remember that you may be able to skip many layers up in the hierarchy when trying to break out of your current context. For example, a &amp;amp;lt;/script&amp;gt; tag may be able to terminate a script block even if it is injected inside a quoted string inside a method call inside the script. This happens because the HTML parser runs before the JavaScript parser.&lt;br /&gt;
&lt;br /&gt;
;Injecting DOWN:The less common way to perform XSS injection is to introduce a code subcontext without closing the current context. For example, if the attacker is able to change &amp;amp;lt;img src=&amp;quot;...UNTRUSTED DATA HERE...&amp;quot; /&amp;gt; into &amp;amp;lt; img src=&amp;quot;javascript:alert(document.cookie)&amp;quot; /&amp;gt; they do not have to break out of the HTML attribute context.  Instead, they introduce a subcontext that allows scripting within the src attribute (in this case a javascript url). Another example is the expression() functionality in CSS properties. Even though you may not be able to escape a quoted CSS property to inject up, you may be able to introduce something like xss:expression(document.write(document.cookie)) without ever leaving the current context.&lt;br /&gt;
&lt;br /&gt;
There's also the possibility of injecting directly in the current context. For example, if you take untrusted input and put it directly into a JavaScript context. While insane, accepting code from an attacker is more common than you might think in modern applications. Generally it is impossible to secure untrusted code with escaping (or anything else). If you do this, your application is just a conduit for attacker code to get running in your users' browsers.&lt;br /&gt;
&lt;br /&gt;
The rules in this document have been designed to prevent both UP and DOWN varieties of XSS injection. To prevent injecting up, you must escape the characters that would allow you to close the current context and start a new one. To prevent attacks that jump up several levels in the DOM hierarchy, you must also escape all the characters that are significant in all enclosing contexts.  To prevent injecting down, you must escape any characters that can be used to introduce a new sub-context within the current context.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== A Positive XSS Prevention Model ==&lt;br /&gt;
&lt;br /&gt;
This article treats an HTML page like a template, with slots where a developer is allowed to put untrusted data. These slots cover the vast majority of the common places where a developer might want to put untrusted data. Putting untrusted data in other places in the HTML is not allowed. This is a &amp;quot;whitelist&amp;quot; model, that denies everything that is not specifically allowed.&lt;br /&gt;
&lt;br /&gt;
Given the way browsers parse HTML, each of the different types of slots has slightly different security rules. When you put untrusted data into these slots, you need to take certain steps to make sure that the data does not break out of that slot into a context that allows code execution. In a way, this approach treats an HTML document like a parameterized database query - the data is kept in specific places and is isolated from code contexts with escaping.&lt;br /&gt;
&lt;br /&gt;
This document sets out the most common types of slots and the rules for putting untrusted data into them safely. Based on the various specifications, known XSS vectors, and a great deal of manual testing with all the popular browsers, we have determined that the rule proposed here are safe.&lt;br /&gt;
&lt;br /&gt;
The slots are defined and a few examples of each are provided. Developers SHOULD NOT put data into any other slots without a very careful analysis to ensure that what they are doing is safe. Browser parsing is extremely tricky and many innocuous looking characters can be significant in the right context.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why Can't I Just HTML Entity Encode Untrusted Data? ==&lt;br /&gt;
&lt;br /&gt;
HTML entity encoding is okay for untrusted data that you put in the body of the HTML document, such as inside a &amp;amp;lt;div&amp;gt; tag.  It even sort of works for untrusted data that goes into attributes, particularly if you're religious about using quotes around your attributes.  But HTML entity encoding doesn't work if you're putting untrusted data inside a &amp;amp;lt;script&amp;gt; tag anywhere, or an event handler attribute like onmouseover, or inside CSS, or in a URL.  So even if you use an HTML entity encoding method everywhere, you are still most likely vulnerable to XSS.  '''You MUST use the escape syntax for the part of the HTML document you're putting untrusted data into.'''  That's what the rules below are all about.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== You Need a Security Encoding Library ==&lt;br /&gt;
&lt;br /&gt;
Writing these encoders is not tremendously difficult, but there are quite a few hidden pitfalls. For example, you might be tempted to use some of the escaping shortcuts like \&amp;quot; in JavaScript. However, these values are dangerous and may be misinterpreted by the nested parsers in the browser. You might also forget to escape the escape character, which attackers can use to neutralize your attempts to be safe. OWASP recommends using a security-focused encoding library to make sure these rules are properly implemented.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library in a variety of languages including Java, .NET, PHP, Classic ASP, Cold Fusion, Python, and Haskell. The ESAPI library can be used for escaping as described here and also for decoding (aka canonicalization), which is critical for input validation.  Microsoft provides an encoding library named [http://www.codeplex.com/AntiXSS AntiXSS].&lt;br /&gt;
&lt;br /&gt;
= XSS Prevention Rules = &lt;br /&gt;
&lt;br /&gt;
The following rules are intended to prevent all XSS in your application. While these rules do not allow absolute freedom in putting untrusted data into an HTML document, they should cover the vast majority of common use cases. You do not have to allow '''all''' the rules in your organization. Many organizations may find that '''allowing only Rule #1 and Rule #2 are sufficient for their needs'''. Please add a note to the discussion page if there is an additional context that is often required and can be secured with escaping.&lt;br /&gt;
&lt;br /&gt;
Do NOT simply escape the list of example characters provided in the various rules. It is NOT sufficient to escape only that list. Blacklist approaches are quite fragile.  The whitelist rules here have been carefully designed to provide protection even against future vulnerabilities introduced by browser changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RULE #0 - Never Insert Untrusted Data Except in Allowed Locations ==&lt;br /&gt;
&lt;br /&gt;
The first rule is to '''deny all''' - don't put untrusted data into your HTML document unless it is within one of the slots defined in Rule #1 through Rule #5. The reason for Rule #0 is that there are so many strange contexts within HTML that the list of escaping rules gets very complicated. We can't think of any good reason to put untrusted data in these contexts.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/script&amp;gt;   directly in a script&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;!--'''...NEVER PUT UNTRUSTED DATA HERE...'''--&amp;gt;             inside an HTML comment&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;div '''...NEVER PUT UNTRUSTED DATA HERE...'''=test /&amp;gt;       in an attribute name&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;'''NEVER PUT UNTRUSTED DATA HERE...''' href=&amp;quot;/test&amp;quot; /&amp;gt;   in a tag name&lt;br /&gt;
&lt;br /&gt;
Most importantly, never accept actual JavaScript code from an untrusted source and then run it. For example, a parameter named &amp;quot;callback&amp;quot; that contains a JavaScript code snippet.  No amount of escaping can fix that.&lt;br /&gt;
&lt;br /&gt;
== RULE #1 - HTML Escape Before Inserting Untrusted Data into HTML Element Content ==&lt;br /&gt;
&lt;br /&gt;
Rule #1 is for when you want to put untrusted data directly into the HTML body somewhere. This includes inside normal tags like div, p, b, td, etc. Most web frameworks have a method for HTML escaping for the characters detailed below. However, this is '''absolutely not sufficient for other HTML contexts.'''  You need to implement the other rules detailed here as well.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;body&amp;gt;'''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;lt;/body&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;div&amp;gt;'''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;lt;/div&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  any other normal HTML elements&lt;br /&gt;
&lt;br /&gt;
Escape the following characters with HTML entity encoding to prevent switching into any execution context, such as script, style, or event handlers. Using hex entities is recommended in the spec. In addition to the 5 characters significant in XML (&amp;amp;, &amp;lt;, &amp;gt;, &amp;quot;, '), the forward slash is included as it helps to end an HTML entity.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp; --&amp;gt; &amp;amp;amp;amp;&lt;br /&gt;
  &amp;lt; --&amp;gt; &amp;amp;amp;lt;&lt;br /&gt;
  &amp;gt; --&amp;gt; &amp;amp;amp;gt;&lt;br /&gt;
  &amp;quot; --&amp;gt; &amp;amp;amp;quot;&lt;br /&gt;
  ' --&amp;gt; &amp;amp;amp;#x27;     &amp;amp;apos; is not recommended&lt;br /&gt;
  / --&amp;gt; &amp;amp;amp;#x2F;     forward slash is included as it helps end an HTML entity&lt;br /&gt;
&lt;br /&gt;
See the [http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/codecs/HTMLEntityCodec.java ESAPI reference implementation] of HTML entity escaping and unescaping.&lt;br /&gt;
&lt;br /&gt;
  String safe = ESAPI.encoder().encodeForHTML( request.getParameter( &amp;quot;input&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes ==&lt;br /&gt;
&lt;br /&gt;
Rule #2 is for putting untrusted data into typical attribute values like width, name, value, etc. This should not be used for complex attributes like href, src, style, or any of the event handlers like onmouseover.  It is extremely important that event handler attributes should follow Rule #3 for HTML JavaScript Data Values.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;div attr='''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;gt;content&amp;lt;/div&amp;gt;     inside UNquoted attribute&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;div attr=''''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...''''&amp;gt;content&amp;lt;/div&amp;gt;   inside single quoted attribute&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;div attr=&amp;quot;'''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;quot;&amp;gt;content&amp;lt;/div&amp;gt;   inside double quoted attribute&lt;br /&gt;
&lt;br /&gt;
Except for alphanumeric characters, escape all characters with ASCII values less than 256 with the &amp;amp;amp;#xHH; format (or a named entity if available) to prevent switching out of the attribute. The reason this rule is so broad is that developers frequently leave attributes unquoted.  Properly quoted attributes can only be escaped with the corresponding quote. Unquoted attributes can be broken out of with many characters, including [space] % * + , - / ; &amp;lt; = &amp;gt; ^ and |.&lt;br /&gt;
&lt;br /&gt;
See the [http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/codecs/HTMLEntityCodec.java ESAPI reference implementation] of HTML entity escaping and unescaping.&lt;br /&gt;
&lt;br /&gt;
  String safe = ESAPI.encoder().encodeForHTMLAttribute( request.getParameter( &amp;quot;input&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns the JavaScript event handlers that are specified on various HTML elements. The only safe place to put untrusted data into these event handlers as a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other code block is quite dangerous, as it is very easy to switch into an execution context, so use with caution.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;alert(''''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''')&amp;amp;lt;/script&amp;gt;     inside a quoted string&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;script&amp;gt;x=''''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...''''&amp;amp;lt;/script&amp;gt;          one side of a quoted expression&lt;br /&gt;
  &lt;br /&gt;
  &amp;amp;lt;div onmouseover=&amp;quot;x=''''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...''''&amp;quot;&amp;amp;lt;/div&amp;gt;  inside quoted event handler&lt;br /&gt;
&lt;br /&gt;
Please note there are some JavaScript functions that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF JAVASCRIPT ESCAPED&amp;lt;/b&amp;gt;! &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
  window.setInterval(''''...EVEN IF YOU ESCAPE UNTRUSTED DATA YOU ARE XSSED HERE...'''');&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Except for alphanumeric characters, escape all characters less than 256 with the \xHH format to prevent switching out of the data value into the script context or into another attribute. Do not use any escaping shortcuts like \&amp;quot; because the quote character may be matched by the HTML attribute parser which runs first.  If an event handler is quoted, breaking out requires the corresponding quote. The reason this rule is so broad is that developers frequently leave event handler attributes unquoted.  Properly quoted attributes can only be escaped with the corresponding quote. Unquoted attributes can be broken out of with many characters including [space] % * + , - / ; &amp;lt; = &amp;gt; ^ and |. Also, a &amp;lt;/script&amp;gt; closing tag will close a script block even though it is inside a quoted string because the HTML parser runs before the JavaScript parser.&lt;br /&gt;
&lt;br /&gt;
See the [http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/codecs/JavaScriptCodec.java ESAPI reference implementation] of JavaScript escaping and unescaping.&lt;br /&gt;
&lt;br /&gt;
  String safe = ESAPI.encoder().encodeForJavaScript( request.getParameter( &amp;quot;input&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #4 is for when you want to put untrusted data into a stylesheet or a style tag. CSS is surprisingly powerful, and can be used for numerous attacks. Therefore, it's important that you only use untrusted data in a property '''value''' and not into other places in style data. You should stay away from putting untrusted data into complex properties like url, behavior, and custom (-moz-binding). You should also not put untrusted data into IE’s expression property value which allows JavaScript.&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;style&amp;gt;selector { property : '''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''; } &amp;amp;lt;/style&amp;gt;     property value&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;amp;lt;style&amp;gt;selector { property : &amp;amp;quot;'''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;amp;quot;; } &amp;amp;lt;/style&amp;gt;   property value&amp;lt;br/&amp;gt;&lt;br /&gt;
  &amp;amp;lt;span style=&amp;amp;quot;property : '''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...'''&amp;amp;quot;&amp;gt;text&amp;amp;lt;/style&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Except for alphanumeric characters, escape all characters with ASCII values less than 256 with the \HH escaping format. Do not use any escaping shortcuts like \&amp;quot; because the quote character may be matched by the HTML attribute parser which runs first. Prevent switching out of the property value and into another property or attribute. Also prevent switching into an expression or other property value that allows scripting. If attribute is quoted, breaking out requires the corresponding quote.  All attributes should be quoted but your encoding should be strong enough to prevent XSS when untrusted data is placed in unquoted contexts. Unquoted attributes can be broken out of with many characters including [space] % * + , - / ; &amp;lt; = &amp;gt; ^ and |.  Also, the &amp;lt;/style&amp;gt; tag will close the style block even though it is inside a quoted string because the HTML parser runs before the JavaScript parser. Please note that we recommend aggressive CSS encoding to prevent XSS attacks for both quoted and unquoted attributes.&lt;br /&gt;
&lt;br /&gt;
See the [http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/codecs/CSSCodec.java ESAPI reference implementation] of CSS escaping and unescaping.&lt;br /&gt;
&lt;br /&gt;
  String safe = ESAPI.encoder().encodeForCSS( request.getParameter( &amp;quot;input&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
== RULE #5 - URL Escape Before Inserting Untrusted Data into HTML URL Parameter Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #5 is for when you want to put untrusted data into HTTP GET parameter value. &lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;a href=&amp;quot;http&amp;amp;#x3a;&amp;amp;#x2f;&amp;amp;#x2f;www.somesite.com&amp;amp;#x3f;test&amp;amp;#x3d;'''...ESCAPE UNTRUSTED DATA BEFORE PUTTING HERE...&amp;quot;'''&amp;gt;link&amp;amp;lt;/a &amp;gt;       &lt;br /&gt;
&lt;br /&gt;
Except for alphanumeric characters, escape all characters with ASCII values less than 256 with the %HH escaping format.  Including untrusted data in data: URLs should not be allowed as there is no good way to disable attacks with escaping to prevent switching out of the URL. All attributes should be quoted. Unquoted attributes can be broken out of with many characters including [space] % * + , - / ; &amp;lt; = &amp;gt; ^ and |. Note that entity encoding is useless in this context.&lt;br /&gt;
&lt;br /&gt;
See the [http://code.google.com/p/owasp-esapi-java/source/browse/trunk/src/main/java/org/owasp/esapi/codecs/PercentCodec.java ESAPI reference implementation] of URL escaping and unescaping.&lt;br /&gt;
&lt;br /&gt;
  String safe = ESAPI.encoder().encodeForURL( request.getParameter( &amp;quot;input&amp;quot; ) );&lt;br /&gt;
&lt;br /&gt;
WARNING: Do not encode complete or relative URL's with URL encoding! If untrusted input is meant to be placed into href, src or other URL-based attributes, it should be validated to make sure it does not point to an unexpected protocol, especially Javascript links. URL's should then be encoded based on the context of display like any other piece of data. For example, user driven URL's in HREF links should be attribute encoded. For example:&lt;br /&gt;
&lt;br /&gt;
  String userURL = request.getParameter( &amp;quot;userURL&amp;quot; )&lt;br /&gt;
  boolean isValidURL = ESAPI.validator().isValidInput(&amp;quot;URLContext&amp;quot;, userURL, &amp;quot;URL&amp;quot;, 255, false); &lt;br /&gt;
  if (isValidURL) {  &lt;br /&gt;
      &amp;lt;a href=&amp;quot;&amp;lt;%=encoder.encodeForHTMLAttribute(userURL)%&amp;gt;&amp;quot;&amp;gt;link&amp;lt;/a&amp;gt;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== RULE #6 - Use an HTML Policy engine to validate or clean user-driven HTML in an outbound way ==&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.validator.html.*;&lt;br /&gt;
   Policy policy = Policy.getInstance(POLICY_FILE_LOCATION);&lt;br /&gt;
   AntiSamy as = new AntiSamy();&lt;br /&gt;
   CleanResults cr = as.scan(dirtyInput, policy);&lt;br /&gt;
   MyUserDAO.storeUserProfile(cr.getCleanHTML()); // some custom function&lt;br /&gt;
&lt;br /&gt;
== RULE #7 - Prevent DOM-based XSS  ==&lt;br /&gt;
&lt;br /&gt;
For details on what DOM-based XSS is, and defenses against this type of XSS flaw, please see the OWASP article on [[DOM_Based_XSS | DOM-based XSS]].&lt;br /&gt;
&lt;br /&gt;
= Encoding Information =&lt;br /&gt;
[&lt;br /&gt;
http://code.google.com/p/owasp-development-guide/wiki/WebAppSecDesignGuide_D6]&lt;br /&gt;
&lt;br /&gt;
= Additional XSS Defense (HTTPOnly cookie flag)=&lt;br /&gt;
&lt;br /&gt;
Preventing all XSS flaws in an application is hard, as you can see. To help mitigate the impact of an XSS flaw on your site, OWASP also recommends you set the HTTPOnly flag on your session cookie and any custom cookies you have that are not accessed by any Javascript you wrote. This cookie flag is typically on by default in .NET apps, but in other languages you have to set it manually.&lt;br /&gt;
&lt;br /&gt;
For more details on the HTTPOnly cookie flag, including what it does, and how to use it, see the OWASP article on [[HTTPOnly]].&lt;br /&gt;
&lt;br /&gt;
=Related Articles=&lt;br /&gt;
&lt;br /&gt;
'''XSS Attack Cheat Sheet'''&lt;br /&gt;
&lt;br /&gt;
The following article describes how to exploit different kinds of XSS Vulnerabilities that this article was created to help you avoid:&lt;br /&gt;
&lt;br /&gt;
* RSnake: &amp;quot;XSS Cheat Sheet&amp;quot; - http://ha.ckers.org/xss.html&lt;br /&gt;
&lt;br /&gt;
'''Description of XSS Vulnerabilities'''&lt;br /&gt;
&lt;br /&gt;
* OWASP article on [[XSS]] Vulnerabilities&lt;br /&gt;
&lt;br /&gt;
'''How to Review Code for Cross-site scripting Vulnerabilities'''&lt;br /&gt;
&lt;br /&gt;
* [[:Category:OWASP Code Review Project|OWASP Code Review Guide]] article on [[Reviewing Code for Cross-site scripting]] Vulnerabilities&lt;br /&gt;
&lt;br /&gt;
'''How to Test for Cross-site scripting  Vulnerabilities'''&lt;br /&gt;
&lt;br /&gt;
* [[:Category:OWASP Testing Project|OWASP Testing Guide]] article on [[Testing for Cross site scripting]] Vulnerabilities&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim[at]manico.net &lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Application Security Verification Standard Project]]&lt;br /&gt;
[[Category:OWASP Enterprise Security API]]&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Hendrik Brummermann</name></author>	</entry>

	</feed>