<?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=Nmatatal</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=Nmatatal"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Nmatatal"/>
		<updated>2026-04-21T05:07:08Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Content_Security_Policy_Cheat_Sheet&amp;diff=193037</id>
		<title>Content Security Policy Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Content_Security_Policy_Cheat_Sheet&amp;diff=193037"/>
				<updated>2015-04-09T19:04:35Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content Security Policy (CSP) is an important standard by the W3C that is aimed to prevent a broad range of content injection attacks such as cross-site scripting (XSS). &lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Content Security Policy (CSP) is an effective &amp;quot;defense in depth&amp;quot; technique to be used against content injection attacks. It is a declarative policy that informs the user agent what are valid sources to load from.&lt;br /&gt;
&lt;br /&gt;
Since, it was introduced in Firefox version 4 by Mozilla, it has been adopted as a standard, and grown in adoption and capabilities.&lt;br /&gt;
&lt;br /&gt;
This document is meant to provide guidance on how to utilize CSP under a variety of situations to address a variety of concerns.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Specifications of the CSP standard can be found the following locations:&lt;br /&gt;
* Latest Revision - https://w3c.github.io/webappsec/specs/content-security-policy/&lt;br /&gt;
* Latest Version (CSP2) - http://www.w3.org/TR/CSP2/&lt;br /&gt;
* CSP 1.0 - http://www.w3.org/TR/2012/CR-CSP-20121115/&lt;br /&gt;
&lt;br /&gt;
= CSP Basics =&lt;br /&gt;
&lt;br /&gt;
CSP consists of a series of directives. CSP has also evolved over two major revisions. Most browsers support 1.0, and adoption of CSP2 has been incremental.&lt;br /&gt;
&lt;br /&gt;
== HTTP Headers ==&lt;br /&gt;
&lt;br /&gt;
The following are headers for CSP.&lt;br /&gt;
&lt;br /&gt;
* '''Content-Security-Policy''' : W3C Spec standard header. Supported by Firefox 23+, Chrome 25+ and Opera 19+&lt;br /&gt;
* '''Content-Security-Policy-Report-Only''' : W3C Spec standard header. Supported by Firefox 23+, Chrome 25+ and Opera 19+, whereby the policy is non-blocking (&amp;quot;fail open&amp;quot;) and a report is sent to the URL designated by the '''report-uri''' directive. This is often used as a precursor to utilizing CSP in blocking mode (&amp;quot;fail closed&amp;quot;)&lt;br /&gt;
* '''DO NOT''' use X-Content-Security-Policy or X-WebKit-CSP. Their implementations are obsolete (since Firefox 23, Chrome 25), limited, inconsistent, and incredibly buggy.&lt;br /&gt;
&lt;br /&gt;
== Directives == &lt;br /&gt;
&lt;br /&gt;
The following is a listing of directives, and a brief description.&lt;br /&gt;
&lt;br /&gt;
=== CSP 1.0 Spec ===&lt;br /&gt;
* '''connect-src''' (d) - restricts which URLs the protected resource can load using script interfaces. (e.g.  send() method of an XMLHttpRequest object) &lt;br /&gt;
* '''font-src''' (d) - restricts from where the protected resource can load fonts&lt;br /&gt;
* '''img-src''' (d) - restricts from where the protected resource can load images&lt;br /&gt;
* '''media-src''' (d) -  restricts from where the protected resource can load video, audio, and associated text tracks&lt;br /&gt;
* '''object-src''' (d) - restricts from where the protected resource can load plugins&lt;br /&gt;
* '''script-src''' (d) -  restricts which scripts the protected resource can execute. Additional restrictions against, inline scripts, and eval. Additional directives in CSP2 for hash and nonce support&lt;br /&gt;
* '''style-src''' (d) - restricts which styles the user may applies to the protected resource. Additional restrictions against inline and eval.&lt;br /&gt;
* '''default-src''' - Covers any directive with ''(d)''&lt;br /&gt;
* '''frame-src''' - restricts from where the protected resource can embed frames. Note, deprecated in CSP2&lt;br /&gt;
* '''report-uri''' - specifies a URL to which the user agent sends reports about policy violation&lt;br /&gt;
* '''sandbox''' - specifies an HTML sandbox policy that the user agent applies to the protected resource. Optional in 1.0&lt;br /&gt;
&lt;br /&gt;
=== New in CSP2 ===&lt;br /&gt;
* '''form-action''' - retricts which URLs can be used as the action of HTML form elements&lt;br /&gt;
* '''frame-ancestors''' - indicates whether the user agent should allow embedding the resource using a frame, iframe, object, embed or applet element, or equivalent functionality in non-HTML resources&lt;br /&gt;
* '''plugin-types''' - restricts the set of plugins that can be invoked by the protected resource by limiting the types of resources that can be embedded&lt;br /&gt;
* '''base-uri''' -  restricts the URLs that can be used to specify the document base URL&lt;br /&gt;
* '''child-src''' (d) -  governs the creation of nested browsing contexts as well as Worker execution contexts&lt;br /&gt;
&lt;br /&gt;
= CSP Sample Policies =&lt;br /&gt;
&lt;br /&gt;
== Basic CSP Policy ==&lt;br /&gt;
&lt;br /&gt;
This policy will only allow resources from the originating domain for all the default level directives, and will not allow inline scripts/styles to execute. If your application and function with these restrictions, it drastically reduces your attack surface having this policy in place, and will work with most modern browsers.&lt;br /&gt;
&lt;br /&gt;
The most basic policy assumes:&lt;br /&gt;
* all resources are hosted by the same domain of the document&lt;br /&gt;
* there are no inlines or evals for scripts and style resources&lt;br /&gt;
&lt;br /&gt;
  Content-Security-Policy: default-src 'self' &lt;br /&gt;
&lt;br /&gt;
To tighten further, one can do the following:&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';&lt;br /&gt;
&lt;br /&gt;
This policy allows images, scripts, AJAX, and CSS from the same origin, and does not allow any other resources to load (eg. object, frame, media, etc). (see http://content-security-policy.com/)&lt;br /&gt;
&lt;br /&gt;
== Mixed Content Policy ==&lt;br /&gt;
&lt;br /&gt;
In order to prevent mixed content (resources being loaded over http, from a document loaded over https), one can use the value &amp;quot;https:&amp;quot; as a directive value.&lt;br /&gt;
&lt;br /&gt;
For instance:&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: default-src https:; connect-src https:; font-src https: data:; frame-src https:; &lt;br /&gt;
 img-src https: data:; media-src https:;  object-src https:; script-src 'unsafe-inline' 'unsafe-eval' https:; &lt;br /&gt;
 style-src 'unsafe-inline' https:;&lt;br /&gt;
&lt;br /&gt;
This is what was used at Twitter, Oct 2014. The policy prevents mixed content, allows for scheme &amp;quot;data:&amp;quot; in font-src and img-src, allows for unsafe-inline and unsafe-eval for script-src, and unsafe-inline for style-src. (see: https://twittercommunity.com/t/blocking-mixed-content-with-content-security-policy/26375)&lt;br /&gt;
&lt;br /&gt;
Mixed Content has two categories: Active and Passive. Passive content consists of &amp;quot;resources which cannot directly interact with or modify other resources on a page: images, fonts, audio, and video for example&amp;quot;, whereas active content is &amp;quot;content which can in some way directly manipulate the resource with which a user is interacting.&amp;quot;  (http://www.w3.org/TR/2014/WD-mixed-content-20140722)&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: img-src https: data:; font-src https: data:; media-src https:;&lt;br /&gt;
&lt;br /&gt;
This is an example to block only passive mixed content.&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: script-src https:; style-src https:; object-src https:; connect-src https:; frame-src https:; &lt;br /&gt;
&lt;br /&gt;
This is an example to block only active mixed content.&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Neil Mattatall - neil[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Denis Mello - ddtaxe&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Content_Security_Policy_Cheat_Sheet&amp;diff=193036</id>
		<title>Content Security Policy Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Content_Security_Policy_Cheat_Sheet&amp;diff=193036"/>
				<updated>2015-04-09T19:02:52Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content Security Policy (CSP) is an important standard by the W3C that is aimed to prevent a broad range of content injection attacks such as cross-site scripting (XSS). &lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Content Security Policy (CSP) is an effective &amp;quot;defense in depth&amp;quot; technique to be used against content injection attacks. It is a declarative policy that informs the user agent what are valid sources to load from.&lt;br /&gt;
&lt;br /&gt;
Since, it was introduced in Firefox version 4 by Mozilla, it has been adopted as a standard, and grown in adoption and capabilities.&lt;br /&gt;
&lt;br /&gt;
This document is meant to provide guidance on how to utilize CSP under a variety of situations to address a variety of concerns.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
Specifications of the CSP standard can be found the following locations:&lt;br /&gt;
* Latest Revision - https://w3c.github.io/webappsec/specs/content-security-policy/&lt;br /&gt;
* Latest Version (CSP2) - http://www.w3.org/TR/CSP2/&lt;br /&gt;
* CSP 1.0 - http://www.w3.org/TR/2012/CR-CSP-20121115/&lt;br /&gt;
&lt;br /&gt;
= CSP Basics =&lt;br /&gt;
&lt;br /&gt;
CSP consists of a series of directives. CSP has also evolved over two major revisions. Most browsers support 1.0, and adoption of CSP2 has been incremental.&lt;br /&gt;
&lt;br /&gt;
== HTTP Headers ==&lt;br /&gt;
&lt;br /&gt;
The following are headers for CSP.&lt;br /&gt;
&lt;br /&gt;
* '''Content-Security-Policy''' : W3C Spec standard header. Supported by Firefox 23+, Chrome 25+ and Opera 19+&lt;br /&gt;
* '''Content-Security-Policy-Report-Only''' : W3C Spec standard header. Supported by Firefox 23+, Chrome 25+ and Opera 19+, whereby the policy is non-blocking (&amp;quot;fail open&amp;quot;) and a report is sent to the URL designated by the '''report-uri''' directive. This is often used as a precursor to utilizing CSP in blocking mode (&amp;quot;fail closed&amp;quot;)&lt;br /&gt;
* '''DO NOT''' use X-Content-Security-Policy or X-WebKit-CSP. Their implementations are obsolete (since Firefox 23, Chrome 25), limited, inconsistent, and incredibly buggy.&lt;br /&gt;
&lt;br /&gt;
== Directives == &lt;br /&gt;
&lt;br /&gt;
The following is a listing of directives, and a brief description.&lt;br /&gt;
&lt;br /&gt;
=== CSP 1.0 Spec ===&lt;br /&gt;
* '''connect-src''' (d) - restricts which URLs the protected resource can load using script interfaces. (e.g.  send() method of an XMLHttpRequest object) &lt;br /&gt;
* '''font-src''' (d) - restricts from where the protected resource can load fonts&lt;br /&gt;
* '''img-src''' (d) - restricts from where the protected resource can load images&lt;br /&gt;
* '''media-src''' (d) -  restricts from where the protected resource can load video, audio, and associated text tracks&lt;br /&gt;
* '''object-src''' (d) - restricts from where the protected resource can load plugins&lt;br /&gt;
* '''script-src''' (d) -  restricts which scripts the protected resource can execute. Additional restrictions against, inline scripts, and eval. Additional directives in CSP2 for hash and nonce support&lt;br /&gt;
* '''style-src''' (d) - restricts which styles the user may applies to the protected resource. Additional restrictions against inline and eval.&lt;br /&gt;
* '''default-src''' - Covers any directive with ''(d)''&lt;br /&gt;
* '''frame-src''' - restricts from where the protected resource can embed frames. Note, deprecated in CSP2&lt;br /&gt;
* '''report-uri''' - specifies a URL to which the user agent sends reports about policy violation&lt;br /&gt;
* '''sandbox''' - specifies an HTML sandbox policy that the user agent applies to the protected resource. Optional in 1.0&lt;br /&gt;
&lt;br /&gt;
=== New in CSP2 ===&lt;br /&gt;
* '''form-action''' - retricts which URLs can be used as the action of HTML form elements&lt;br /&gt;
* '''frame-ancestors''' - indicates whether the user agent should allow embedding the resource using a frame, iframe, object, embed or applet element, or equivalent functionality in non-HTML resources&lt;br /&gt;
* '''plugin-types''' - restricts the set of plugins that can be invoked by the protected resource by limiting the types of resources that can be embedded&lt;br /&gt;
* '''base-uri''' -  restricts the URLs that can be used to specify the document base URL&lt;br /&gt;
* '''child-src''' (d) -  governs the creation of nested browsing contexts as well as Worker execution contexts&lt;br /&gt;
&lt;br /&gt;
= CSP Sample Policies =&lt;br /&gt;
&lt;br /&gt;
== Basic CSP Policy ==&lt;br /&gt;
&lt;br /&gt;
This policy will only allow resources from the originating domain for all the default level directives, and will not allow inline scripts/styles to execute. If your application and function with these restrictions, it drastically reduces your attack surface having this policy in place, and will work with most modern browsers.&lt;br /&gt;
&lt;br /&gt;
The most basic policy assumes:&lt;br /&gt;
* all resources are hosted by the same domain of the document&lt;br /&gt;
* there are no inlines or evals for scripts and style resources&lt;br /&gt;
&lt;br /&gt;
  Content-Security-Policy: default-src 'self' &lt;br /&gt;
&lt;br /&gt;
To tighten further, one can do the following:&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';&lt;br /&gt;
&lt;br /&gt;
This policy allows images, scripts, AJAX, and CSS from the same origin, and does not allow any other resources to load (eg. object, frame, media, etc). (see http://content-security-policy.com/)&lt;br /&gt;
&lt;br /&gt;
== Mixed Content Policy ==&lt;br /&gt;
&lt;br /&gt;
In order to prevent mixed content (resources being loaded over http, from a document loaded over https), one can use the value &amp;quot;https:&amp;quot; as a directive value.&lt;br /&gt;
&lt;br /&gt;
For instance:&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: default-src https:; connect-src https:; font-src https: data:; frame-src https:; &lt;br /&gt;
 img-src https: data:; media-src https:;  object-src https:; script-src 'unsafe-inline' 'unsafe-eval' https:; &lt;br /&gt;
 style-src 'unsafe-inline' https:;&lt;br /&gt;
&lt;br /&gt;
This is what was used at Twitter, Oct 2014. The policy prevents mixed content, allows for scheme &amp;quot;data:&amp;quot; in font-src and img-src, allows for unsafe-inline and unsafe-eval for script-src, and unsafe-inline for style-src. (see: https://twittercommunity.com/t/blocking-mixed-content-with-content-security-policy/26375)&lt;br /&gt;
&lt;br /&gt;
Mixed Content has two categories: Active and Passive. Passive content consists of &amp;quot;resources which cannot directly interact with or modify other resources on a page: images, fonts, audio, and video for example&amp;quot;, whereas active content is &amp;quot;content which can in some way directly manipulate the resource with which a user is interacting.&amp;quot;  (http://www.w3.org/TR/2014/WD-mixed-content-20140722)&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: img-src https: data:; font-src https: data:; media-src https:;&lt;br /&gt;
&lt;br /&gt;
This is an example to block only passive mixed content.&lt;br /&gt;
&lt;br /&gt;
 Content-Security-Policy: script-src https:; style-src https:; object-src https:; connect-src https:; frame-src https:; &lt;br /&gt;
&lt;br /&gt;
This is an example to block only active mixed content.&lt;br /&gt;
&lt;br /&gt;
= CSP Cheat Sheet - Guide for main technologies =&lt;br /&gt;
&lt;br /&gt;
This section summarizes the implementation and/or support for CSP in different technologies (either acting as Client or Server).&lt;br /&gt;
See below the details.&lt;br /&gt;
&lt;br /&gt;
'''Google Chrome'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Google Chrome based web applications and theme uses a manifest file named manifest.json.&lt;br /&gt;
There is a section in the manifest file where the developer can declare the CSP directives.&lt;br /&gt;
For further details, please refer to Content Security Police for Google Chrome.&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
  ''// Required''&lt;br /&gt;
  &amp;quot;manifest_version&amp;quot;: 2,&lt;br /&gt;
  &amp;quot;name&amp;quot;: &amp;quot;My Extension&amp;quot;,&lt;br /&gt;
  &amp;quot;version&amp;quot;: &amp;quot;versionString&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  ''// Recommended''&lt;br /&gt;
  &amp;quot;default_locale&amp;quot;: &amp;quot;en&amp;quot;,&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;A plain text description&amp;quot;,&lt;br /&gt;
  &amp;quot;icons&amp;quot;: {...},&lt;br /&gt;
&lt;br /&gt;
  ''// Pick one (or none)''&lt;br /&gt;
  &amp;quot;browser_action&amp;quot;: {...},&lt;br /&gt;
  &amp;quot;page_action&amp;quot;: {...},&lt;br /&gt;
&lt;br /&gt;
  ''// Optional''&lt;br /&gt;
  &amp;quot;author&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;automation&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;background&amp;quot;: {&lt;br /&gt;
    // Recommended&lt;br /&gt;
    &amp;quot;persistent&amp;quot;: false&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;background_page&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;chrome_settings_overrides&amp;quot;: {...},&lt;br /&gt;
  &amp;quot;chrome_ui_overrides&amp;quot;: {&lt;br /&gt;
    &amp;quot;bookmarks_ui&amp;quot;: {&lt;br /&gt;
      &amp;quot;remove_bookmark_shortcut&amp;quot;: true,&lt;br /&gt;
      &amp;quot;remove_button&amp;quot;: true&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;chrome_url_overrides&amp;quot;: {...},&lt;br /&gt;
  &amp;quot;commands&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;content_pack&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;content_scripts&amp;quot;: [{...}],&lt;br /&gt;
  &amp;quot;content_security_policy&amp;quot;: &amp;quot;policyString&amp;quot;,&lt;br /&gt;
  &amp;quot;converted_from_user_script&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;current_locale&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;devtools_page&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;externally_connectable&amp;quot;: {&lt;br /&gt;
    &amp;quot;matches&amp;quot;: [&amp;quot;*://*.example.com/*&amp;quot;]&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;file_browser_handlers&amp;quot;: [...],&lt;br /&gt;
  &amp;quot;homepage_url&amp;quot;: &amp;quot;http://path/to/homepage&amp;quot;,&lt;br /&gt;
  &amp;quot;import&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;incognito&amp;quot;: &amp;quot;spanning or split&amp;quot;,&lt;br /&gt;
  &amp;quot;input_components&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;key&amp;quot;: &amp;quot;publicKey&amp;quot;,&lt;br /&gt;
  &amp;quot;minimum_chrome_version&amp;quot;: &amp;quot;versionString&amp;quot;,&lt;br /&gt;
  &amp;quot;nacl_modules&amp;quot;: [...],&lt;br /&gt;
  &amp;quot;oauth2&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;offline_enabled&amp;quot;: true,&lt;br /&gt;
  &amp;quot;omnibox&amp;quot;: {&lt;br /&gt;
    &amp;quot;keyword&amp;quot;: &amp;quot;aString&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;optional_permissions&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;options_page&amp;quot;: &amp;quot;aFile.html&amp;quot;,&lt;br /&gt;
  &amp;quot;options_ui&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;page_actions&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;permissions&amp;quot;: [...],&lt;br /&gt;
  &amp;quot;platforms&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;plugins&amp;quot;: [...],&lt;br /&gt;
  &amp;quot;requirements&amp;quot;: {...},&lt;br /&gt;
  &amp;quot;sandbox&amp;quot;: [...],&lt;br /&gt;
  &amp;quot;script_badge&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;short_name&amp;quot;: &amp;quot;Short Name&amp;quot;,&lt;br /&gt;
  &amp;quot;signature&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;spellcheck&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;storage&amp;quot;: {&lt;br /&gt;
    &amp;quot;managed_schema&amp;quot;: &amp;quot;schema.json&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;system_indicator&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;tts_engine&amp;quot;: ...,&lt;br /&gt;
  &amp;quot;update_url&amp;quot;: &amp;quot;http://path/to/updateInfo.xml&amp;quot;,&lt;br /&gt;
  &amp;quot;web_accessible_resources&amp;quot;: [...]}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Apache'''&lt;br /&gt;
&lt;br /&gt;
It is required to add lines to the httpd.conf configuration file, or inside .htaccess files or virtual host sections.&lt;br /&gt;
Also, it is required to enable mod_headers, and after inserting the lines according to your specific needs, restart Apache.&lt;br /&gt;
The headers below are good examples to add in the files (change/modify it properly):&lt;br /&gt;
&lt;br /&gt;
Header unset Content-Security-Policy &lt;br /&gt;
Header add Content-Security-Policy &amp;quot;default-src 'self'&amp;quot; &lt;br /&gt;
Header unset X-Content-Security-Policy &lt;br /&gt;
Header add X-Content-Security-Policy &amp;quot;default-src 'self'&amp;quot; &lt;br /&gt;
Header unset X-WebKit-CSP Header add X-WebKit-CSP &amp;quot;default-src 'self'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''WordPress'''&lt;br /&gt;
&lt;br /&gt;
Most of the configuration can be done in Apache, however, Wordpress has a plugin that allows developers/administrator to set up their own custom policies. The plugin however is not update for 2 years. Use it carefully.&lt;br /&gt;
A workaround can be the creation or modification of the file htaccess under wp-admin directory.&lt;br /&gt;
&lt;br /&gt;
An example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;IfModule mod_headers.c&amp;gt; &lt;br /&gt;
Header set Content-Security-Policy &amp;quot;default-src 'self'; &lt;br /&gt;
img-src 'self' data: http: https: *.gravatar.com; &lt;br /&gt;
script-src 'self' 'unsafe-inline' 'unsafe-eval'; &lt;br /&gt;
style-src 'self' 'unsafe-inline' http: https: fonts.googleapis.com; &lt;br /&gt;
font-src 'self' data: http: https: fonts.googleapis.com themes.googleusercontent.com;&amp;quot; &lt;br /&gt;
&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''nginx'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;For nginx, it is required to edit the nginx.conf file. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# config to don't allow the browser to render the page inside an frame or iframe&lt;br /&gt;
&lt;br /&gt;
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking&lt;br /&gt;
&lt;br /&gt;
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri # https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options&lt;br /&gt;
add_header X-Frame-Options SAMEORIGIN;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,&lt;br /&gt;
&lt;br /&gt;
# to disable content-type sniffing on some browsers.&lt;br /&gt;
&lt;br /&gt;
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers&lt;br /&gt;
&lt;br /&gt;
# currently suppoorted in IE &amp;gt; 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx&lt;br /&gt;
&lt;br /&gt;
# http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx&lt;br /&gt;
&lt;br /&gt;
# 'soon' on Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=471020&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
# This header enables the Cross-site scripting (XSS) filter built into most recent web browsers.&lt;br /&gt;
&lt;br /&gt;
# It's usually enabled by default anyway, so the role of this header is to re-enable the filter for&lt;br /&gt;
&lt;br /&gt;
# this particular website if it was disabled by the user.&lt;br /&gt;
&lt;br /&gt;
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers&lt;br /&gt;
add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
# with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy),&lt;br /&gt;
&lt;br /&gt;
# you can tell the browser that it can only download content from the domains you explicitly allow&lt;br /&gt;
&lt;br /&gt;
# http://www.html5rocks.com/en/tutorials/security/content-security-policy/&lt;br /&gt;
&lt;br /&gt;
# https://www.owasp.org/index.php/Content_Security_Policy&lt;br /&gt;
&lt;br /&gt;
# I need to change our application code so we can increase security by disabling 'unsafe-inline' 'unsafe-eval'&lt;br /&gt;
&lt;br /&gt;
# directives for css and js(if you have inline css or js, you will need to keep it too).&lt;br /&gt;
&lt;br /&gt;
# more: http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful&lt;br /&gt;
add_header Content-Security-Policy &amp;quot;default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://example.com https://example1.com; style-src https://example.com; font-src https://example.com; frame-src https://example.com; object-src 'none'&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
server {&lt;br /&gt;
 listen 443 ssl default deferred;&lt;br /&gt;
 server_name .forgott.com;&lt;br /&gt;
 &lt;br /&gt;
 ssl_certificate the_path_of_your_certificate.crt;&lt;br /&gt;
 ssl_certificate_key the_path_of_your_key.key;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Django'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Django recently introduced a package with a number a collection of models, views and middlewares to aid secure Django based projects.&lt;br /&gt;
The installation of this model can be done through from Python packages repository: &lt;br /&gt;
pip install django-security&lt;br /&gt;
Also, the the latest development version, install from django-security repository on GitHub:&lt;br /&gt;
git clone https://github.com/sdelements/django-security.git&lt;br /&gt;
cd django-security&lt;br /&gt;
sudo python setup.py install&lt;br /&gt;
For each Djangon’s application, the settings.py file must be modified.&lt;br /&gt;
&lt;br /&gt;
== INSTALLED_APPS = (&lt;br /&gt;
    ...&lt;br /&gt;
    'security',&lt;br /&gt;
    ...&lt;br /&gt;
    )&lt;br /&gt;
 ==&lt;br /&gt;
&lt;br /&gt;
Middleware modules can be added to MIDDLEWARE_CLASSES list in settings file. Particularly, it is our interesting the ContentSecurityPolicyMiddleware. It sends Content Security Policy (CSP) header in HTTP response.:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== MIDDLEWARE_CLASSES = (&lt;br /&gt;
...&lt;br /&gt;
'security.middleware.DoNotTrackMiddleware',&lt;br /&gt;
 ==&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Neil Mattatall - neil[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Denis Mello - ddtaxe&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=AppSec_California_2015&amp;diff=182622</id>
		<title>AppSec California 2015</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=AppSec_California_2015&amp;diff=182622"/>
				<updated>2014-09-20T15:22:22Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Please visit https://2015.appseccalifornia.org/ for up to date info. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On January 26-28, 2015, AppSec California, the West Coast’s leading infosec event, will return for the second year in a row to the Annenberg Community Beach House in Santa Monica, California for three days of action-packed presentations and training sessions for IT and IT Security professionals, application developers and software security professionals. This event is a collaborative effort by the Los Angeles, Orange County, San Diego, Santa Barbara, and the Bay Area chapters of the Open Web Application Security Project (OWASP), and will feature many prominent speakers in a truly unique environment. The conference will be three days filled with multiple tracks, great networking, and a full day of hands-on training.&lt;br /&gt;
The first round of the call for speakers is currently open and will close on October 31, 2014. To submit a talk proposal, please visit: https://2015.appseccalifornia.org/&lt;br /&gt;
AppSec California will feature four outstanding keynote speakers including: Alex Stamos, CISO at Yahoo; John Steven, CTO at Cigital; Charlie Miller, Security Researcher at Twitter; and Katie Moussouris, Chief Policy Officer at HackerOne. Other confirmed speakers include: Parisa Tabriz (Google), Jim Manico (Manicode Security), Adrienne Porter (Google), Aaron Portnoy (Exodus Intelligence), Devdatta Akhawe (Dropbox), Jeff Williams (Contrast Security), Ping Yan (Salesforce), Zach Lanier (Duo Security), James Wickett (Signal Sciences Corp.), Kelly Lum (Tumblr), Ilja van Sprundel (IOActive), Russ Gidein (Attack Research), and Stenoplasma.&lt;br /&gt;
“Last year AppSec Cali had nearly 300 top information security attendees from California and across the globe take part in the inaugural event,” said Richard Greenberg, head of the AppSec Cali event. This year we plan to surpass that number, drawing even more senior executives, technical experts, information security practitioners and students to benefit from the information sharing and personal connections the event offers.”&lt;br /&gt;
The conference venue sits on 5-acres of oceanfront property with spectacular views of the Pacific Ocean. Attendees will be able to enjoy the various indoor and outdoor spaces, meeting with the leading information security practitioners, researchers, and developers in California.&lt;br /&gt;
Who Should Attend AppSec California? &lt;br /&gt;
    Application Developers&lt;br /&gt;
    Application Testers and Quality Assurance&lt;br /&gt;
    Application Project Management and Staff&lt;br /&gt;
    Chief Information Officers, Chief Information Security Officers, Chief Technology Officers, Deputies, Associates and Staff&lt;br /&gt;
    Chief Financial Officers, Auditors, and Staff Responsible for IT Security Oversight and Compliance&lt;br /&gt;
    Security Managers and Staff&lt;br /&gt;
    Executives, Managers, and Staff Responsible for IT Security Governance&lt;br /&gt;
    IT Professionals Interesting in Improving IT Security&lt;br /&gt;
Various sponsorship opportunities are available to allow all companies to gain exposure for their products and services. For more details on sponsoring this event, please visit: &lt;br /&gt;
https://2015.appseccalifornia.org/wp-content/uploads/2014/09/Sponsorship-Opportunities-09-07-2014.pdf&lt;br /&gt;
For more general event information, please visit the AppSec California 2015 website: &lt;br /&gt;
https://2015.appseccalifornia.org/&lt;br /&gt;
About OWASP: &lt;br /&gt;
The Open Web Application Security Project (OWASP) is a not-for-profit, worldwide organization focused on improving the security of application software. Its mission is to make application security visible, so that people and organizations can make informed decisions about true application security risks. Everyone is free to participate in OWASP and all of its materials are available under a free and open software license. OWASP is a new kind of organization. Its freedom from commercial pressures allows it to provide unbiased, practical, cost-effective information about application security. OWASP is not affiliated with any technology company, although it supports the informed use of commercial security technology.&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=WASPY_Awards_2014&amp;diff=180401</id>
		<title>WASPY Awards 2014</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=WASPY_Awards_2014&amp;diff=180401"/>
				<updated>2014-08-11T16:33:34Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:WASPY-BANNER-2014.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;6&amp;quot;&amp;gt;'''Web Application Security People of the Year Awards 2014'''&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every year a group of individuals including researchers, developers, security professionals and others work to ensure the security of web applications. Some of these individuals are featured in news stories or at conferences as recognized experts. But there are many other ‘unsung heroes’ that work every day to improve web application security and yet are rarely recognized. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Timeline'''==&lt;br /&gt;
&lt;br /&gt;
June 10 - Call for Nominees '''Now Open!''' Submit your nominee [http://www.tfaforms.com/284578 here]&lt;br /&gt;
&lt;br /&gt;
June 23 - Reminder Email Will be Sent For Call for Nominees&lt;br /&gt;
&lt;br /&gt;
June 30 - Call for Nominees Closes&lt;br /&gt;
&lt;br /&gt;
July 7 - Announcement of Nominees Per Category&lt;br /&gt;
&lt;br /&gt;
July 15 - Deadline For Profile Picture and Bio to be Submitted&lt;br /&gt;
&lt;br /&gt;
July 31 - Paid Membership Deadline - '''NOT SURE IF YOU ARE A CURRENT MEMBER?''' &lt;br /&gt;
&lt;br /&gt;
August 8 - Voting Opens&lt;br /&gt;
&lt;br /&gt;
August 26 - Voting Closes&lt;br /&gt;
&lt;br /&gt;
August 27 - Announcement of Winners&lt;br /&gt;
&lt;br /&gt;
September 16-19 - Awards Ceremony at AppSecUSA 2014 in Denver, CO&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''Categories'''==&lt;br /&gt;
&lt;br /&gt;
1. Best Chapter Leader - active chapter leader to be recognized for their contributions to the growth and organization of the chapter.&lt;br /&gt;
&lt;br /&gt;
2. Best Project Leader  - active project leader to be recognized for the development of their project.&lt;br /&gt;
&lt;br /&gt;
3. Best Mission Outreach - individual who contributed to the growth of the organization through outreach to the community. &lt;br /&gt;
&lt;br /&gt;
4. Best New Community Supporter &amp;quot;Rookie of the Year&amp;quot; - individual (no requirement to be a leader) who has contributed to any chapter, project,  initiative, or other OWASP activity.&lt;br /&gt;
&lt;br /&gt;
5. Best Platform Supporter - (OWASP Staff Vote) individual who positively contributes to the reinforcement of the OWASP platform.&lt;br /&gt;
&lt;br /&gt;
=='''Rules:==&lt;br /&gt;
&lt;br /&gt;
1. Board members can NOT be nominated&lt;br /&gt;
&lt;br /&gt;
2. Paid staff can NOT be nominated&lt;br /&gt;
&lt;br /&gt;
3. Must be a paid member to vote.&lt;br /&gt;
&lt;br /&gt;
4. All nominees will remain anonymous until July 7, 2014&lt;br /&gt;
&lt;br /&gt;
5. Anyone can nominate any individual&lt;br /&gt;
&lt;br /&gt;
6. One person per category may be nominated &lt;br /&gt;
&lt;br /&gt;
=='''Sponsorship Opportunities'''==&lt;br /&gt;
The support from our sponsors, is what makes these awards truly successful!  To learn more about how you can support these awards please see our [http://owasp.com/images/1/1a/2014_WASPY_Sponsorship_Doc.pdf '''Sponsorship Opportunities'''.]&lt;br /&gt;
&lt;br /&gt;
'''Become involved and support the WASPY Awards today!'''&lt;br /&gt;
&lt;br /&gt;
=='''And the Nominees Are...'''==&lt;br /&gt;
'''Categories:'''&lt;br /&gt;
&lt;br /&gt;
*Best Chapter Leader&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;150&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;120&amp;quot; | Chapter &lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; | Citation&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| [https://www.owasp.org/index.php/User:Riotaro_OKADA Riotaro OKADA] &amp;amp; [https://www.owasp.org/index.php/User:Sen_UENO Sen UENO ] Japan Chapter Leaders||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Japan Japan]||align=&amp;quot;center&amp;quot;|&amp;quot;The foundation of the OWASP Japan local chapter, its rapid growth to reaching over 2,000 participants in local chapter meetings in the first 2 years and the massive success of AppSec APAC 2014 in Tokyo would not have been possible without the passion and full commitment to the OWASP cause demonstrated by Rio.  He is definitely a role model for the OWASP community, especially in the Asia Pacific region which in general is lacking strong and effective leadership, and there is no doubt in my mind he is the most suited candidate for Best Chapter Leader based on the efforts he's contributed in the past few years as well as the success and results of those efforts.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;He holds local chapter meeting(we call OWASP Night), and every event is full capacity and good topics. And he organized successful event, which is OWASP APAC 2014 in this year.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Rio has done an amazing job building up our Japan chapters. &lt;br /&gt;
Over the last few years with huge community meetings, new chapters in Japan and a lot of community activity. &lt;br /&gt;
This is truely outstanding!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Sen is OWASP Japan Co-Chapter leader and leading OWASP AppSec APAC.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| Adam Brand, Ryan Heiserman, Kristian Erik Hermansen, Neil Matatall, Ron Perris, Adam Robertson [https://www.owasp.org/index.php/Orange_County_Team Orange County Team]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Orange_County Orange County]||align=&amp;quot;center&amp;quot;|&lt;br /&gt;
&lt;br /&gt;
&amp;quot;• OWASP Orange County Chapter Meetings&lt;br /&gt;
	• Grew the chapter leadership organization to six chapter leaders from three.&lt;br /&gt;
	• Increased meeting frequency from bi-yearly to monthly.&lt;br /&gt;
	• Held 13 meetings in the last twelve months.&lt;br /&gt;
	• Attracted 140 new attendees to chapter meetings.&lt;br /&gt;
	• Established a culture of vendor neutrality and speakers selection based on merit&lt;br /&gt;
&lt;br /&gt;
• Organized AppSec California&lt;br /&gt;
	• 250 Attendees&lt;br /&gt;
	• 40 Speakers on 3 Tracks&lt;br /&gt;
&lt;br /&gt;
Currently Organizing AppSec California 2015!&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| [https://www.owasp.org/index.php/Sebastien_(Seba)_Deleersnyder Sebastien Deleersnyder]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/ Belgium]||align=&amp;quot;center&amp;quot;|&amp;quot;He does a lot of work, not only for the chapter meetings but also for the BeNeLux days. He is very approachable and open for suggestions.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| [https://www.owasp.org/index.php/User:Jonathan_Marcil Jonathan Marcil]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/ Montreal]||align=&amp;quot;center&amp;quot;|&amp;quot;&amp;quot;I would like to nominate Jonathan for his involvement in:&lt;br /&gt;
1) Successfully leading the Montreal Chapter. Even when personally absent and traveling on another continent, Jonathan has remotely managed the overall execution of the local chapter meetings.&lt;br /&gt;
2) His valuable contribution to the OWASP Media project, that undoubtedly brings the &amp;quot;&amp;quot;O&amp;quot;&amp;quot; of OWASP to audiences unable to attend meetings&lt;br /&gt;
3) Jonathan has contributed and invested efforts on the &amp;quot;&amp;quot;outreach&amp;quot;&amp;quot; objective, announced by the board as a core objective for 2013-2014.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Best Project Leader&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;150&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;120&amp;quot; | Project &lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; | Citation&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Jeremy_Long Jeremy Long]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_Dependency_Check OWASP Dependency Check]||align=&amp;quot;center&amp;quot;|&amp;quot;Reasons Jeremy Long and his Dependency Check deserve a WASPY award:&lt;br /&gt;
&lt;br /&gt;
- His OWASP Dependency Check is a solution to the problem of third party libraries that needed to be solved. &lt;br /&gt;
- Jeremy's work on D.C. is steady.  He has put a lot of work into this project&lt;br /&gt;
- Jeremy has successfully involved others to help work on the project.  It is a model open source project.&lt;br /&gt;
- He has been responsive and helpful to questions and created a nice community of users.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/User:achim Achim Hoffmann]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/O-Saft OWASP O-Saft]||align=&amp;quot;center&amp;quot;|&amp;quot;Achim is the project leader of O-Saft (https://www.owasp.org/index.php/O-Saft). O-Saft is a tool to analyze the SSL configuration of a web or mail server. It is a tool with a very specific focus, not a swiss army knife but there is a need for exactly this tool. Achim started the development at the beginning of the big SSL-crisis (concerns about weak ciphers, cipher orders, perfect forward secrecy, ). Without a specialized tool it is impossible to find out the SSL behaviour of a given server. Achim's interest was focused on facts only. The outcome of the tool is not a subjective rating, score or grade, only  facts about the config. Achim goals were exactness, comprehensiveness and impartiality which he achieved with his project. He was open to suggestions and could win additional highly motivated and skilled contributors. He is not a marketing driven project leader instead of that he gives talks and trainings about SSL and O-Saft (Munich Chapter, OWASP AppSec EU 2014 Cambridge) to share his knowledge.&lt;br /&gt;
 &lt;br /&gt;
I would like to nominate Achim for the OWASP Project Leader 2014 because his project fulfills the OWASP mission in a perfect way. It makes the security of SSL servers visible. There is no free available tool beside O-Saft with a comparable comprehensive scope and ability to execute. It is completely free of commercial interests or commercial &amp;quot;&amp;quot;added values&amp;quot;&amp;quot;, distributed under a GPL.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/User:Tokuji_Akamine Tokuji Akamine]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_XSecurity_Project  OWASP XSecurity Project]||align=&amp;quot;center&amp;quot;|&amp;quot;The idea(feature) of this security tool is excellent, especially these two points below.&lt;br /&gt;
Usually security is difficult and burdensome. But this security tool makes security much easier and less burdensome to iOS app developers.&lt;br /&gt;
1. Provide developer friendly security features on top of Xcode to assist developers to learn iOS app security.(Quick Security Help with built-in Security Guidelines)&lt;br /&gt;
2. Avoid making vulnerabilities during development.(Real-time Vulnerability Notifications)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;He provides to assist iOS developers to develop secure iOS apps and  a security plugin for Xcode plus clang static analyzer checkers for iOS application development. This plugin will be to reduce the vulnerability made during development by detecting the vulnerability.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Matteo_Meucci Matteo Meucci]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_Testing_Project OWASP Testing Project]||align=&amp;quot;center&amp;quot;|&amp;quot;Matteo collaborates in OWASP from 2002.He founded the Italian Chapter in 2005.He candidates for the Autum of Code in 2006 to start a new project regarding the Testing Guide. He leads the OWASP Testing from 2006 (v2) to now with the publishing of Testing Guide v4 in the next weeks. He was capable to attract and manage more than 50 people to create the new Guide. Nowadays the Testing Guide is the most recognized project of OWASP with great contents and high quality delivery.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/User:Simon_Bennetts  Simon Bennetts]||align=&amp;quot;center&amp;quot;|[http://owasp.com/index.php/ZAP OWASP Zed Attack Proxy Project (ZAP)]||align=&amp;quot;center&amp;quot;|&amp;quot;He has both humble heart and strong leadership.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/John_Melton John Melton]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_AppSensor OWASP AppSensor]||align=&amp;quot;center&amp;quot;|&amp;quot;John has working tirelessly, and mostly invisible behind the scenes in developing the OWASP AppSensor project. While others have lead the charge on the OWASP AppSensor documentation project, for the most part, John has been the sole contributor to the OWASP AppSensor source code.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Spyros_Gasteratos Spryos Gasteratos]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_Hackademic_Challenges_Project OWASP Hackademic Challenges Project]||align=&amp;quot;center&amp;quot;|&amp;quot;Spyros has been involved in OWASP since 2010, contributing more and more time as years go by. He began by volunteering for OWASP AppSec Research 2012, where he was in charge for coordinating a team of more than 20 volunteers. For the past 1.5 year he as been co-leading the OWASP Hackademic Challenges Project. During that time he has managed to take the project into the next level both by producing code and by mentoring GSOC students. Spyros has spent a tremendous amount of time in coding, fixing bugs, setting up and maintaining a live version of Hackademic. Undoubtedly, without his efforts the project would have become dormant.Furthermore, he is also helping in other OWASP initiatives, e.g. by participating in the Open Source Showcase, presenting Hackademic and OWASP at the FOSDEM conference in Belgium and by setting up the new &amp;quot;&amp;quot;OWASP Code Wind&amp;quot;&amp;quot; project that aims to bring more student contributions to OWASP.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Best Mission Outreach&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;150&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;120&amp;quot; |  &lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; | Citation&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Mostafa_Siraj Mostafa Siraj]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Cairo Cairo Chapter]||align=&amp;quot;center&amp;quot;|&amp;quot;Mostafa did a great job helping our chapter (Cairo Chapter), here are summary of his contribution: - He had a great talk in the latest chapter event, he talk about AppSec US summarizing the conference technical sessions (Mostafa attended the 2013 conference and won the technical competition there), - Mostafa is one of the main members of a small group of AppSec expertise from Cairo chapter, this group is engaged now for preparing security awareness training program for all governmental developers in Egypt, I highly recommend him,&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/User:Jonathan_Marcil Jonathan Marcil]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/OWASP_Media_Project OWASP Media Project]||align=&amp;quot;center&amp;quot;|&amp;quot;Because he is helping spread OWASP message through this videos and live streaming events&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/AppSecUSA_2013_Team AppSecUSA 2013 Team]||align=&amp;quot;center&amp;quot;|[http://2013.appsecusa.org/ AppSecUSA 2013 Team]||align=&amp;quot;center&amp;quot;|&amp;quot;AppSec USA 2013 was one of our (if not the) most successful conferences ever. In terms of the sheer number of attendees and high quality talks and organisation, this was indeed an outstanding achievement in mission outreach. I would like to nominate the team for this amazing achievement.&amp;quot;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Best New Community Supporter&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;150&amp;quot; | Name&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;120&amp;quot; |  &lt;br /&gt;
! scope=&amp;quot;col&amp;quot; align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; | Citation&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/AppSecAPAC_2014_Team AppSecAPAC 2014 Team]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/AppSecAsiaPac2014#tab=TEAM AppSec APAC  2014]||align=&amp;quot;center&amp;quot;|&amp;quot;Despite it being the first time that AppSec was held in Japan and despite the lack of experience in planning and organizing a large scale international conference, the volunteers on the AppSec APAC 2014 team came together and went above and beyond their responsibilities to make AppSec APAC 2014 in Tokyo a stunning success.  It was by far the most successful AppSec in the Asia Pacific region and achieved an unprecedented level of profitability.  The vast majority of the sponsors were Japanese companies and many of the attendees were Japanese.  The ability to achieve this despite the relatively low level of awareness of the OWASP brand in Japan was definitely due to the hard work and dedication of the AppSec APAC 2014 team who worked around the clock to make the event a success.  Considering that there were no applicants to hold AppSec APAC 2015 despite the tremendous success in Tokyo, recognizing the contributions of the AppSec APAC 2015 team would definitely give a strong message motivating the Asia Pacific community and facilitate future OWASP initiatives in the region.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Surely, potential language barriers were completely broken in the conference. This experience of us will be a good example for OWASP organizers especially in Asia Pacific area.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;quot;2 OWASP ZAP evangelists were born in Japan at the timing of AppSec APAC 2014.&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/Beth_Ritter-Guth Beth Guth]||align=&amp;quot;center&amp;quot;|[https://www.owasp.org/index.php/New_Jersey_South South New Jersey]||align=&amp;quot;center&amp;quot;|&amp;quot;She started South New Jersey chapter with energy and enthusiasm bringing together people from builders, breakers and defenders. Self-starter&amp;quot;&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:2014-04_OWASP_SoCal_-_Continuous1.pptx&amp;diff=173493</id>
		<title>File:2014-04 OWASP SoCal - Continuous1.pptx</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:2014-04_OWASP_SoCal_-_Continuous1.pptx&amp;diff=173493"/>
				<updated>2014-04-25T19:13:28Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:CSP-1.1-2014-02-20.pdf&amp;diff=168898</id>
		<title>File:CSP-1.1-2014-02-20.pdf</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:CSP-1.1-2014-02-20.pdf&amp;diff=168898"/>
				<updated>2014-02-24T15:43:18Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &amp;quot;How CSP will (maybe) Solve the XSS Problem&amp;quot; presented at OWASP OC on Feb 20, 2014&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;quot;How CSP will (maybe) Solve the XSS Problem&amp;quot; presented at OWASP OC on Feb 20, 2014&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=158482</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=158482"/>
				<updated>2013-09-15T21:22:04Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* HTML entity encoding */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this without encoding the data with one of the techniques listed below.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== JSON entity encoding ====&lt;br /&gt;
&lt;br /&gt;
The rules for JSON encoding can be found in the [https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Output_Encoding_Rules_Summary Output Encoding Rules Summary]. Note, this will not allow you to use XSS protection provided by CSP 1.0.&lt;br /&gt;
&lt;br /&gt;
==== HTML entity encoding ====&lt;br /&gt;
&lt;br /&gt;
This technique has the advantage that html entity escaping is widely supported and helps separate data from server side code without crossing any context boundaries. Consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= html_escape(data.to_json) %&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  // external js file&lt;br /&gt;
  var dataElement = document.getElementById('init_data');&lt;br /&gt;
  var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
  var initData = JSON.parse(jsonText);&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]. URL encoding should only be used to encode parameter values, not the entire URL or path fragments of a URL.&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=158481</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=158481"/>
				<updated>2013-09-15T21:20:44Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* JSON entity encoding */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this without encoding the data with one of the techniques listed below.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== JSON entity encoding ====&lt;br /&gt;
&lt;br /&gt;
The rules for JSON encoding can be found in the [https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Output_Encoding_Rules_Summary Output Encoding Rules Summary]. Note, this will not allow you to use XSS protection provided by CSP 1.0.&lt;br /&gt;
&lt;br /&gt;
==== HTML entity encoding ====&lt;br /&gt;
&lt;br /&gt;
Built-in to every framework.&lt;br /&gt;
&lt;br /&gt;
Consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= html_escape(data.to_json) %&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  // external js file&lt;br /&gt;
  var dataElement = document.getElementById('init_data');&lt;br /&gt;
  var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
  var initData = JSON.parse(jsonText); &lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]. URL encoding should only be used to encode parameter values, not the entire URL or path fragments of a URL.&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=158480</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=158480"/>
				<updated>2013-09-15T21:19:52Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* RULE #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this without encoding the data with one of the techniques listed below.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== JSON entity encoding ====&lt;br /&gt;
&lt;br /&gt;
An alternative to the technique above is JSON encoding the data. The rules for JSON encoding can be found in the [https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Output_Encoding_Rules_Summary Output Encoding Rules Summary].&lt;br /&gt;
&lt;br /&gt;
==== HTML entity encoding ====&lt;br /&gt;
&lt;br /&gt;
Built-in to every framework.&lt;br /&gt;
&lt;br /&gt;
Consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= html_escape(data.to_json) %&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  // external js file&lt;br /&gt;
  var dataElement = document.getElementById('init_data');&lt;br /&gt;
  var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
  var initData = JSON.parse(jsonText); &lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]. URL encoding should only be used to encode parameter values, not the entire URL or path fragments of a URL.&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=158479</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=158479"/>
				<updated>2013-09-15T21:19:17Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* HTML entity encoding */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this without encoding the data with one of the techniques listed below.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== HTML entity encoding ====&lt;br /&gt;
&lt;br /&gt;
Built-in to every framework.&lt;br /&gt;
&lt;br /&gt;
Consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= html_escape(data.to_json) %&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  // external js file&lt;br /&gt;
  var dataElement = document.getElementById('init_data');&lt;br /&gt;
  var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
  var initData = JSON.parse(jsonText); &lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
==== JSON entity encoding ====&lt;br /&gt;
&lt;br /&gt;
An alternative to the technique above is JSON encoding the data. The rules for JSON encoding can be found in the [https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Output_Encoding_Rules_Summary Output Encoding Rules Summary].&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]. URL encoding should only be used to encode parameter values, not the entire URL or path fragments of a URL.&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=158478</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=158478"/>
				<updated>2013-09-15T21:18:33Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* RULE #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this without encoding the data with one of the techniques listed below.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== HTML entity encoding ====&lt;br /&gt;
&lt;br /&gt;
Built-in to every framework.&lt;br /&gt;
&lt;br /&gt;
Consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= html_escape(data.to_json) %&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
    var dataElement = document.getElementById('init_data');&lt;br /&gt;
    var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
    var initData = JSON.parse(jsonText); &lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
==== JSON entity encoding ====&lt;br /&gt;
&lt;br /&gt;
An alternative to the technique above is JSON encoding the data. The rules for JSON encoding can be found in the [https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#Output_Encoding_Rules_Summary Output Encoding Rules Summary].&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]. URL encoding should only be used to encode parameter values, not the entire URL or path fragments of a URL.&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158469</id>
		<title>Projects/OWASP Framework Matrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158469"/>
				<updated>2013-09-15T17:09:21Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: This page is a template part of the [https://www.owasp.org/index.php/OWASP_Framework_Security_Project OWASP Framework Security Project]. Edit this page [https://www.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;amp;action=edit here]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Framework'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Security Control'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Present / Not Present'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Enabled By Default'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Link to more info'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Under Development?'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Contact Point'''&lt;br /&gt;
|-&lt;br /&gt;
| || Automatic escaping in templates || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Prepared statements (including ORM) || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| Django||x-frame-options||Present||No||[https://docs.djangoproject.com/en/dev/ref/clickjacking/#setting-x-frame-options-for-all-responses link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||SECURE Cookie Flag||Present||No||[https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SESSION_COOKIE_SECURE link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||HTTPOnly Cookie Flag||?||?||[# link]||?||?&lt;br /&gt;
|-&lt;br /&gt;
| Rails||Automatic CSRF protection||Present||Yes||[http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| || Offsite redirect detection/prevention || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || javascript: URIs in links || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Error suppression in production environments || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Mask sensitive data in logs || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Encryption abstractions || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Strict transport security || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Content security policy || || ||  ||  || &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158468</id>
		<title>Projects/OWASP Framework Matrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158468"/>
				<updated>2013-09-15T17:08:57Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: This page is a template part of the [https://www.owasp.org/index.php/OWASP_Framework_Security_Project OWASP Framework Security Project]. Edit this page [https://www.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;amp;action=edit here]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Framework'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Security Control'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Present / Not Present'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Enabled By Default'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Link to more info'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Under Development?'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Contact Point'''&lt;br /&gt;
|-&lt;br /&gt;
| || Automatic escaping in templates || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Prepared statements (including ORM) || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| Django||x-frame-options||Present||No||[https://docs.djangoproject.com/en/dev/ref/clickjacking/#setting-x-frame-options-for-all-responses link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||SECURE Cookie Flag||Present||No||[https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SESSION_COOKIE_SECURE link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||HTTPOnly Cookie Flag||?||?||[# link]||?||?&lt;br /&gt;
|-&lt;br /&gt;
| Rails||Automatic CSRF protection||Present||Yes||[http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| || Offsite redirect detection/prevention || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || javascript: URIs in links || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Error suppression in production environments || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Mask sensitive data in logs || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Encryption abstractions || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Prepared statement support || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Strict transport security || || ||  ||  || &lt;br /&gt;
|-&lt;br /&gt;
| || Content security policy || || ||  ||  || &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158309</id>
		<title>Projects/OWASP Framework Matrix</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;diff=158309"/>
				<updated>2013-09-12T04:47:33Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Note: This page is a template part of the [https://www.owasp.org/index.php/OWASP_Framework_Security_Project OWASP Framework Security Project]. Edit this page [https://www.owasp.org/index.php?title=Projects/OWASP_Framework_Matrix&amp;amp;action=edit here]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Framework'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Security Control'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Present / Not Present'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Enabled By Default'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Link to more info'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Under Development?'''&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|'''Contact Point'''&lt;br /&gt;
|-&lt;br /&gt;
| Django||x-frame-options||Present||No||[https://docs.djangoproject.com/en/dev/ref/clickjacking/#setting-x-frame-options-for-all-responses link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||SECURE Cookie Flag||Present||No||[https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-SESSION_COOKIE_SECURE link]||n/a||n/a&lt;br /&gt;
|-&lt;br /&gt;
| Django||HTTPOnly Cookie Flag||?||?||[# link]||?||?&lt;br /&gt;
|-&lt;br /&gt;
| Rails||Automatic CSRF protection||Present||Yes||[http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf link]||n/a||n/a&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=157526</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=157526"/>
				<updated>2013-08-29T19:29:49Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* RULE #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform and ASP.NET Framework has built-in [http://msdn.microsoft.com/en-us/library/ms972969.aspx#securitybarriers_topic6 ValidateRequest] function that provides '''limited''' sanitization.&lt;br /&gt;
&lt;br /&gt;
The OWASP [[ESAPI]] project has created an escaping library for Java. OWASP also provides the [[OWASP Java Encoder Project]] for high-performance encoding.&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.&lt;br /&gt;
&lt;br /&gt;
'''Ensure returned ''Content-Type'' header is application/json and not text/html. &lt;br /&gt;
This shall instruct the browser not misunderstand the context and execute injected script'''&lt;br /&gt;
&lt;br /&gt;
'''Bad HTTP response:'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: text/html; charset=utf-8''' &amp;lt;-- bad&lt;br /&gt;
    ....&lt;br /&gt;
    Content-Length: 373&lt;br /&gt;
    Keep-Alive: timeout=5, max=100&lt;br /&gt;
    Connection: Keep-Alive&lt;br /&gt;
    {&amp;quot;Message&amp;quot;:&amp;quot;No HTTP resource was found that matches the request URI 'dev.net.ie/api/pay/.html?HouseNumber=9&amp;amp;AddressLine&lt;br /&gt;
    =The+Gardens'''&amp;amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;'''&amp;amp;AddressLine2=foxlodge+woods&amp;amp;TownName=Meath'.&amp;quot;,&amp;quot;MessageDetail&amp;quot;:&amp;quot;No type was found&lt;br /&gt;
    that matches the controller named 'pay'.&amp;quot;}   &amp;lt;-- this script will pop!!&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
'''Good HTTP response'''&lt;br /&gt;
&lt;br /&gt;
    HTTP/1.1 200&lt;br /&gt;
    Date: Wed, 06 Feb 2013 10:28:54 GMT&lt;br /&gt;
    Server: Microsoft-IIS/7.5....&lt;br /&gt;
    '''Content-Type: application/json; charset=utf-8''' &amp;lt;--good&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= data.to_json %&amp;gt;  &amp;amp;lt;-- data is HTML escaped, or at least json entity escaped --&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
    var dataElement = document.getElementById('init_data');&lt;br /&gt;
    var jsonText = dataElement.textContent || dataElement.innerText  // unescapes the content of the span&lt;br /&gt;
    var initData = JSON.parse(jsonText); &lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;/span&amp;gt;       property value&lt;br /&gt;
&lt;br /&gt;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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 - Sanitize HTML Markup with a Library Designed for the Job ==&lt;br /&gt;
&lt;br /&gt;
If your application handles markup -- untrusted input that is supposed to contain HTML -- it can be very difficult to validate. Encoding is also difficult, since it would break all the tags that are supposed to be in the input. Therefore, you need a library that can parse and clean HTML formatted text.  There are several available at OWASP that are simple to use:&lt;br /&gt;
&lt;br /&gt;
'''OWASP AntiSamy''' - https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project&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;
'''OWASP Java HTML Sanitizer''' - https://www.owasp.org/index.php/OWASP_Java_HTML_Sanitizer_Project&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&lt;br /&gt;
&lt;br /&gt;
'''Other libraries that provide HTML Sanitization include:'''&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP Html Purifier - http://htmlpurifier.org/&amp;lt;br/&amp;gt;&lt;br /&gt;
JavaScript/Node.JS Bleach - https://github.com/ecto/bleach&amp;lt;br/&amp;gt;&lt;br /&gt;
Python Bleach - https://pypi.python.org/pypi/bleach&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;document.write(&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;quot;UNTRUSTED INPUT: &amp;quot; + document.location.hash&amp;lt;/span&amp;gt;);&amp;amp;lt;script/&amp;amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Eoin Keary - eoin.keary[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=153759</id>
		<title>Orange County</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=153759"/>
				<updated>2013-06-14T23:13:20Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chapter Template|chaptername=Orange County|extra=Lead by [mailto:ron.perris@whitehatsec.com Ron Perris]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|mailinglistsite=http://lists.owasp.org/mailman/listinfo/owasp-Orange_County|emailarchives=http://lists.owasp.org/pipermail/owasp-Orange_County}}&lt;br /&gt;
The chapter leader is [mailto:ron.perris@whitehatsec.com Ron Perris].&lt;br /&gt;
&lt;br /&gt;
== We are on '''Meetup'''! ==&lt;br /&gt;
Join us and RSVP to our meeting there &amp;lt;br&amp;gt;&lt;br /&gt;
http://www.meetup.com/OWASP-OC&lt;br /&gt;
&lt;br /&gt;
== Sponsor ==&lt;br /&gt;
HP Enterprise Security&lt;br /&gt;
&lt;br /&gt;
==Future Meetings ==&lt;br /&gt;
&lt;br /&gt;
==== May 21th 2013====&lt;br /&gt;
&lt;br /&gt;
'''Topic: Top Ten Web Defenses'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''Presenter: Jim Manico&amp;lt;br&amp;gt;'''&lt;br /&gt;
'''Summary:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Title: Top Ten Web Defenses&lt;br /&gt;
&lt;br /&gt;
We cannot “firewall” or “patch” our way to secure websites. In the past, security professionals thought firewalls, Secure Sockets Layer (SSL), patching, and privacy policies were enough. Today, however, these methods are outdated and ineffective, as attacks on prominent, well-protected websites are occurring every day. Citigroup, PBS, Sega, Nintendo, Gawker, AT&amp;amp;T, the CIA, the US Senate, NASA, Nasdaq, the NYSE, Zynga, and thousands of others have something in common – all have had websites compromised in the last year. No company or industry is immune. Programmers need to learn to build websites differently. This talk will review the top coding techniques developers need to master in order to build a low-risk, high-security web application.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
BIO: Jim Manico is the VP of Security Architecture for WhiteHat &lt;br /&gt;
Security, a web security firm. He authors and delivers developer &lt;br /&gt;
security awareness training for WhiteHat Security and has a background as a software developer and architect. Jim is also a global board member for the OWASP foundation. He manages and participates in several OWASP projects, including the OWASP cheat sheet series and the OWASP podcast series.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where: Crescent Solutions&lt;br /&gt;
17871 Mitchell N # 100, Irvine, CA&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Schedule:&amp;lt;br&amp;gt;&lt;br /&gt;
6:00 - 6:30: Introduction and networking&amp;lt;br&amp;gt;&lt;br /&gt;
6:30 - 7:30: Presentation&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RSVP here http://www.meetup.com/OWASP-OC'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== July 18th 2013====&lt;br /&gt;
&lt;br /&gt;
'''Topic: TBD'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''Presenter:TBD&amp;lt;br&amp;gt;'''&lt;br /&gt;
'''Summary:''' &amp;lt;br&amp;gt;&lt;br /&gt;
Where: Crescent Solutions&lt;br /&gt;
17871 Mitchell N # 100, Irvine, CA&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Schedule:&amp;lt;br&amp;gt;&lt;br /&gt;
6:00 - 6:30: Introduction and networking&amp;lt;br&amp;gt;&lt;br /&gt;
6:30 - 7:30: Presentation&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RSVP here http://www.meetup.com/OWASP-OC'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Previous Meetings===&lt;br /&gt;
&lt;br /&gt;
==== January 17th 2013====&lt;br /&gt;
&lt;br /&gt;
'''Topic: Putting your robots to work: security automation at Twitter'''&amp;lt;br&amp;gt;&lt;br /&gt;
'''Presenter: Neil Matatall and Justin Collins&amp;lt;br&amp;gt;'''&lt;br /&gt;
'''Summary:''' &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;With daily code releases and a growing infrastructure, manually reviewing code changes and protecting against security regressions quickly becomes impractical. Even when using security tools, whether commercial or open source, the difficult work of integrating them into the development and security cycles remains. We need to use an automated approach to push these tools as close to when the code is written as possible, allowing us to prevent potential vulnerabilities before they are shipped. We worked with development, operations, and release teams to create a targeted suite of tools focused on specific security concerns that are effective and don’t introduce any noise. This presentation will give an overview of what we’ve done over the past year, what we have learned along the way, and will provide advice for anyone else going down this road as well as the philosophy that guided us along the way.&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where: Crescent Solutions&lt;br /&gt;
17871 Mitchell N # 100, Irvine, CA&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Schedule:&amp;lt;br&amp;gt;&lt;br /&gt;
6:00 - 6:30: Introduction and networking&amp;lt;br&amp;gt;&lt;br /&gt;
6:30 - 7:30: Presentation&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RSVP here http://www.meetup.com/OWASP-OC'''&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== OWASP LA Event: Security Summit: April 25, 2012, 3:00PM - 8PM  ====&lt;br /&gt;
&lt;br /&gt;
(Note different time and location)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jerry Hoff VP, Static Code Analysis Division at WhiteHat Security, will be speaking about Webgoat. Shakeel Tufail, Federal Practice Director for HP Enterprise Security Solutions, will be speaking on securing software. Noa Bar Yosef, Senior Security Strategist at Imperva, will be speaking on &amp;quot;De-Anonymizing Anonymous&amp;quot;. A concluding panel, moderated by Richard Greenberg, Information Security Officer for LA County Public Health, will have the speakers joined by Adnan Masood, a Software Engineer and Architect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== March 28th 2012 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: March 28th 7pm&lt;br /&gt;
&lt;br /&gt;
Where: Irvine - 5151 California Ave, Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:30: Presentation&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;WebGoat.NET&amp;quot;====&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
Jerry Hoff, the project leader of the OWASP Appsec Tutorial Series, and VP of the Static Code Analysis Division at WhiteHat Security, will be discussing his newest OWASP project, WebGoat.NET.  For many years, the Java version of WebGoat has been available as a fantastic tool for learning application security from the Java perspective.  Jerry has now created a parallel tool for ASP.NET developers to learn about application security.  Jerry will be discussing how this tool can be used in a learning environment, and other issues related to application security education.&lt;br /&gt;
&lt;br /&gt;
====Speaker Bio:====&lt;br /&gt;
Jerry Hoff is vice president of the Static Code Analysis division at WhiteHat Security. In this role, he oversees the development of WhiteHats cloud-based static application security testing (SAST) service. Prior to WhiteHat, Mr. Hoff was co-founder and managing partner ofInfrared Security, a leading application security professional services firm. Mr. Hoff is an experienced application security consultant with years of professional development and training delivery. He is also the lead of the OWASP AppSec Tutorial Series. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== September 14th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: Wednesday September 17th 7pm&lt;br /&gt;
Where: TBD (Irvine)&lt;br /&gt;
http://www.meetup.com/ocrails/events/30043551/&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:00: Brakeman with Justin Collins&lt;br /&gt;
8:00 - 8:15: Lightning Rounds&lt;br /&gt;
8:15 - 8:30: Brakeman Demo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brakeman with Justin Collins: &lt;br /&gt;
While the popular Ruby on Rails web framework provides built-in protection &lt;br /&gt;
for many security vulnerabilities, it is still possible to misuse these&lt;br /&gt;
features or introduce other vulnerabilities to an application. Brakeman is a static code analysis tool designed specifically to find vulnerabilities and configuration issues  in Ruby on Rails applications. Since it works at the source code level, Brakeman can be used at any point in development without the need for deploying the full application stack. To make it even simpler, &lt;br /&gt;
Brakeman can be integrated with Hudson/Jenkins to provide automatic monitoring of Brakeman results as code is committed. This talk will discuss how to use Brakeman and how it can help you create safer Rails applications.&lt;br /&gt;
&lt;br /&gt;
Lightning Rounds:&lt;br /&gt;
&lt;br /&gt;
Neil Matatall: Friendly_id + ancsetry&lt;br /&gt;
&lt;br /&gt;
Drew Deponte: Guard, spork, BDD&lt;br /&gt;
&lt;br /&gt;
==== June 29th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
[[http://owaspoc.eventbrite.com/ Registration Link]]&lt;br /&gt;
&lt;br /&gt;
'''When''': Wednesday june 29th, 2011 7pm&lt;br /&gt;
&lt;br /&gt;
'''Where:  HireRight Offices'''&lt;br /&gt;
5151 California Avenue&lt;br /&gt;
Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
'''Pizza and refreshments will be provided by the sponsors of this meeting.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
===== Meeting Sponsors =====&lt;br /&gt;
 &lt;br /&gt;
Food and refreshments:&lt;br /&gt;
[[File:AppSecDC2010-Sponsor-trustwave.gif]]&lt;br /&gt;
&lt;br /&gt;
Meeting location:&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
 &lt;br /&gt;
===== Presentation Topic: =====&lt;br /&gt;
Featuring analysis of more than 220 data breach investigations and more than 2,300 penetration tests conducted by Trustwave's SpiderLabs, the Global Security Report 2011 identifies the top vulnerabilities business encountered in 2010 as well as a list of strategic initiatives to help your business improve its overall security.&lt;br /&gt;
 &lt;br /&gt;
The data gathered from these engagements is substantial and comprehensive. This presentation will be a summary of the results of the analysis of the data gathered during 2010. The results will be presented both technical and business impact analysis.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Charles Henderson, Director of Application Security Services of SpiderLabs at Trustwave =====&lt;br /&gt;
 &lt;br /&gt;
Henderson began his career in computer security in 1993, specializing in penetration testing as well as security and vulnerability research. As Director of Application Security Services at SpiderLabs, he leads the team responsible for Application Penetration Testing, Code Review, Secure Development Training, and other elite application security consulting services.&lt;br /&gt;
 &lt;br /&gt;
Prior to joining SpiderLabs, Henderson ran his own boutique application&lt;br /&gt;
security testing firm. Henderson’s firm provided offensive security services to a wide variety of clients in the United States and Europe.&lt;br /&gt;
 &lt;br /&gt;
Henderson speaks frequently at major industry events and conferences, including BlackHat, DEF CON,  AppSec US, AppSec EU, SOURCE, and the International Association of Financial Crime Investigators convention.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====January 28th, 2011====&lt;br /&gt;
&lt;br /&gt;
'''Registration link: [https://www.regonline.com/owasp_oc_jan]'''&lt;br /&gt;
&lt;br /&gt;
'''Time:''' 1 PM - 5PM&lt;br /&gt;
&lt;br /&gt;
'''Location: '''&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=5151+California+Ave&amp;amp;sll=33.621597,-117.740797&amp;amp;sspn=0.010489,0.019011&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=5151+California+Ave,+Irvine,+Orange,+California+92617&amp;amp;z=16&amp;amp;iwloc=A Hireright] &lt;br /&gt;
&lt;br /&gt;
5151 California Ave&lt;br /&gt;
&lt;br /&gt;
Irvine, California 92617&lt;br /&gt;
&lt;br /&gt;
United States.   &lt;br /&gt;
&lt;br /&gt;
'''Topics:''' Threat Modeling, Application Security&lt;br /&gt;
&lt;br /&gt;
'''Food:''' Provided&lt;br /&gt;
&lt;br /&gt;
Speakers:  &lt;br /&gt;
&lt;br /&gt;
'''Samy Kamkar'''&lt;br /&gt;
&lt;br /&gt;
Online Privacy and the Evercookie&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Samy Kamkar has lectured on computer security issues in over a dozen&lt;br /&gt;
countries, and his work has been featured on the front page of the New&lt;br /&gt;
York Times. As a grey-hat hacker, he makes and breaks computer&lt;br /&gt;
security for tech companies. In addition to his independent security&lt;br /&gt;
research, he co-founded Fonality, an IP PBX company.&lt;br /&gt;
&lt;br /&gt;
'''Jim Manico'''&lt;br /&gt;
&lt;br /&gt;
Back to Basics: Defensive Coding Principles for Web Development 101&lt;br /&gt;
&lt;br /&gt;
The application security community is in deep need of prescriptive&lt;br /&gt;
solutions for developers. This talk will review the world of Web&lt;br /&gt;
Application Security from a &amp;quot;builder&amp;quot; point of view, focusing on&lt;br /&gt;
critical controls that all developers must master if they wish to build&lt;br /&gt;
low risk web applications today.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Jim Manico is the chair of the OWASP Connections committee where he&lt;br /&gt;
focuses on producing and hosting the OWASP Podcast. Jim also is a&lt;br /&gt;
co-manager of the OWASP ESAPI Open Source project. Professionally, Jim&lt;br /&gt;
is an independent application security architect specializing in the&lt;br /&gt;
construction of low-risk web applications. Jim is also an application&lt;br /&gt;
security educator and assessment specialist.&lt;br /&gt;
&lt;br /&gt;
'''Edward Bonver'''&lt;br /&gt;
Talk Title:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling at Symantec&lt;br /&gt;
[[File:OWASP-WWW-2011-Edward-Bonver-Threat-Modelint-at-Symantec.pptx]]&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling is one of the most important security activities that a development/QA team needs to perform as part of a Security Development Lifecycle. This activity allows the team to build a complete security profile of the system being built. Threat Modeling is not always easy to get going for a team that has little or no security experience. In this presentation we’ll take a look at why Threat Modeling is so important; we’ll explore the process behind it, and how the process is being implemented and followed across Symantec.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Edward Bonver is a principal software engineer on the product security team under the Office of the CTO at Symantec Corporation.  In this capacity, Edward is responsible for working with software developers and quality assurance (QA) professionals across Symantec to continuously enhance the company’s software security practices through the adoption of methodologies, procedures and tools for secure coding and security testing.  Within Symantec, Edward teaches secure coding and security testing classes for Symantec engineers, and also leads the company’s QA Security Task Force, which he founded.  Prior to joining Symantec, Edward held software engineering and QA roles at Digital Equipment Corporation, Nbase and Zuma Networks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edward is a Certified Information Systems Security Professional (CISSP) and a Certified Secure Software Lifecycle Professional (CSSLP).  He holds a master’s degree in computer science from California State University, Northridge, and a bachelor’s degree in computer science from Rochester Institute of Technology. Edward is a Ph.D. student at NOVA Southeastern University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, January 21st 2010====&lt;br /&gt;
&lt;br /&gt;
Time: 7:30&lt;br /&gt;
Location: We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus. The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020. Parking is $7 but feel free to park off campus and walk to the building. http://www.oit.uci.edu/computing/labs/training.html Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdfBD&lt;br /&gt;
&lt;br /&gt;
For those who would like to avoid paying for parking, you can park in the University Center and take the campus shuttle: http://www.shuttle.uci.edu/maincampus/index.php&lt;br /&gt;
&lt;br /&gt;
The shuttle runs until 10:45PM.  The shuttle costs $1 per ride, but fees are rarely collected ;)&lt;br /&gt;
&lt;br /&gt;
Title: Do VLANs allow for good application security? &lt;br /&gt;
 &lt;br /&gt;
Virtual Local Area Networks (VLANs) are not a new concept, and can help&lt;br /&gt;
any organization better control network access.  I will present some of&lt;br /&gt;
the previous issues identified, what was the root cause, and how these&lt;br /&gt;
have been fixed in current technology.  In addition we will talk about&lt;br /&gt;
how this can help to enhance security in your environment, and what&lt;br /&gt;
controls must be in place in order to implement such an environment.  We&lt;br /&gt;
will also touch on how this can complicate your application environment,&lt;br /&gt;
but improve overall security.&lt;br /&gt;
&lt;br /&gt;
I will touch on the controls that need to be reviewed and audited when&lt;br /&gt;
working with VMware, VLANs, and web applications, to ensure that these&lt;br /&gt;
networks are secure, and what to look for to potentially pass audit&lt;br /&gt;
criteria.  I will also talk about where and how these controls have been&lt;br /&gt;
implemented in order to protect thousands of users while accessing one&lt;br /&gt;
of the most hostile networks in the world.&lt;br /&gt;
&lt;br /&gt;
David M. N. Bryan &lt;br /&gt;
Senior Security Consultant &lt;br /&gt;
&lt;br /&gt;
David has over 9+ years of computer security experience including,&lt;br /&gt;
consulting, engineering and administration.  He has performed security&lt;br /&gt;
assessment projects for health care, nuclear, manufacturing,&lt;br /&gt;
pharmaceutical, banking and educational sectors.   As an active&lt;br /&gt;
participant in the information security community, he volunteers at&lt;br /&gt;
DEFCON where he designs and implements the Firewall and Network for what&lt;br /&gt;
is said to be the most hostile network environment in the world.  &lt;br /&gt;
&lt;br /&gt;
He is also an active participant in the local Minneapolis security&lt;br /&gt;
groups both as a board member of OWASP MSP and DC612.  His roots and&lt;br /&gt;
experience come from working for a large enterprise banks, designing and&lt;br /&gt;
managing enterprise security systems.  In the more recent years he has&lt;br /&gt;
been working as an Information Security Consultant to review the&lt;br /&gt;
security and architecture of information computing environments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday December 17th 2009====&lt;br /&gt;
&lt;br /&gt;
7:30 PM, UC Irvine Campus, Room AIRB 1020&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus.  The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020.  Parking is $7 but feel free to park off campus and walk to the building.&lt;br /&gt;
http://www.oit.uci.edu/computing/labs/training.html&lt;br /&gt;
Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf&lt;br /&gt;
&lt;br /&gt;
'''Abstract'''&lt;br /&gt;
&lt;br /&gt;
'''Title: Pulling the Plug: Security Risks in the Next Generation of Offline Web Applications'''&lt;br /&gt;
&lt;br /&gt;
As the line between desktop and web applications becomes increasingly blurry in a web 2.0 world, browser functionality is being pushed well beyond what it was originally intended for. Persistent client side storage has become a requirement for web applications if they are to be available both online and off. This need is being filled by a variety of technologies such as [http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage Gears (formerly Google Gears) and the Database Storage]   functionality included in the emerging [http://dev.w3.org/html5/spec/Overview.html HTML 5 specification]. While all such technologies offer great promise, it is clear that the vast majority of developers simply do not understand their security implications.&lt;br /&gt;
&lt;br /&gt;
Researching a variety of currently deployed implementations of these technologies has revealed a broad scope of vulnerabilities with frightening implications. Now attackers can target victims not just once, but every time they visit a site as the victim now carries and stores the attack with them. Imagine a scenario whereby updated confidential information is forwarded to an attacker every time a victim interacts with a given we application. The attacker no longer needs to worry about timing their attacks to ensure that the victim is authenticated as the victim attacks himself! Limited storage? Cookies that expire? Not a problem when entire databases are accessible with virtually unlimited storage and an infinite lifespan. Think these attacks are theoretical? Think again. In this talk we dive into these technologies and break down the risk posed by them when not properly understood. We will then detail a variety of real-world vulnerabilities that have been uncovered, including a new class of cross-site scripting and client-side SQL injection.&lt;br /&gt;
&lt;br /&gt;
'''Bio'''&lt;br /&gt;
&lt;br /&gt;
'''Michael Sutton'''&lt;br /&gt;
'''Vice President, Security Research – Zscaler'''&lt;br /&gt;
&lt;br /&gt;
Michael Sutton has spent more than a decade in the security industry conducting leading-edge research, building teams of world-class researchers and educating others on a variety of security topics. As VP of Security Research, Michael heads Zscaler Labs, the research and development arm of the company. Zscaler Labs is responsible for researching emerging topics in web security and developing innovative security controls, which leverage the Zscaler in-the-cloud model. The team is comprised of researchers with a wealth of experience in the security industry.    &lt;br /&gt;
&lt;br /&gt;
Prior to joining Zscaler, Michael was the Security Evangelist for SPI Dynamics where, as an industry expert, he was responsible for researching, publishing and presenting on various security issues. In 2007, SPI Dynamics was acquired by Hewlett-Packard. Previously, Michael was a Research Director at iDefense where he led iDefense Labs, a team responsible for discovering and researching security vulnerabilities in a variety of technologies. iDefense was acquired by VeriSign in 2005. Michael is a frequent speaker at major information security conferences; he is regularly quoted by the media on various information security topics, has authored numerous articles and is the co-author of Fuzzing: Brute Force Vulnerability Discovery, an Addison-Wesley publication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, November 19th 2009====&lt;br /&gt;
&lt;br /&gt;
When: November 19th 2009, 7:30PM&lt;br /&gt;
Where: Gina's Pizza, Irvine&lt;br /&gt;
Topics: Facebook privacy, web application firewalls, penetration testing, the reluctance for hackers to execute attacks, and random new technology.  Announced OWASP OC/LAs intention to submit a proposal for AppSec 2010.&lt;br /&gt;
&lt;br /&gt;
====Wednesday, October 14th 2009====&lt;br /&gt;
&lt;br /&gt;
Separate meetings will be held for OWASP OC and OWASP@UCI (student group).&lt;br /&gt;
&lt;br /&gt;
When:  Wednesday 10/14  7:30PM&lt;br /&gt;
Where:  Steelhead Brewery&lt;br /&gt;
Topics:  News, Ideas, Chit-chat&lt;br /&gt;
&lt;br /&gt;
This is a restaurant/bar with plenty of seating, but room for a projector is out of the question so this would be an informal round table discussion.&lt;br /&gt;
&lt;br /&gt;
I have a presentation I'm working on regarding WAFs and Vulnerability Assessment Tools.  If it pleases the group, I'd love to go over the presentation and discuss everyone's experiences.  Also, it's a great way to get feedback :)&lt;br /&gt;
&lt;br /&gt;
Neil&lt;br /&gt;
&lt;br /&gt;
I'm open to suggestions of any kind: location, time, topics, etc&lt;br /&gt;
&lt;br /&gt;
====Thursday, September 17th, 2009 7:30PM ====&lt;br /&gt;
'''Location:''' UC Irvine &lt;br /&gt;
Building: Calit2 building,building number 325 in quadrant H8 on the [http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf UC Irvine Map]&lt;br /&gt;
Room: 3008&lt;br /&gt;
&lt;br /&gt;
Parking will be $7.&lt;br /&gt;
Please park in the [http://maps.google.com/maps?li=d&amp;amp;hl=en&amp;amp;f=d&amp;amp;iwstate1=dir:to&amp;amp;daddr=Parking+Structure+for+CalIT2%4033.643082,+-117.837593&amp;amp;geocode=CSJ9b4xJxrzxFUpaAQId5_D5-A&amp;amp;iwloc=1&amp;amp;dq=calit2,+uc+irvine,+ca&amp;amp;cid=33643082,-117837593,16505793731713499531&amp;amp;ei=v3bvSabfO6LejAOR2pjgAQ Anteater Parking Structure]&lt;br /&gt;
&lt;br /&gt;
I can only unofficially say that if you park in the nearby shopping centers and walk, you may be able to park for free.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;The Rise of Threat Analysis and the Fall of Compliance, Policies, and Standards in mitigating Web Application Security Risks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Apr 30, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Our fourth OC OWASP meeting will be an informal, roundtable discussion of current application security issues. Feel free to bring some ideas, code, slides, etc to contribute to the discussion. Hope to see everyone there!&lt;br /&gt;
&lt;br /&gt;
====Feb 19, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come talk application security at the third OWASP OC meeting. We'll discuss current application security topics and chapter issues over pizza. We have a room booked for 15-20 people so we'll be able to rant without disturbing the patrons :) See you there! [https://www.owasp.org/images/5/58/Cloud_Computing_Security.pdf Presentation Slides]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dec 17, 2008 6PM - 9PM====&lt;br /&gt;
Microsoft Campus&lt;br /&gt;
Room MPR1, 3 Park Plaza, Suite 1600, Irvine, CA, 92614&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=microsoft,+Irvine,+CA,+92614&amp;amp;sll=33.678479,-117.838368&amp;amp;sspn=0.009892,0.022745&amp;amp;g=3+Park+Plaza,+Irvine,+CA,+92614&amp;amp;ie=UTF8&amp;amp;ei=sCFJSfKPEo3UNc2ZmCc&amp;amp;cd=1&amp;amp;cid=33728042,-117783305,17507068988286890825&amp;amp;li=lmd&amp;amp;ll=33.731835,-117.78142&amp;amp;spn=0.039545,0.090981&amp;amp;z=14&amp;amp;iwloc=A Google Map]&lt;br /&gt;
&lt;br /&gt;
This meeting will be a roundtable discussion of application security news, plus a few OWASP-themed challenges with prizes. Pizza will be provided and we'll head to the Yard House after the meeting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Aug 27, 2008, 7 PM - 9 PM====&lt;br /&gt;
Penny Saver&lt;br /&gt;
&lt;br /&gt;
603 Valencia, Brea, CA 92822&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=603+valencia,+Brea,+CA+92822&amp;amp;sll=33.911348,-117.851629&amp;amp;sspn=0.009865,0.022745&amp;amp;ie=UTF8&amp;amp;ll=33.909478,-117.852917&amp;amp;spn=0.009866,0.022745&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come meet up with web security professionals, have some pizza, and offer your thoughts for the direction of the OC chapter at our inaugural meeting! We are looking for speakers and venue sponsors for the next meeting. If you are interested, please contact the chapter leaders. Everyone is welcome to join us at our chapter meetings.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Chapter]]&lt;br /&gt;
&lt;br /&gt;
= Orange County OWASP Board Members =&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County President&amp;lt;/b&amp;gt; [mailto:ron.perris@whitehatsec.com Ron Perris]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Vice-President&amp;lt;/b&amp;gt; Jerry Craft, [mailto:shong.chong@owasp.org Shong Chong]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Treasurer:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Recording Secretary:&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:California]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148902</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148902"/>
				<updated>2013-03-29T16:47:59Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Redirects and Forwards */&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;
This ''Cheatsheet'' intends to provide quick basic Ruby on Rails security tips for developers. It complements, augments or emphasizes points brought up in the [http://guides.rubyonrails.org/security.html rails security guide] from rails core.&lt;br /&gt;
&lt;br /&gt;
The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.  The Ruby Security Reviewer's Guide has a  [http://code.google.com/p/ruby-security/wiki/Guide#Good_ol%27_shell_injection section on injection]  and there are a number of OWASP references for it, starting at the top:  [https://www.owasp.org/index.php/Command_Injection Command Injection].&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].  OWASP has extensive information about [https://www.owasp.org/index.php/SQL_Injection SQL Injection].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
If you must accept HTML content from users, consider a markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This helps ensures that the input accepted doesn’t include HTML content that could be malicious. If you cannot restrict your users from entering HTML, consider implementing content security policy to disallow the execution of any javascript. And finally, consider using the #sanitize method that let's you whitelist allowed tags. Be careful, this method has been shown to be flawed numerous times and will never be a complete solution.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OWASP provides more general information about XSS in a top level page: [https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29 OWASP Cross Site Scripting].&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
There is an [https://www.owasp.org/index.php/Session_Management_Cheat_Sheet OWASP Session Management Cheat Sheet].&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
There is an [https://www.owasp.org/index.php/Authentication_Cheat_Sheet OWASP Authentication Cheat Sheet].&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
More general information about this class of vulnerability is in the [https://www.owasp.org/index.php/Top_10_2010-A4-Insecure_Direct_Object_References OWASP Top 10 Page].&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
There is a top level OWASP page for [https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29 CSRF].&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The most basic, but restrictive protection is to use the :only_path option. Setting this to true will essentially strip out any host information.&lt;br /&gt;
&lt;br /&gt;
    redirect_to params[:url], :only_path =&amp;gt; true&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host    # no validation is needed if we are just using a path, as this will lead to your applications&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
        # you could also check the host value against a whitelist&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
There is a more general OWASP resource about [https://www.owasp.org/index.php/Unvalidated_Redirects_and_Forwards_Cheat_Sheet Unvalidated Redirects and Forwards].&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter).&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))' # this is an example of what NOT to do&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like https://gemcanary.com/ and https://gemnasium.com/.&lt;br /&gt;
&lt;br /&gt;
Another area of tooling is the security testing tool [http://gauntlt.org Gauntlt] which is built on cucumber and uses gherkin syntax to define attack files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose400 [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
* [http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/ Rails Insecure Defaults]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148901</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148901"/>
				<updated>2013-03-29T16:44:39Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Redirects and Forwards */&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;
This ''Cheatsheet'' intends to provide quick basic Ruby on Rails security tips for developers. It complements, augments or emphasizes points brought up in the [http://guides.rubyonrails.org/security.html rails security guide] from rails core.&lt;br /&gt;
&lt;br /&gt;
The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.  The Ruby Security Reviewer's Guide has a  [http://code.google.com/p/ruby-security/wiki/Guide#Good_ol%27_shell_injection section on injection]  and there are a number of OWASP references for it, starting at the top:  [https://www.owasp.org/index.php/Command_Injection Command Injection].&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].  OWASP has extensive information about [https://www.owasp.org/index.php/SQL_Injection SQL Injection].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
If you must accept HTML content from users, consider a markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This helps ensures that the input accepted doesn’t include HTML content that could be malicious. If you cannot restrict your users from entering HTML, consider implementing content security policy to disallow the execution of any javascript. And finally, consider using the #sanitize method that let's you whitelist allowed tags. Be careful, this method has been shown to be flawed numerous times and will never be a complete solution.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OWASP provides more general information about XSS in a top level page: [https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29 OWASP Cross Site Scripting].&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
There is an [https://www.owasp.org/index.php/Session_Management_Cheat_Sheet OWASP Session Management Cheat Sheet].&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
There is an [https://www.owasp.org/index.php/Authentication_Cheat_Sheet OWASP Authentication Cheat Sheet].&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
More general information about this class of vulnerability is in the [https://www.owasp.org/index.php/Top_10_2010-A4-Insecure_Direct_Object_References OWASP Top 10 Page].&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
There is a top level OWASP page for [https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29 CSRF].&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host    # no validation is needed if we are just using a path, as this will lead to your applications&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
        # you could also check the host value against a whitelist&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
There is a more general OWASP resource about [https://www.owasp.org/index.php/Unvalidated_Redirects_and_Forwards_Cheat_Sheet Unvalidated Redirects and Forwards].&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter).&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))' # this is an example of what NOT to do&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like https://gemcanary.com/ and https://gemnasium.com/.&lt;br /&gt;
&lt;br /&gt;
Another area of tooling is the security testing tool [http://gauntlt.org Gauntlt] which is built on cucumber and uses gherkin syntax to define attack files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose400 [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
* [http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/ Rails Insecure Defaults]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unvalidated_Redirects_and_Forwards_Cheat_Sheet&amp;diff=148218</id>
		<title>Unvalidated Redirects and Forwards Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unvalidated_Redirects_and_Forwards_Cheat_Sheet&amp;diff=148218"/>
				<updated>2013-03-20T17:10:43Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Dangerous URL Redirect Example 1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
Unvalidated redirects and forwards are possible when a web application accepts untrusted input that could cause the web application to redirect the request to a URL contained within untrusted input. By modifying untrusted URL input to a malicious site, an attacker may successfully launch a phishing scam and steal user credentials. Because the server name in the modified link is identical to the original site, phishing attempts may have a more trustworthy appearance. Unvalidated redirect and forward attacks can also be used to maliciously craft a URL that would pass the application’s access control check and then forward the attacker to privileged functions that they would normally not be able to access.&lt;br /&gt;
&lt;br /&gt;
= Safe URL Redirects =&lt;br /&gt;
&lt;br /&gt;
When we want to redirect a user automatically to another page (without an action of the visitor such as clicking on a hyperlink) you might implement a code such as the following:&lt;br /&gt;
&lt;br /&gt;
PHP&lt;br /&gt;
  &amp;lt;?php&lt;br /&gt;
  /* Redirect browser */&lt;br /&gt;
  header(&amp;quot;Location: http&amp;amp;#58;//www.mysite.com/&amp;quot;);&lt;br /&gt;
  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ASP.NET&lt;br /&gt;
   Response.Redirect(&amp;quot;~/folder/Login.aspx&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Rails&lt;br /&gt;
    redirect_to login_path&lt;br /&gt;
&lt;br /&gt;
In the examples above, the URL is being explicitly declared in the code and cannot be manipulated by an attacker.&lt;br /&gt;
&lt;br /&gt;
= Dangerous URL Redirects =&lt;br /&gt;
&lt;br /&gt;
The following examples demonstrate unsafe redirect and forward code.&lt;br /&gt;
&lt;br /&gt;
== Dangerous URL Redirect Example 1 ==&lt;br /&gt;
&lt;br /&gt;
The following PHP code obtains a URL from the query string and then redirects the user to that URL.&lt;br /&gt;
  &lt;br /&gt;
  $redirect_url = $_GET['url'];&lt;br /&gt;
  header(&amp;quot;Location: &amp;quot; . $redirect_url);&lt;br /&gt;
  &lt;br /&gt;
A similar example of C# .NET Vulnerable Code:&lt;br /&gt;
	&lt;br /&gt;
  string url = request.QueryString[&amp;quot;url&amp;quot;];&lt;br /&gt;
  Response.Redirect(url);&lt;br /&gt;
&lt;br /&gt;
And in rails:&lt;br /&gt;
   redirect_to params[:url]&lt;br /&gt;
&lt;br /&gt;
The above code is vulnerable to an attack if no validation or extra method controls are applied to verify the certainty of the URL. This vulnerability could be used as part of a phishing scam by redirecting users to a malicious site. If no validation is applied, a malicious user could create a hyperlink to redirect your users to an unvalidated malicious website, for example:&lt;br /&gt;
&lt;br /&gt;
  http&amp;amp;#58;//example.com/example.php?url=http&amp;amp;#58;//malicious.example.com&lt;br /&gt;
&lt;br /&gt;
The user sees the link directing to the original trusted site (example.com) and does not realize the redirection that could take place&lt;br /&gt;
&lt;br /&gt;
== Dangerous URL Redirect Example 2 ==&lt;br /&gt;
&lt;br /&gt;
ASP.NET MVC 1 &amp;amp; 2 websites are particularly vulnerable to open redirection attacks. In order to avoid this vulnerability, you need to apply MVC 3.&lt;br /&gt;
&lt;br /&gt;
The code for the LogOn action in an ASP.NET MVC 2 application is shown below. After a successful login, the controller returns a redirect to the returnUrl. You can see that no validation is being performed against the returnUrl parameter.&lt;br /&gt;
&lt;br /&gt;
Listing 1 – ASP.NET MVC 2 LogOn action in AccountController.cs&lt;br /&gt;
&lt;br /&gt;
  [HttpPost]&lt;br /&gt;
  public ActionResult LogOn(LogOnModel model, string returnUrl)&lt;br /&gt;
  {&lt;br /&gt;
    if (ModelState.IsValid)&lt;br /&gt;
    {&lt;br /&gt;
        if (MembershipService.ValidateUser(model.UserName, model.Password))&lt;br /&gt;
        {&lt;br /&gt;
            FormsService.SignIn(model.UserName, model.RememberMe);&lt;br /&gt;
            if (!String.IsNullOrEmpty(returnUrl))&lt;br /&gt;
            {&lt;br /&gt;
                return Redirect(returnUrl);&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                return RedirectToAction(&amp;quot;Index&amp;quot;, &amp;quot;Home&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            ModelState.AddModelError(&amp;quot;&amp;quot;, &amp;quot;The user name or password provided is incorrect.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    // If we got this far, something failed, redisplay form&lt;br /&gt;
    return View(model);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Dangerous Forward Example ==&lt;br /&gt;
&lt;br /&gt;
When applications allow user input to forward requests between different parts of the site, the application must check that the user is authorized to access the url, perform the functions it provides, and it is an appropriate url request. If the application fails to perform these checks, an attacker crafted URL may pass the application’s access control check and then forward the attacker to an administrative function that is not normally permitted.&lt;br /&gt;
&lt;br /&gt;
http&amp;amp;#58;//www.example.com/function.jsp?fwd=admin.jsp&lt;br /&gt;
&lt;br /&gt;
The following code is a Java servlet that will receive a GET request with a url parameter in the request to redirect the browser to the address specified in the url parameter. The servlet will retrieve the url parameter value from the request and send a response to redirect the browser to the url address.&lt;br /&gt;
&lt;br /&gt;
   public class RedirectServlet extends HttpServlet {&lt;br /&gt;
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {&lt;br /&gt;
      String query = request.getQueryString();&lt;br /&gt;
      if (query.contains(&amp;quot;url&amp;quot;)) {&lt;br /&gt;
       String url = request.getParameter(&amp;quot;url&amp;quot;);&lt;br /&gt;
       response.sendRedirect(url);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
= Preventing Unvalidated Redirects and Forwards =&lt;br /&gt;
&lt;br /&gt;
Safe use of redirects and forwards can be done in a number of ways:&lt;br /&gt;
&lt;br /&gt;
* Simply avoid using redirects and forwards.&lt;br /&gt;
* If used, do not allow the url as user input for the destination. This can usually be done. In this case, you should have a method to validate URL. &lt;br /&gt;
* If user input can’t be avoided, ensure that the supplied &amp;lt;strong&amp;gt;value&amp;lt;/strong&amp;gt; is valid, appropriate for the application, and is &amp;lt;strong&amp;gt;authorized&amp;lt;/strong&amp;gt; for the user.&lt;br /&gt;
* It is recommended that any such destination input be mapped to a value, rather than the actual URL or portion of the URL, and that server side code translate this value to the target URL.&lt;br /&gt;
* Sanitize input by creating a list of trusted URL's (lists of hosts or a regex).&lt;br /&gt;
* Force all redirects to first go through a page notifying users that they are going off of your site, and have them click a link to confirm.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
# OWASP Article on Open Redirects https://www.owasp.org/index.php/Open_redirect&lt;br /&gt;
# CWE Entry 601 on Open Redirects http://cwe.mitre.org/data/definitions/601.html&lt;br /&gt;
# WASC Article on URL Redirector Abuse http://projects.webappsec.org/w/page/13246981/URL%20Redirector%20Abuse&lt;br /&gt;
# Google blog article on the dangers of open redirects http://googlewebmastercentral.blogspot.com/2009/01/open-redirect-urls-is-your-site-being.html&lt;br /&gt;
# Preventing Open Redirection Attacks (C#) http://www.asp.net/mvc/tutorials/security/preventing-open-redirection-attacks&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Susanna Bezold - susanna.bezold[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Johanna Curiel - johanna.curiel[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Unvalidated_Redirects_and_Forwards_Cheat_Sheet&amp;diff=148217</id>
		<title>Unvalidated Redirects and Forwards Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Unvalidated_Redirects_and_Forwards_Cheat_Sheet&amp;diff=148217"/>
				<updated>2013-03-20T17:10:07Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
Unvalidated redirects and forwards are possible when a web application accepts untrusted input that could cause the web application to redirect the request to a URL contained within untrusted input. By modifying untrusted URL input to a malicious site, an attacker may successfully launch a phishing scam and steal user credentials. Because the server name in the modified link is identical to the original site, phishing attempts may have a more trustworthy appearance. Unvalidated redirect and forward attacks can also be used to maliciously craft a URL that would pass the application’s access control check and then forward the attacker to privileged functions that they would normally not be able to access.&lt;br /&gt;
&lt;br /&gt;
= Safe URL Redirects =&lt;br /&gt;
&lt;br /&gt;
When we want to redirect a user automatically to another page (without an action of the visitor such as clicking on a hyperlink) you might implement a code such as the following:&lt;br /&gt;
&lt;br /&gt;
PHP&lt;br /&gt;
  &amp;lt;?php&lt;br /&gt;
  /* Redirect browser */&lt;br /&gt;
  header(&amp;quot;Location: http&amp;amp;#58;//www.mysite.com/&amp;quot;);&lt;br /&gt;
  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ASP.NET&lt;br /&gt;
   Response.Redirect(&amp;quot;~/folder/Login.aspx&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Rails&lt;br /&gt;
    redirect_to login_path&lt;br /&gt;
&lt;br /&gt;
In the examples above, the URL is being explicitly declared in the code and cannot be manipulated by an attacker.&lt;br /&gt;
&lt;br /&gt;
= Dangerous URL Redirects =&lt;br /&gt;
&lt;br /&gt;
The following examples demonstrate unsafe redirect and forward code.&lt;br /&gt;
&lt;br /&gt;
== Dangerous URL Redirect Example 1 ==&lt;br /&gt;
&lt;br /&gt;
The following PHP code obtains a URL from the query string and then redirects the user to that URL.&lt;br /&gt;
  &lt;br /&gt;
  $redirect_url = $_GET['url'];&lt;br /&gt;
  header(&amp;quot;Location: &amp;quot; . $redirect_url);&lt;br /&gt;
  &lt;br /&gt;
A similar example of C# .NET Vulnerable Code:&lt;br /&gt;
	&lt;br /&gt;
  string url = request.QueryString[&amp;quot;url&amp;quot;];&lt;br /&gt;
  Response.Redirect(url);&lt;br /&gt;
&lt;br /&gt;
And in ruby:&lt;br /&gt;
   redirect_to params[:url]&lt;br /&gt;
&lt;br /&gt;
The above code is vulnerable to an attack if no validation or extra method controls are applied to verify the certainty of the URL. This vulnerability could be used as part of a phishing scam by redirecting users to a malicious site. If no validation is applied, a malicious user could create a hyperlink to redirect your users to an unvalidated malicious website, for example:&lt;br /&gt;
&lt;br /&gt;
  http&amp;amp;#58;//example.com/example.php?url=http&amp;amp;#58;//malicious.example.com&lt;br /&gt;
&lt;br /&gt;
The user sees the link directing to the original trusted site (example.com) and does not realize the redirection that could take place&lt;br /&gt;
&lt;br /&gt;
== Dangerous URL Redirect Example 2 ==&lt;br /&gt;
&lt;br /&gt;
ASP.NET MVC 1 &amp;amp; 2 websites are particularly vulnerable to open redirection attacks. In order to avoid this vulnerability, you need to apply MVC 3.&lt;br /&gt;
&lt;br /&gt;
The code for the LogOn action in an ASP.NET MVC 2 application is shown below. After a successful login, the controller returns a redirect to the returnUrl. You can see that no validation is being performed against the returnUrl parameter.&lt;br /&gt;
&lt;br /&gt;
Listing 1 – ASP.NET MVC 2 LogOn action in AccountController.cs&lt;br /&gt;
&lt;br /&gt;
  [HttpPost]&lt;br /&gt;
  public ActionResult LogOn(LogOnModel model, string returnUrl)&lt;br /&gt;
  {&lt;br /&gt;
    if (ModelState.IsValid)&lt;br /&gt;
    {&lt;br /&gt;
        if (MembershipService.ValidateUser(model.UserName, model.Password))&lt;br /&gt;
        {&lt;br /&gt;
            FormsService.SignIn(model.UserName, model.RememberMe);&lt;br /&gt;
            if (!String.IsNullOrEmpty(returnUrl))&lt;br /&gt;
            {&lt;br /&gt;
                return Redirect(returnUrl);&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                return RedirectToAction(&amp;quot;Index&amp;quot;, &amp;quot;Home&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            ModelState.AddModelError(&amp;quot;&amp;quot;, &amp;quot;The user name or password provided is incorrect.&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    // If we got this far, something failed, redisplay form&lt;br /&gt;
    return View(model);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Dangerous Forward Example ==&lt;br /&gt;
&lt;br /&gt;
When applications allow user input to forward requests between different parts of the site, the application must check that the user is authorized to access the url, perform the functions it provides, and it is an appropriate url request. If the application fails to perform these checks, an attacker crafted URL may pass the application’s access control check and then forward the attacker to an administrative function that is not normally permitted.&lt;br /&gt;
&lt;br /&gt;
http&amp;amp;#58;//www.example.com/function.jsp?fwd=admin.jsp&lt;br /&gt;
&lt;br /&gt;
The following code is a Java servlet that will receive a GET request with a url parameter in the request to redirect the browser to the address specified in the url parameter. The servlet will retrieve the url parameter value from the request and send a response to redirect the browser to the url address.&lt;br /&gt;
&lt;br /&gt;
   public class RedirectServlet extends HttpServlet {&lt;br /&gt;
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {&lt;br /&gt;
      String query = request.getQueryString();&lt;br /&gt;
      if (query.contains(&amp;quot;url&amp;quot;)) {&lt;br /&gt;
       String url = request.getParameter(&amp;quot;url&amp;quot;);&lt;br /&gt;
       response.sendRedirect(url);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
= Preventing Unvalidated Redirects and Forwards =&lt;br /&gt;
&lt;br /&gt;
Safe use of redirects and forwards can be done in a number of ways:&lt;br /&gt;
&lt;br /&gt;
* Simply avoid using redirects and forwards.&lt;br /&gt;
* If used, do not allow the url as user input for the destination. This can usually be done. In this case, you should have a method to validate URL. &lt;br /&gt;
* If user input can’t be avoided, ensure that the supplied &amp;lt;strong&amp;gt;value&amp;lt;/strong&amp;gt; is valid, appropriate for the application, and is &amp;lt;strong&amp;gt;authorized&amp;lt;/strong&amp;gt; for the user.&lt;br /&gt;
* It is recommended that any such destination input be mapped to a value, rather than the actual URL or portion of the URL, and that server side code translate this value to the target URL.&lt;br /&gt;
* Sanitize input by creating a list of trusted URL's (lists of hosts or a regex).&lt;br /&gt;
* Force all redirects to first go through a page notifying users that they are going off of your site, and have them click a link to confirm.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
# OWASP Article on Open Redirects https://www.owasp.org/index.php/Open_redirect&lt;br /&gt;
# CWE Entry 601 on Open Redirects http://cwe.mitre.org/data/definitions/601.html&lt;br /&gt;
# WASC Article on URL Redirector Abuse http://projects.webappsec.org/w/page/13246981/URL%20Redirector%20Abuse&lt;br /&gt;
# Google blog article on the dangers of open redirects http://googlewebmastercentral.blogspot.com/2009/01/open-redirect-urls-is-your-site-being.html&lt;br /&gt;
# Preventing Open Redirection Attacks (C#) http://www.asp.net/mvc/tutorials/security/preventing-open-redirection-attacks&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Susanna Bezold - susanna.bezold[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Johanna Curiel - johanna.curiel[at]owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148081</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=148081"/>
				<updated>2013-03-18T18:48:55Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Cross-site Scripting (XSS) */&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;
This article intends to provide quick basic Ruby on Rails security tips for developers. The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
If you must accept HTML content from users, consider a markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This helps ensures that the input accepted doesn’t include HTML content that could be malicious. If you cannot restrict your users from entering HTML, consider implementing content security policy to disallow the execution of any javascript. And finally, consider using the #sanitize method that let's you whitelist allowed tags. Be careful, this method has been shown to be flawed numerous times and will never be a complete solution.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter).&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))' # this is an example of what NOT to do&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like [http://sourceninja.com SourceNinja].&lt;br /&gt;
&lt;br /&gt;
Another area of tooling is the security testing tool [http://gauntlt.org Gauntlt] which is built on cucumber and uses gherkin syntax to define attack files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose400 [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144423</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144423"/>
				<updated>2013-02-14T17:59:50Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Attack Surface */&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;
This article intends to provide quick basic Ruby on Rails security tips for developers. The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
One way to manage cases like this is to use a Rails provided helper method called sanitize:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= sanitize @project.name, :tags =&amp;gt; %w(h1 h2 h3 h4 h5), :attributes =&amp;gt; %() %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This eliminates tags other than &amp;lt;nowiki&amp;gt;&amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt;&amp;lt;/nowiki&amp;gt;.  It also disallows attributes on those tags.  Note that it is critical to understand the tags you enable here.  &amp;lt;nowiki&amp;gt;&amp;lt;img&amp;gt;&amp;lt;/nowiki&amp;gt; may seem like an innocuous tag, but through various attributes on &amp;lt;nowiki&amp;gt;&amp;lt;img/&amp;gt;&amp;lt;/nowiki&amp;gt; that are scriptable such as onError=””.  Only by sanitizing only innocuous tags can XSS be prevented.&lt;br /&gt;
&lt;br /&gt;
A more attractive alternative to using sanitize and real HTML content is to use an alternative markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This ensures that the input accepted doesn’t include HTML content that could be malicious.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter).&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))' # this is an example of what NOT to do&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like [http://sourceninja.com SourceNinja].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose [at] crowdsecurify.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144420</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144420"/>
				<updated>2013-02-14T17:55:50Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Security-related headers */&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;
This article intends to provide quick basic Ruby on Rails security tips for developers. The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
One way to manage cases like this is to use a Rails provided helper method called sanitize:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= sanitize @project.name, :tags =&amp;gt; %w(h1 h2 h3 h4 h5), :attributes =&amp;gt; %() %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This eliminates tags other than &amp;lt;nowiki&amp;gt;&amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt;&amp;lt;/nowiki&amp;gt;.  It also disallows attributes on those tags.  Note that it is critical to understand the tags you enable here.  &amp;lt;nowiki&amp;gt;&amp;lt;img&amp;gt;&amp;lt;/nowiki&amp;gt; may seem like an innocuous tag, but through various attributes on &amp;lt;nowiki&amp;gt;&amp;lt;img/&amp;gt;&amp;lt;/nowiki&amp;gt; that are scriptable such as onError=””.  Only by sanitizing only innocuous tags can XSS be prevented.&lt;br /&gt;
&lt;br /&gt;
A more attractive alternative to using sanitize and real HTML content is to use an alternative markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This ensures that the input accepted doesn’t include HTML content that could be malicious.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter).&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))'&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like [http://sourceninja.com SourceNinja].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose [at] crowdsecurify.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144419</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144419"/>
				<updated>2013-02-14T17:55:06Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &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;
This article intends to provide quick basic Ruby on Rails security tips for developers. The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
One way to manage cases like this is to use a Rails provided helper method called sanitize:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= sanitize @project.name, :tags =&amp;gt; %w(h1 h2 h3 h4 h5), :attributes =&amp;gt; %() %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This eliminates tags other than &amp;lt;nowiki&amp;gt;&amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt;&amp;lt;/nowiki&amp;gt;.  It also disallows attributes on those tags.  Note that it is critical to understand the tags you enable here.  &amp;lt;nowiki&amp;gt;&amp;lt;img&amp;gt;&amp;lt;/nowiki&amp;gt; may seem like an innocuous tag, but through various attributes on &amp;lt;nowiki&amp;gt;&amp;lt;img/&amp;gt;&amp;lt;/nowiki&amp;gt; that are scriptable such as onError=””.  Only by sanitizing only innocuous tags can XSS be prevented.&lt;br /&gt;
&lt;br /&gt;
A more attractive alternative to using sanitize and real HTML content is to use an alternative markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This ensures that the input accepted doesn’t include HTML content that could be malicious.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing ==&lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Security-related headers ==&lt;br /&gt;
&lt;br /&gt;
To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter.&lt;br /&gt;
&lt;br /&gt;
  response.headers['X-header-name'] = 'value'&lt;br /&gt;
&lt;br /&gt;
'''Rails 4''' provides the &amp;quot;default_headers&amp;quot; functionality that will automatically apply the values supplied. This works for most headers in almost all cases.  Note: this does not account for content security policy.&lt;br /&gt;
&lt;br /&gt;
  ActionDispatch::Response.default_headers = {	  	&lt;br /&gt;
    'X-Frame-Options' =&amp;gt; 'DENY', 	&lt;br /&gt;
    'X-Content-Type-Options' =&amp;gt; 'nosniff',	  	&lt;br /&gt;
    'X-XSS-Protection' =&amp;gt; '1;'&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Strict transport security is a special case, it is set in an environment file (e.g. production.rb)&lt;br /&gt;
&lt;br /&gt;
  config.force_ssl = true&lt;br /&gt;
&lt;br /&gt;
For those not on the edge, there is a library ([https://github.com/twitter/secureheaders secure_headers]) for the same behavior with content security policy abstraction provided. It will automatically apply logic based on the user agent to produce a concise set of headers.&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))'&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like [http://sourceninja.com SourceNinja].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose [at] crowdsecurify.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144416</id>
		<title>Ruby on Rails Cheatsheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Ruby_on_Rails_Cheatsheet&amp;diff=144416"/>
				<updated>2013-02-14T17:40:37Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Insecure Direct Object Reference or Forceful Browsing */&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;
This article intends to provide quick basic Ruby on Rails security tips for developers. The Rails framework abstracts developers from quite a bit of tedious work and provides the means to accomplish complex tasks quickly and with ease. New developers, those unfamiliar with the inner-workings of Rails, likely need a basic set of guidelines to secure fundamental aspects of their application. The intended purpose of this doc is to be that guide.&lt;br /&gt;
&lt;br /&gt;
= Items =&lt;br /&gt;
== Command Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby offers a function called “eval” which will dynamically build new Ruby code based on Strings.  It also has a number of ways to call system commands.&lt;br /&gt;
 &lt;br /&gt;
   eval(&amp;quot;ruby code here&amp;quot;)&lt;br /&gt;
   System(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
   `ls -al /`   (backticks contain os command)&lt;br /&gt;
   Kernel.exec(&amp;quot;os command here&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
While the power of these commands is quite useful, extreme care should be taken when using them in a Rails based application.  Usually, its just a bad idea.  If need be, a whitelist of possible values should be used and any input should be validated as thoroughly as possible.&lt;br /&gt;
&lt;br /&gt;
== SQL Injection == &lt;br /&gt;
&lt;br /&gt;
Ruby on Rails is often used with an ORM called ActiveRecord, though it is flexible and can be used with other data sources.  Typically very simple Rails applications use methods on the Rails models to query data.  Many use cases protect for SQL Injection out of the box.  However, it is possible to write code that allows for SQL Injection.  &lt;br /&gt;
&lt;br /&gt;
Here is an example (Rails 2.X style):&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; “name like #{params[:name]}”)&lt;br /&gt;
&lt;br /&gt;
A Rails 3.X example:&lt;br /&gt;
&lt;br /&gt;
    name = params[:name]&lt;br /&gt;
    @projects = Project.where(“name like ‘“ + name + “‘“);&lt;br /&gt;
&lt;br /&gt;
In both of these cases, the statement is injectable because the name parameter is not escaped.  &lt;br /&gt;
&lt;br /&gt;
Here is the idiom for building this kind of statement:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.find(:all, :conditions =&amp;gt; [ “name like ?”, “#{params[:name]}”] )&lt;br /&gt;
&lt;br /&gt;
An AREL based solution:&lt;br /&gt;
&lt;br /&gt;
    @projects = Project.where(&amp;quot;name like ?&amp;quot;, &amp;quot;%#{params[:name]}%&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Use caution not to build SQL statements based on user controlled input.  A list of more realistic and detailed examples is here: [http://rails-sqli.org rails-sqli.org].&lt;br /&gt;
&lt;br /&gt;
== Cross-site Scripting (XSS) == &lt;br /&gt;
&lt;br /&gt;
By default, in Rails 3.0 protection against XSS comes as the default behavior.  When string data is shown in views, it is escaped prior to being sent back to the browser.  This goes a long way, but there are common cases where developers bypass this protection - for example to enable rich text editing.  In the event that you want to pass variables to the front end with tags intact, it is tempting to do the following in your .erb file (ruby markup).&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= raw @product.name %&amp;gt;   &lt;br /&gt;
    &amp;lt;%= @product.name.html_safe %&amp;gt;       These are examples of how NOT to do it!&lt;br /&gt;
    &amp;lt;%= content_tag @product.name %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, any field that uses raw like this will be a potential XSS target.  Note that there are also widespread misunderstandings about html_safe.  [http://stackoverflow.com/questions/4251284/raw-vs-html-safe-vs-h-to-unescape-html This writeup] describes the underlying SafeBuffer mechanism in detail.  Other tags that change the way strings are prepared for output can introduce similar issues, including content_tag.&lt;br /&gt;
&lt;br /&gt;
One way to manage cases like this is to use a Rails provided helper method called sanitize:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= sanitize @project.name, :tags =&amp;gt; %w(h1 h2 h3 h4 h5), :attributes =&amp;gt; %() %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This eliminates tags other than &amp;lt;nowiki&amp;gt;&amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, &amp;lt;h3&amp;gt;, &amp;lt;h4&amp;gt;, &amp;lt;h5&amp;gt;&amp;lt;/nowiki&amp;gt;.  It also disallows attributes on those tags.  Note that it is critical to understand the tags you enable here.  &amp;lt;nowiki&amp;gt;&amp;lt;img&amp;gt;&amp;lt;/nowiki&amp;gt; may seem like an innocuous tag, but through various attributes on &amp;lt;nowiki&amp;gt;&amp;lt;img/&amp;gt;&amp;lt;/nowiki&amp;gt; that are scriptable such as onError=””.  Only by sanitizing only innocuous tags can XSS be prevented.&lt;br /&gt;
&lt;br /&gt;
A more attractive alternative to using sanitize and real HTML content is to use an alternative markup language for rich text in an application (Examples include:  markdown and textile) and disallow HTML tags. This ensures that the input accepted doesn’t include HTML content that could be malicious.&lt;br /&gt;
&lt;br /&gt;
An often overlooked XSS attack vector is the href value of a link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;%= link_to “Personal Website”, @user.website %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If @user.website contains a link that starts with “javascript:”, the content will execute when a user clicks the generated link:&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;a href=”javascript:alert(‘Haxored’)”&amp;gt;Personal Website&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails uses a Cookie based session store.  What that means is that unless you change something, the session will not expire on the server.  That means that some default applications may be vulnerable to replay attacks.  It also means that sensitive information should never be put in the session.&lt;br /&gt;
&lt;br /&gt;
The best practice is to use a database based session, which thankfully is very easy with Rails:&lt;br /&gt;
&lt;br /&gt;
    Project::Application.config.session_store :active_record_store&lt;br /&gt;
&lt;br /&gt;
== Authentication == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails does not provide authentication by itself.  However, most developers using Rails leverage libraries such as Devise or AuthLogic to provide authentication.  To enable authentication with Devise, one simply has to put the following in a controller:&lt;br /&gt;
&lt;br /&gt;
    class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
        before_filter :authenticate_user&lt;br /&gt;
&lt;br /&gt;
As with other methods, this supports exceptions.  Note that by default Devise only requires 6 characters for a password.  The minimum can be changed in:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.password_length = 8..128&lt;br /&gt;
&lt;br /&gt;
There are several possible ways to enforce complexity.  One is to put a Validator in the user model.&lt;br /&gt;
      &lt;br /&gt;
    validate :password_complexity&lt;br /&gt;
    def password_complexity&lt;br /&gt;
       if password.present? and not password.match(/\A(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+\z/)&lt;br /&gt;
           errors.add :password, &amp;quot;must include at least one lowercase letter, one uppercase letter, and one digit&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Insecure Direct Object Reference or Forceful Browsing == &lt;br /&gt;
&lt;br /&gt;
By default, Ruby on Rails apps use a RESTful uri structure.  That means that paths are often intuitive and guessable.  To protect against a user trying to access or modify data that belongs to another user, it is important to specifically control actions.  Out of the gate on a vanilla Rails application, there is no such built in protection.  It is possible to do this by hand at the controller level.  &lt;br /&gt;
&lt;br /&gt;
It is also possible, and probably recommended, to consider resource-based access control libraries such as [https://github.com/ryanb/cancan cancan] to do this. This ensures that all operations on a database object are authorized by the business logic of the application.&lt;br /&gt;
&lt;br /&gt;
== CSRF (Cross Site Request Forgery) ==&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails has specific, built in support for CSRF tokens.  To enable it, or ensure that it is enabled, find the base ApplicationController and look for a directive such as the following:&lt;br /&gt;
&lt;br /&gt;
    class ApplicationController &amp;lt; ActionController::Base&lt;br /&gt;
        protect_from_forgery&lt;br /&gt;
&lt;br /&gt;
Note that the syntax for this type of control includes a way to add exceptions.  Exceptions may be useful for API’s or other reasons - but should be reviewed and consciously included.  In the example below, the Rails ProjectController will not provide CSRF protection for the show method.&lt;br /&gt;
&lt;br /&gt;
   class ProjectController &amp;lt; ApplicationController&lt;br /&gt;
       protect_from_forgery :except =&amp;gt; :show&lt;br /&gt;
&lt;br /&gt;
Also note that by default Rails does not provide CSRF protection for any HTTP GET request.&lt;br /&gt;
&lt;br /&gt;
== Mass Assignment and Strong Parameters == &lt;br /&gt;
&lt;br /&gt;
Although the major issue with Mass Assignment has been fixed by default in base Rails specifically when generating new projects, it still applies to older and upgraded projects so it is important to understand the issue and to ensure that only attributes that are intended to be modifiable are exposed.&lt;br /&gt;
&lt;br /&gt;
When working with a model, the attributes on the model will not be accessible to forms being posted unless a programmer explicitly indicates that:&lt;br /&gt;
&lt;br /&gt;
    class Project &amp;lt; ActiveRecord::Base&lt;br /&gt;
        attr_accessible :name, :admin&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
With the admin attribute accessible based on the example above, the following could work:&lt;br /&gt;
&lt;br /&gt;
    curl -d “project[name]=triage&amp;amp;project[admin]=1” host:port/projects&lt;br /&gt;
&lt;br /&gt;
Review accessible attributes to ensure that they should be accessible.  If you are working in Rails &amp;lt; 3.2.3 you should ensure that your attributes are whitelisted with the following:&lt;br /&gt;
&lt;br /&gt;
    config.active_record.whitelist_attributes = true&lt;br /&gt;
&lt;br /&gt;
In Rails 4.0 strong parameters will be the recommended approach for handling attribute visibility. It is also possible to use the strong_parameters gem with Rails 3.x, and the strong_parameters_rails2 gem for Rails 2.3.x applications.&lt;br /&gt;
&lt;br /&gt;
== Redirects and Forwards == &lt;br /&gt;
&lt;br /&gt;
Web applications often require the ability to dynamically redirect users based on client-supplied data. To clarify, dynamic redirection usually entails the client including a URL in a parameter within a request to the application. Once received by the application, the user is redirected to the URL specified in the request. For example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://www.example_commerce_site.com/checkout&lt;br /&gt;
&lt;br /&gt;
The above request would redirect the user to http://www.example.com/checkout.  The security concern associated with this functionality is leveraging an organization’s trusted brand to phish users and trick them into visiting a malicious site, in our example, “badhacker.com”.  Example:&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=http://badhacker.com&lt;br /&gt;
&lt;br /&gt;
The obvious fix for this type of vulnerability is to restrict to specific Top-Level Domains (TLDs), statically define specific sites, or map a key to it’s value. Example:&lt;br /&gt;
&lt;br /&gt;
    ACCEPTABLE_URLS = {&lt;br /&gt;
        ‘our_app_1’ =&amp;gt; “https://www.example_commerce_site.com/checkout”,&lt;br /&gt;
        ‘our_app_2’ =&amp;gt; “https://www.example_user_site.com/change_settings”&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
http://www.example.com/redirect?url=our_app_1&lt;br /&gt;
&lt;br /&gt;
   def redirect&lt;br /&gt;
       url = ACCEPTABLE_URLS[“#{params[:url]}”]&lt;br /&gt;
       redirect_to url if url&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
If matching user input against a list of approved sites or TLDs against regular expression is a must, it makes sense to leverage a library such as URI.parse() to obtain the host and then take the host value and match it against regular expression patterns. Those regular expressions must, at a minimum, have anchors or there is a greater chance of an attacker bypassing the validation routine.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
    require ‘uri’&lt;br /&gt;
    host = URI.parse(“#{params[:url]}”).host&lt;br /&gt;
    validation_routine(host) if host&lt;br /&gt;
    def validation_routine(host)&lt;br /&gt;
        # Validation routine where we use  \A and \z as anchors *not* ^ and $&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Dynamic Render Paths == &lt;br /&gt;
&lt;br /&gt;
In Rails, controller actions and views can dynamically determine which view or partial to render by calling the “render” method. If user input is used in or for the template name, an attacker could cause the application to render an arbitrary view, such as an administrative page.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when using user input to determine which view to render. If possible, avoid any user input in the name or path to the view.&lt;br /&gt;
&lt;br /&gt;
== Cross Origin Resource Sharing == &lt;br /&gt;
&lt;br /&gt;
Occasionally, a need arises to share resources with another domain. For example, a file-upload function that sends data via an AJAX request to another domain. In these cases, the same-origin rules followed by web browsers must be bent. Modern browsers, in compliance with HTML5 standards, will allow this to occur but in order to do this; a couple precautions must be taken.&lt;br /&gt;
&lt;br /&gt;
When using a nonstandard HTTP construct, such as an atypical Content-Type header, for example, the following applies:&lt;br /&gt;
&lt;br /&gt;
The receiving site should whitelist only those domains allowed to make such requests as well as set the Access-Control-Allow-Origin header in both the response to the OPTIONS request and POST request. This is because the OPTIONS request is sent first, in order to determine if the remote or receiving site allows the requesting domain. Next, a second request, a POST request, is sent. Once again, the header must be set in order for the transaction to be shown as successful.&lt;br /&gt;
&lt;br /&gt;
When standard HTTP constructs are used:&lt;br /&gt;
&lt;br /&gt;
The request is sent and the browser, upon receiving a response, inspects the response headers in order to determine if the response can and should be processed.&lt;br /&gt;
&lt;br /&gt;
Note: Do NOT do use the wildcard in the access control header as it allows communication with any site.&lt;br /&gt;
    Access-Control-Allow-Origin: *       (Bad example)&lt;br /&gt;
&lt;br /&gt;
Whitelist in Rails:&lt;br /&gt;
&lt;br /&gt;
Gemfile&lt;br /&gt;
    gem 'rack-cors', :require =&amp;gt; 'rack/cors'&lt;br /&gt;
&lt;br /&gt;
config/application.rb&lt;br /&gt;
    module Sample&lt;br /&gt;
        class Application &amp;lt; Rails::Application&lt;br /&gt;
            config.middleware.use Rack::Cors do&lt;br /&gt;
                allow do&lt;br /&gt;
                    origins 'someserver.example.com'&lt;br /&gt;
                    resource %r{/users/\d+.json},&lt;br /&gt;
                        :headers =&amp;gt; ['Origin', 'Accept', 'Content-Type'],&lt;br /&gt;
                        :methods =&amp;gt; [:post, :get]&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Business Logic Bugs ==&lt;br /&gt;
&lt;br /&gt;
Any application in any technology can contain business logic errors that result in security bugs.  Business logic bugs are difficult to impossible to detect using automated tools.  The best ways to prevent business logic security bugs are to do code review, pair program and write unit tests.&lt;br /&gt;
&lt;br /&gt;
== Attack Surface == &lt;br /&gt;
&lt;br /&gt;
Generally speaking, Rails avoids open redirect and path traversal types of vulnerabilities because of its /config/routes.rb file which dictates what URL’s should be accessible and handled by which controllers.  The routes file is a great place to look when thinking about the scope of the attack surface.  An example might be as follows:&lt;br /&gt;
&lt;br /&gt;
    match ':controller(/:action(/:id(.:format)))'&lt;br /&gt;
&lt;br /&gt;
In this case, this route allows any public method on any controller to be called as an action.  As a developer, you want to make sure that users can only reach the controller methods intended and in the way intended.&lt;br /&gt;
&lt;br /&gt;
== Sensitive Files == &lt;br /&gt;
&lt;br /&gt;
Many Ruby on Rails apps are open source and hosted on publicly available source code repositories.  Whether that is the case or the code is committed to a corporate source control system, there are certain files that should be either excluded or carefully managed.&lt;br /&gt;
&lt;br /&gt;
    /config/database.yml                 -  May contain production credentials.&lt;br /&gt;
    /config/initializers/secret_token.rb -  Contains a secret used to hash session cookie.&lt;br /&gt;
    /db/seeds.rb                         -  May contain seed data including bootstrap admin user.&lt;br /&gt;
    /db/development.sqlite3              -  May contain real data. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption == &lt;br /&gt;
&lt;br /&gt;
Rails uses OS encryption.  Generally speaking, it is always a bad idea to write your own encryption.&lt;br /&gt;
&lt;br /&gt;
Devise by default uses bcrypt for password hashing, which is an appropriate solution.  Typically, the following config causes the 10 stretches for production:  /config/initializers/devise.rb&lt;br /&gt;
&lt;br /&gt;
    config.stretches = Rails.env.test? ? 1 : 10&lt;br /&gt;
&lt;br /&gt;
= Updating Rails and Having a Process for Updating Dependencies = &lt;br /&gt;
&lt;br /&gt;
In early 2013, a number of critical vulnerabilities were identified in the Rails Framework.  Organizations that had fallen behind current versions had more trouble updating and harder decisions along the way, including patching the source code for the framework itself.&lt;br /&gt;
&lt;br /&gt;
An additional concern with Ruby applications in general is that most libraries (gems) are not signed by their authors.  It is literally impossible to build a Rails based project with libraries that come from trusted sources.  One good practice might be to audit the gems you are using.&lt;br /&gt;
&lt;br /&gt;
In general, it is important to have a process for updating dependencies.  An example process might define three mechanisms for triggering an update of response: &lt;br /&gt;
* Every month/quarter dependencies in general are updated.&lt;br /&gt;
* Every week important security vulnerabilities are taken into account and potentially trigger an update.&lt;br /&gt;
* In EXCEPTIONAL conditions, emergency updates may need to be applied.&lt;br /&gt;
&lt;br /&gt;
= Tools =&lt;br /&gt;
&lt;br /&gt;
Use [http://brakemanscanner.org/ brakeman], an open source code analysis tool for Rails applications, to identify many potential issues.  It will not necessarily produce comprehensive security findings, but it can find easily exposed issues.  A great way to see potential issues in Rails is to review the brakeman documentation of warning types.&lt;br /&gt;
&lt;br /&gt;
There are emerging tools that can be used to track security issues in dependency sets, like [http://sourceninja.com SourceNinja].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors = &lt;br /&gt;
Matt Konda - mkonda [at] jemurai.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Neil Matatall neil [at] matatall.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Ken Johnson cktricky [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Justin Collins justin [at] presidentbeef.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Rose - jrose [at] crowdsecurify.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Lance Vaughn - lance [at] cabforward.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jon Claudius - jonathan.claudius [at] gmail.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico jim [at] owasp.org&amp;lt;br/&amp;gt;&lt;br /&gt;
Aaron Bedra aaron [at] aaronbedra.com&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Related Articles and References = &lt;br /&gt;
&lt;br /&gt;
* [http://guides.rubyonrails.org/security.html The Official Rails Security Guide]&lt;br /&gt;
* [https://www.owasp.org/index.php/Category:OWASP_Ruby_on_Rails_Security_Guide_V2 OWASP Ruby on Rails Security Guide]&lt;br /&gt;
* [http://code.google.com/p/ruby-security/wiki/Guide The Ruby Security Reviewers Guide]&lt;br /&gt;
* [https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-security The Ruby on Rails Security Mailing List]&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=143219</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=143219"/>
				<updated>2013-01-31T21:35:12Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* RULE #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform. The OWASP [[ESAPI]] project has created an escaping library in a variety of languages including Java, PHP, Classic ASP, Cold Fusion, Python, and Haskell. The OWASP project also provides the [[OWASP Java Encoder Project]] and the [[OWASP Encoding Project]].&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.  &lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script id=&amp;quot;init_data&amp;quot; type=&amp;quot;application/json&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= data.to_json %&amp;gt;  &amp;amp;lt;-- data is HTML escaped, or at least json entity escaped --&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
    var jsonText = document.getElementById('init_data').innerHTML;  // unescapes the content of the span&lt;br /&gt;
    var initData = JSON.parse(jsonText); &lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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;
'''OWASP AntiSamy'''&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;
'''OWASP Java HTML Sanitizer'''&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| TODO&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=141872</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=141872"/>
				<updated>2013-01-05T01:32:18Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* RULE #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform. The OWASP [[ESAPI]] project has created an escaping library in a variety of languages including Java, PHP, Classic ASP, Cold Fusion, Python, and Haskell. The OWASP project also provides the [[OWASP Java Encoder Project]] and the [[OWASP Encoding Project]].&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;amp;apos; not recommended because its not in the HTML spec (See: [http://www.w3.org/TR/html4/sgml/entities.html section 24.4.1]) &amp;amp;amp;apos; is in the XML and XHTML specs.&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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.  &lt;br /&gt;
&lt;br /&gt;
A common '''anti-pattern''' one would see:&lt;br /&gt;
&lt;br /&gt;
    &amp;amp;lt;script&amp;gt;&lt;br /&gt;
      var initData = &amp;lt;%= data.to_json %&amp;gt;; // '''Do NOT do this.'''&lt;br /&gt;
    &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instead, consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;span style=&amp;quot;display:none&amp;quot; id=&amp;quot;init_data&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= data.to_json %&amp;gt;  &amp;amp;lt;-- data is HTML escaped --&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
    var jsonText = document.getElementById('init_data').innerHTML;  // unescapes the content of the span&lt;br /&gt;
    var initData = JSON.parse(jsonText); &lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.&lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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;
'''OWASP AntiSamy'''&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;
'''OWASP Java HTML Sanitizer'''&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| TODO&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet&amp;diff=137511</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=137511"/>
				<updated>2012-10-11T00:21:51Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* XSS Prevention Rules */&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;
Both [[XSS#Stored_and_Reflected_XSS_Attacks | reflected and stored XSS]] can be addressed by performing the appropriate validation and escaping on the server-side. [[DOM Based XSS]] can be addressed with a special subset of rules described in the [[DOM based XSS Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
For a cheatsheet on the attack vectors related to XSS, please refer to the [[XSS Filter Evasion Cheat Sheet]]. 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;
Before reading this cheatsheet, it is important to have a fundamental understanding of [[Injection Theory]].&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;
== 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;
== 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;
Microsoft provides an encoding library named the [http://wpl.codeplex.com Microsoft Anti-Cross Site Scripting Library] for the .NET platform. The OWASP [[ESAPI]] project has created an escaping library in a variety of languages including Java, PHP, Classic ASP, Cold Fusion, Python, and Haskell. The OWASP project also provides the [[OWASP Java Encoder Project]] and the [[OWASP Encoding Project]].&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;
== 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. This includes &amp;quot;nested contexts&amp;quot; like a URL inside a javascript -- the encoding rules for those locations are tricky and dangerous.  If you insist on putting untrusted data into nested contexts, please do a lot of cross-browser testing and let us know what you find out.&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;
  &amp;amp;lt;style&amp;gt;'''...NEVER PUT UNTRUSTED DATA HERE...'''&amp;lt;/style&amp;gt;   directly in CSS&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;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;
== 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;
== RULE #3 - JavaScript Escape Before Inserting Untrusted Data into JavaScript Data Values ==&lt;br /&gt;
&lt;br /&gt;
Rule #3 concerns dynamically generated JavaScript code - both script blocks and event-handler attributes. The only safe place to put untrusted data into this code is inside a quoted &amp;quot;data value.&amp;quot;  Including untrusted data inside any other JavaScript context is quite dangerous, as it is extremely easy to switch into an execution context with characters including (but not limited to) semi-colon, equals, space, plus, and many more, 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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
If an event handler is properly quoted, breaking out requires the corresponding quote. However, we have intentionally made this rule quite broad because event handler attributes are often left unquoted.  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 #3.1 - HTML escape JSON values in an HTML context and read the data with JSON.parse ===&lt;br /&gt;
&lt;br /&gt;
In a Web 2.0 world, the need for having data dynamically generated by an application in a javascript context is common.  One strategy is to make an AJAX call to get the values, but this isn't always performant.  Often, an initial block of JSON is loaded into the page to act as a single place to store multiple values.  This data is tricky, though not impossible, to escape correctly without breaking the format and content of the values.  Instead, consider placing the JSON block on the page as a normal element and then parsing the innerHTML to get the contents.  The javascript that reads the span can live in an external file, thus making the implementation of CSP enforcement easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;span style=&amp;quot;display:none&amp;quot; id=&amp;quot;init_data&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;amp;lt;%= data.to_json %&amp;gt;  &amp;amp;lt;-- data is HTML escaped --&amp;gt;&lt;br /&gt;
  &amp;amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;script&amp;gt;&lt;br /&gt;
    var jsonText = document.getElementById('init_data').innerHTML;  // unescapes the content of the span&lt;br /&gt;
    var initData = JSON.parse(jsonText); &lt;br /&gt;
  &amp;amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The data is added to the page and is HTML entity escaped so it won't pop in the HTML context.  The data is then read by innerHTML, which unescapes the value.  The unescaped text from the page is then parsed with JSON.parse.  &lt;br /&gt;
&lt;br /&gt;
== RULE #4 - CSS Escape And Strictly Validate 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;
Please note there are some CSS contexts that can never safely use untrusted data as input - &amp;lt;b&amp;gt;EVEN IF PROPERLY CSS ESCAPED&amp;lt;/b&amp;gt;! You will have to ensure that URLs only start with &amp;quot;http&amp;quot; not &amp;quot;javascript&amp;quot; and that properties never start with &amp;quot;expression&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
  { background-url : &amp;quot;javascript:alert(1)&amp;quot;; }  // and all other URLs&lt;br /&gt;
  { text-size: &amp;quot;expression(alert('XSS'))&amp;quot;; }   // only in IE&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. These escaping shortcuts are also susceptible to &amp;quot;escape-the-escape&amp;quot; attacks where the attacker sends \&amp;quot; and the vulnerable code turns that into \\&amp;quot; which enables the quote.&lt;br /&gt;
&lt;br /&gt;
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 and validation 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;
'''OWASP AntiSamy'''&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;
'''OWASP Java HTML Sanitizer'''&lt;br /&gt;
&lt;br /&gt;
   import org.owasp.html.Sanitizers;&lt;br /&gt;
   import org.owasp.html.PolicyFactory;&lt;br /&gt;
   PolicyFactory sanitizer = Sanitizers.FORMATTING.and(Sanitizers.BLOCKS);&lt;br /&gt;
   String cleanResults = sanitizer.sanitize(&amp;quot;&amp;amp;lt;p&amp;amp;gt;Hello, &amp;amp;lt;b&amp;amp;gt;World!&amp;amp;lt;/b&amp;amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
For more information on OWASP Java HTML Sanitizer policy construction, see [http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html http://owasp-java-html-sanitizer.googlecode.com/svn/trunk/distrib/javadoc/org/owasp/html/Sanitizers.html]&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 Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
== Bonus Rule: Use 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.  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;
= XSS Prevention Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The following snippets of HTML demonstrate how to safely render untrusted data in a variety of different contexts. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Data Type&lt;br /&gt;
! Context&lt;br /&gt;
! Code Sample&lt;br /&gt;
! Defense&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;amp;lt;/span&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Safe HTML Attributes&lt;br /&gt;
| &amp;amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;fname&amp;quot; value=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes Aggressive HTML Entity Encoding]&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Only place untrusted data into a whitelist of safe attributes (listed below).&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Strictly validate unsafe attributes such as background, id and name.&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| GET Parameter&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;/site/search?value=&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.235_-_URL_Escape_Before_Inserting_Untrusted_Data_into_HTML_URL_Parameter_Values URL Encoding]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| Untrusted URL in a SRC or HREF attribute&lt;br /&gt;
| &amp;amp;lt;a href=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot;&amp;gt;clickme&amp;amp;lt;/a&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;iframe src=&amp;quot;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED URL&amp;lt;/span&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Cannonicalize input&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;URL Validation&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Safe URL verification&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Whitelist http and https URL's only ([[Avoid the JavaScript Protocol to Open a new Window]])&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Attribute encoder&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| CSS Value&lt;br /&gt;
| &amp;amp;lt;div style=&amp;quot;width: &amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;;&amp;quot;&amp;gt;Selection&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.234_-_CSS_Escape_And_Strictly_Validate_Before_Inserting_Untrusted_Data_into_HTML_Style_Property_Values Strict structural validation]&amp;lt;li&amp;gt;CSS Hex encoding&amp;lt;li&amp;gt;Good design of CSS Features&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| JavaScript Variable&lt;br /&gt;
| &amp;amp;lt;script&amp;gt;var currentValue='&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;';&amp;amp;lt;/script&amp;gt;&amp;lt;br/&amp;gt;&amp;amp;lt;script&amp;gt;someFunction('&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED DATA&amp;lt;/span&amp;gt;');&amp;amp;lt;/script&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Ensure JavaScript variables are quoted&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Hex Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;JavaScript Unicode Encoding&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Avoid backslash encoding (\&amp;quot; or \' or \\)&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| HTML&lt;br /&gt;
| HTML Body&lt;br /&gt;
| &amp;amp;lt;div&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;UNTRUSTED HTML&amp;lt;/span&amp;gt;&amp;amp;lt;/div&amp;gt;&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.236_-_Use_an_HTML_Policy_engine_to_validate_or_clean_user-driven_HTML_in_an_outbound_way HTML Validation (JSoup, AntiSamy, HTML Sanitizer)]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
| String&lt;br /&gt;
| DOM XSS&lt;br /&gt;
| TODO&lt;br /&gt;
| &amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;[[DOM based XSS Prevention Cheat Sheet]]&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''''Safe HTML Attributes include:''''' align, alink, alt, bgcolor, border, cellpadding, cellspacing, class, color, cols, colspan, coords, dir, face, height, hspace, ismap, lang, marginheight, marginwidth, multiple, nohref, noresize, noshade, nowrap, ref, rel, rev, rows, rowspan, scrolling, shape, span, summary, tabindex, title, usemap, valign, value, vlink, vspace, width&lt;br /&gt;
&lt;br /&gt;
= Output Encoding Rules Summary =&lt;br /&gt;
&lt;br /&gt;
The purpose of output encoding (as it relates to Cross Site Scripting) is to convert untrusted input into a safe form where the input is displayed as '''data''' to the user without executing as '''code''' in the browser. The following charts details a list of critical output encoding methods needed to stop Cross Site Scripting.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Encoding Type&lt;br /&gt;
! Encoding Mechanism&lt;br /&gt;
|-&lt;br /&gt;
| HTML Entity Encoding&lt;br /&gt;
|   Convert &amp;amp; to &amp;amp;amp;amp;&amp;lt;br/&amp;gt;Convert &amp;lt; to &amp;amp;amp;lt;&amp;lt;br/&amp;gt;Convert &amp;gt; to &amp;amp;amp;gt;&amp;lt;br/&amp;gt;Convert &amp;quot; to &amp;amp;amp;quot;&amp;lt;br/&amp;gt;Convert ' to &amp;amp;amp;#x27;&amp;lt;br/&amp;gt;Convert / to &amp;amp;amp;#x2F;&lt;br /&gt;
|-&lt;br /&gt;
| HTML Attribute Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the HTML Entity &amp;amp;amp;#xHH; format, including spaces. (HH = Hex Value)&lt;br /&gt;
|-&lt;br /&gt;
| URL Encoding&lt;br /&gt;
| Standard percent encoding, see: [http://www.w3schools.com/tags/ref_urlencode.asp http://www.w3schools.com/tags/ref_urlencode.asp]&lt;br /&gt;
|-&lt;br /&gt;
| JavaScript Encoding&lt;br /&gt;
| Except for alphanumeric characters, escape all characters with the \uXXXX unicode escaping format (X = Integer).&lt;br /&gt;
|-&lt;br /&gt;
| CSS Hex Encoding&lt;br /&gt;
| CSS escaping supports \XX and \XXXXXX. Using a two character escape can cause problems if the next character continues the escape sequence. There are two solutions (a) Add a space after the CSS escape (will be ignored by the CSS parser) (b) use the full amount of CSS escaping possible by zero padding the value.&lt;br /&gt;
|}&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;
'''A Systematic Analysis of XSS Sanitization in Web Application Frameworks'''&lt;br /&gt;
&lt;br /&gt;
[http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf http://www.cs.berkeley.edu/~prateeks/papers/empirical-webfwks.pdf]&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;
* [[XSS Experimental Minimal Encoding Rules]]&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors =&lt;br /&gt;
&lt;br /&gt;
Jeff Williams - jeff.williams[at]aspectsecurity.com&amp;lt;br/&amp;gt;&lt;br /&gt;
Jim Manico - jim[at]owasp.org&lt;br /&gt;
&lt;br /&gt;
= Other Cheatsheets =&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=134614</id>
		<title>Orange County</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=134614"/>
				<updated>2012-08-22T17:53:27Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chapter Template|chaptername=Orange County|extra=Lead by [mailto:shong.chong@owasp.org Shong Chong]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;paypal&amp;gt;Orange County&amp;lt;/paypal&amp;gt;&lt;br /&gt;
|mailinglistsite=http://lists.owasp.org/mailman/listinfo/owasp-Orange_County|emailarchives=http://lists.owasp.org/pipermail/owasp-Orange_County}}&lt;br /&gt;
The chapter leader is [mailto:shong.chong@owasp.org Shong Chong].&lt;br /&gt;
&lt;br /&gt;
Follow OWASP OC on Twitter: https://twitter.com/OWASPOC for the latest news (so I don't spam your inboxes)&lt;br /&gt;
&lt;br /&gt;
== Sponsor ==&lt;br /&gt;
&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
&lt;br /&gt;
== Local News ==&lt;br /&gt;
&lt;br /&gt;
===Future Meetings ===&lt;br /&gt;
&lt;br /&gt;
===Previous Meetings===&lt;br /&gt;
&lt;br /&gt;
==== OWASP LA Event: Security Summit: April 25, 2012, 3:00PM - 8PM  ====&lt;br /&gt;
&lt;br /&gt;
(Note different time and location)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jerry Hoff VP, Static Code Analysis Division at WhiteHat Security, will be speaking about Webgoat. Shakeel Tufail, Federal Practice Director for HP Enterprise Security Solutions, will be speaking on securing software. Noa Bar Yosef, Senior Security Strategist at Imperva, will be speaking on &amp;quot;De-Anonymizing Anonymous&amp;quot;. A concluding panel, moderated by Richard Greenberg, Information Security Officer for LA County Public Health, will have the speakers joined by Adnan Masood, a Software Engineer and Architect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== March 28th 2012 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: March 28th 7pm&lt;br /&gt;
&lt;br /&gt;
Where: Irvine - 5151 California Ave, Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:30: Presentation&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;WebGoat.NET&amp;quot;====&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
Jerry Hoff, the project leader of the OWASP Appsec Tutorial Series, and VP of the Static Code Analysis Division at WhiteHat Security, will be discussing his newest OWASP project, WebGoat.NET.  For many years, the Java version of WebGoat has been available as a fantastic tool for learning application security from the Java perspective.  Jerry has now created a parallel tool for ASP.NET developers to learn about application security.  Jerry will be discussing how this tool can be used in a learning environment, and other issues related to application security education.&lt;br /&gt;
&lt;br /&gt;
====Speaker Bio:====&lt;br /&gt;
Jerry Hoff is vice president of the Static Code Analysis division at WhiteHat Security. In this role, he oversees the development of WhiteHats cloud-based static application security testing (SAST) service. Prior to WhiteHat, Mr. Hoff was co-founder and managing partner ofInfrared Security, a leading application security professional services firm. Mr. Hoff is an experienced application security consultant with years of professional development and training delivery. He is also the lead of the OWASP AppSec Tutorial Series. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== September 14th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: Wednesday September 17th 7pm&lt;br /&gt;
Where: TBD (Irvine)&lt;br /&gt;
http://www.meetup.com/ocrails/events/30043551/&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:00: Brakeman with Justin Collins&lt;br /&gt;
8:00 - 8:15: Lightning Rounds&lt;br /&gt;
8:15 - 8:30: Brakeman Demo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brakeman with Justin Collins: &lt;br /&gt;
While the popular Ruby on Rails web framework provides built-in protection &lt;br /&gt;
for many security vulnerabilities, it is still possible to misuse these&lt;br /&gt;
features or introduce other vulnerabilities to an application. Brakeman is a static code analysis tool designed specifically to find vulnerabilities and configuration issues  in Ruby on Rails applications. Since it works at the source code level, Brakeman can be used at any point in development without the need for deploying the full application stack. To make it even simpler, &lt;br /&gt;
Brakeman can be integrated with Hudson/Jenkins to provide automatic monitoring of Brakeman results as code is committed. This talk will discuss how to use Brakeman and how it can help you create safer Rails applications.&lt;br /&gt;
&lt;br /&gt;
Lightning Rounds:&lt;br /&gt;
&lt;br /&gt;
Neil Matatall: Friendly_id + ancsetry&lt;br /&gt;
&lt;br /&gt;
Drew Deponte: Guard, spork, BDD&lt;br /&gt;
&lt;br /&gt;
==== June 29th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
[[http://owaspoc.eventbrite.com/ Registration Link]]&lt;br /&gt;
&lt;br /&gt;
'''When''': Wednesday june 29th, 2011 7pm&lt;br /&gt;
&lt;br /&gt;
'''Where:  HireRight Offices'''&lt;br /&gt;
5151 California Avenue&lt;br /&gt;
Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
'''Pizza and refreshments will be provided by the sponsors of this meeting.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
===== Meeting Sponsors =====&lt;br /&gt;
 &lt;br /&gt;
Food and refreshments:&lt;br /&gt;
[[File:AppSecDC2010-Sponsor-trustwave.gif]]&lt;br /&gt;
&lt;br /&gt;
Meeting location:&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
 &lt;br /&gt;
===== Presentation Topic: =====&lt;br /&gt;
Featuring analysis of more than 220 data breach investigations and more than 2,300 penetration tests conducted by Trustwave's SpiderLabs, the Global Security Report 2011 identifies the top vulnerabilities business encountered in 2010 as well as a list of strategic initiatives to help your business improve its overall security.&lt;br /&gt;
 &lt;br /&gt;
The data gathered from these engagements is substantial and comprehensive. This presentation will be a summary of the results of the analysis of the data gathered during 2010. The results will be presented both technical and business impact analysis.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Charles Henderson, Director of Application Security Services of SpiderLabs at Trustwave =====&lt;br /&gt;
 &lt;br /&gt;
Henderson began his career in computer security in 1993, specializing in penetration testing as well as security and vulnerability research. As Director of Application Security Services at SpiderLabs, he leads the team responsible for Application Penetration Testing, Code Review, Secure Development Training, and other elite application security consulting services.&lt;br /&gt;
 &lt;br /&gt;
Prior to joining SpiderLabs, Henderson ran his own boutique application&lt;br /&gt;
security testing firm. Henderson’s firm provided offensive security services to a wide variety of clients in the United States and Europe.&lt;br /&gt;
 &lt;br /&gt;
Henderson speaks frequently at major industry events and conferences, including BlackHat, DEF CON,  AppSec US, AppSec EU, SOURCE, and the International Association of Financial Crime Investigators convention.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====January 28th, 2011====&lt;br /&gt;
&lt;br /&gt;
'''Registration link: [https://www.regonline.com/owasp_oc_jan]'''&lt;br /&gt;
&lt;br /&gt;
'''Time:''' 1 PM - 5PM&lt;br /&gt;
&lt;br /&gt;
'''Location: '''&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=5151+California+Ave&amp;amp;sll=33.621597,-117.740797&amp;amp;sspn=0.010489,0.019011&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=5151+California+Ave,+Irvine,+Orange,+California+92617&amp;amp;z=16&amp;amp;iwloc=A Hireright] &lt;br /&gt;
&lt;br /&gt;
5151 California Ave&lt;br /&gt;
&lt;br /&gt;
Irvine, California 92617&lt;br /&gt;
&lt;br /&gt;
United States.   &lt;br /&gt;
&lt;br /&gt;
'''Topics:''' Threat Modeling, Application Security&lt;br /&gt;
&lt;br /&gt;
'''Food:''' Provided&lt;br /&gt;
&lt;br /&gt;
Speakers:  &lt;br /&gt;
&lt;br /&gt;
'''Samy Kamkar'''&lt;br /&gt;
&lt;br /&gt;
Online Privacy and the Evercookie&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Samy Kamkar has lectured on computer security issues in over a dozen&lt;br /&gt;
countries, and his work has been featured on the front page of the New&lt;br /&gt;
York Times. As a grey-hat hacker, he makes and breaks computer&lt;br /&gt;
security for tech companies. In addition to his independent security&lt;br /&gt;
research, he co-founded Fonality, an IP PBX company.&lt;br /&gt;
&lt;br /&gt;
'''Jim Manico'''&lt;br /&gt;
&lt;br /&gt;
Back to Basics: Defensive Coding Principles for Web Development 101&lt;br /&gt;
&lt;br /&gt;
The application security community is in deep need of prescriptive&lt;br /&gt;
solutions for developers. This talk will review the world of Web&lt;br /&gt;
Application Security from a &amp;quot;builder&amp;quot; point of view, focusing on&lt;br /&gt;
critical controls that all developers must master if they wish to build&lt;br /&gt;
low risk web applications today.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Jim Manico is the chair of the OWASP Connections committee where he&lt;br /&gt;
focuses on producing and hosting the OWASP Podcast. Jim also is a&lt;br /&gt;
co-manager of the OWASP ESAPI Open Source project. Professionally, Jim&lt;br /&gt;
is an independent application security architect specializing in the&lt;br /&gt;
construction of low-risk web applications. Jim is also an application&lt;br /&gt;
security educator and assessment specialist.&lt;br /&gt;
&lt;br /&gt;
'''Edward Bonver'''&lt;br /&gt;
Talk Title:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling at Symantec&lt;br /&gt;
[[File:OWASP-WWW-2011-Edward-Bonver-Threat-Modelint-at-Symantec.pptx]]&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling is one of the most important security activities that a development/QA team needs to perform as part of a Security Development Lifecycle. This activity allows the team to build a complete security profile of the system being built. Threat Modeling is not always easy to get going for a team that has little or no security experience. In this presentation we’ll take a look at why Threat Modeling is so important; we’ll explore the process behind it, and how the process is being implemented and followed across Symantec.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Edward Bonver is a principal software engineer on the product security team under the Office of the CTO at Symantec Corporation.  In this capacity, Edward is responsible for working with software developers and quality assurance (QA) professionals across Symantec to continuously enhance the company’s software security practices through the adoption of methodologies, procedures and tools for secure coding and security testing.  Within Symantec, Edward teaches secure coding and security testing classes for Symantec engineers, and also leads the company’s QA Security Task Force, which he founded.  Prior to joining Symantec, Edward held software engineering and QA roles at Digital Equipment Corporation, Nbase and Zuma Networks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edward is a Certified Information Systems Security Professional (CISSP) and a Certified Secure Software Lifecycle Professional (CSSLP).  He holds a master’s degree in computer science from California State University, Northridge, and a bachelor’s degree in computer science from Rochester Institute of Technology. Edward is a Ph.D. student at NOVA Southeastern University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, January 21st 2010====&lt;br /&gt;
&lt;br /&gt;
Time: 7:30&lt;br /&gt;
Location: We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus. The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020. Parking is $7 but feel free to park off campus and walk to the building. http://www.oit.uci.edu/computing/labs/training.html Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdfBD&lt;br /&gt;
&lt;br /&gt;
For those who would like to avoid paying for parking, you can park in the University Center and take the campus shuttle: http://www.shuttle.uci.edu/maincampus/index.php&lt;br /&gt;
&lt;br /&gt;
The shuttle runs until 10:45PM.  The shuttle costs $1 per ride, but fees are rarely collected ;)&lt;br /&gt;
&lt;br /&gt;
Title: Do VLANs allow for good application security? &lt;br /&gt;
 &lt;br /&gt;
Virtual Local Area Networks (VLANs) are not a new concept, and can help&lt;br /&gt;
any organization better control network access.  I will present some of&lt;br /&gt;
the previous issues identified, what was the root cause, and how these&lt;br /&gt;
have been fixed in current technology.  In addition we will talk about&lt;br /&gt;
how this can help to enhance security in your environment, and what&lt;br /&gt;
controls must be in place in order to implement such an environment.  We&lt;br /&gt;
will also touch on how this can complicate your application environment,&lt;br /&gt;
but improve overall security.&lt;br /&gt;
&lt;br /&gt;
I will touch on the controls that need to be reviewed and audited when&lt;br /&gt;
working with VMware, VLANs, and web applications, to ensure that these&lt;br /&gt;
networks are secure, and what to look for to potentially pass audit&lt;br /&gt;
criteria.  I will also talk about where and how these controls have been&lt;br /&gt;
implemented in order to protect thousands of users while accessing one&lt;br /&gt;
of the most hostile networks in the world.&lt;br /&gt;
&lt;br /&gt;
David M. N. Bryan &lt;br /&gt;
Senior Security Consultant &lt;br /&gt;
&lt;br /&gt;
David has over 9+ years of computer security experience including,&lt;br /&gt;
consulting, engineering and administration.  He has performed security&lt;br /&gt;
assessment projects for health care, nuclear, manufacturing,&lt;br /&gt;
pharmaceutical, banking and educational sectors.   As an active&lt;br /&gt;
participant in the information security community, he volunteers at&lt;br /&gt;
DEFCON where he designs and implements the Firewall and Network for what&lt;br /&gt;
is said to be the most hostile network environment in the world.  &lt;br /&gt;
&lt;br /&gt;
He is also an active participant in the local Minneapolis security&lt;br /&gt;
groups both as a board member of OWASP MSP and DC612.  His roots and&lt;br /&gt;
experience come from working for a large enterprise banks, designing and&lt;br /&gt;
managing enterprise security systems.  In the more recent years he has&lt;br /&gt;
been working as an Information Security Consultant to review the&lt;br /&gt;
security and architecture of information computing environments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday December 17th 2009====&lt;br /&gt;
&lt;br /&gt;
7:30 PM, UC Irvine Campus, Room AIRB 1020&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus.  The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020.  Parking is $7 but feel free to park off campus and walk to the building.&lt;br /&gt;
http://www.oit.uci.edu/computing/labs/training.html&lt;br /&gt;
Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf&lt;br /&gt;
&lt;br /&gt;
'''Abstract'''&lt;br /&gt;
&lt;br /&gt;
'''Title: Pulling the Plug: Security Risks in the Next Generation of Offline Web Applications'''&lt;br /&gt;
&lt;br /&gt;
As the line between desktop and web applications becomes increasingly blurry in a web 2.0 world, browser functionality is being pushed well beyond what it was originally intended for. Persistent client side storage has become a requirement for web applications if they are to be available both online and off. This need is being filled by a variety of technologies such as [http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage Gears (formerly Google Gears) and the Database Storage]   functionality included in the emerging [http://dev.w3.org/html5/spec/Overview.html HTML 5 specification]. While all such technologies offer great promise, it is clear that the vast majority of developers simply do not understand their security implications.&lt;br /&gt;
&lt;br /&gt;
Researching a variety of currently deployed implementations of these technologies has revealed a broad scope of vulnerabilities with frightening implications. Now attackers can target victims not just once, but every time they visit a site as the victim now carries and stores the attack with them. Imagine a scenario whereby updated confidential information is forwarded to an attacker every time a victim interacts with a given we application. The attacker no longer needs to worry about timing their attacks to ensure that the victim is authenticated as the victim attacks himself! Limited storage? Cookies that expire? Not a problem when entire databases are accessible with virtually unlimited storage and an infinite lifespan. Think these attacks are theoretical? Think again. In this talk we dive into these technologies and break down the risk posed by them when not properly understood. We will then detail a variety of real-world vulnerabilities that have been uncovered, including a new class of cross-site scripting and client-side SQL injection.&lt;br /&gt;
&lt;br /&gt;
'''Bio'''&lt;br /&gt;
&lt;br /&gt;
'''Michael Sutton'''&lt;br /&gt;
'''Vice President, Security Research – Zscaler'''&lt;br /&gt;
&lt;br /&gt;
Michael Sutton has spent more than a decade in the security industry conducting leading-edge research, building teams of world-class researchers and educating others on a variety of security topics. As VP of Security Research, Michael heads Zscaler Labs, the research and development arm of the company. Zscaler Labs is responsible for researching emerging topics in web security and developing innovative security controls, which leverage the Zscaler in-the-cloud model. The team is comprised of researchers with a wealth of experience in the security industry.    &lt;br /&gt;
&lt;br /&gt;
Prior to joining Zscaler, Michael was the Security Evangelist for SPI Dynamics where, as an industry expert, he was responsible for researching, publishing and presenting on various security issues. In 2007, SPI Dynamics was acquired by Hewlett-Packard. Previously, Michael was a Research Director at iDefense where he led iDefense Labs, a team responsible for discovering and researching security vulnerabilities in a variety of technologies. iDefense was acquired by VeriSign in 2005. Michael is a frequent speaker at major information security conferences; he is regularly quoted by the media on various information security topics, has authored numerous articles and is the co-author of Fuzzing: Brute Force Vulnerability Discovery, an Addison-Wesley publication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, November 19th 2009====&lt;br /&gt;
&lt;br /&gt;
When: November 19th 2009, 7:30PM&lt;br /&gt;
Where: Gina's Pizza, Irvine&lt;br /&gt;
Topics: Facebook privacy, web application firewalls, penetration testing, the reluctance for hackers to execute attacks, and random new technology.  Announced OWASP OC/LAs intention to submit a proposal for AppSec 2010.&lt;br /&gt;
&lt;br /&gt;
====Wednesday, October 14th 2009====&lt;br /&gt;
&lt;br /&gt;
Separate meetings will be held for OWASP OC and OWASP@UCI (student group).&lt;br /&gt;
&lt;br /&gt;
When:  Wednesday 10/14  7:30PM&lt;br /&gt;
Where:  Steelhead Brewery&lt;br /&gt;
Topics:  News, Ideas, Chit-chat&lt;br /&gt;
&lt;br /&gt;
This is a restaurant/bar with plenty of seating, but room for a projector is out of the question so this would be an informal round table discussion.&lt;br /&gt;
&lt;br /&gt;
I have a presentation I'm working on regarding WAFs and Vulnerability Assessment Tools.  If it pleases the group, I'd love to go over the presentation and discuss everyone's experiences.  Also, it's a great way to get feedback :)&lt;br /&gt;
&lt;br /&gt;
Neil&lt;br /&gt;
&lt;br /&gt;
I'm open to suggestions of any kind: location, time, topics, etc&lt;br /&gt;
&lt;br /&gt;
====Thursday, September 17th, 2009 7:30PM ====&lt;br /&gt;
'''Location:''' UC Irvine &lt;br /&gt;
Building: Calit2 building,building number 325 in quadrant H8 on the [http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf UC Irvine Map]&lt;br /&gt;
Room: 3008&lt;br /&gt;
&lt;br /&gt;
Parking will be $7.&lt;br /&gt;
Please park in the [http://maps.google.com/maps?li=d&amp;amp;hl=en&amp;amp;f=d&amp;amp;iwstate1=dir:to&amp;amp;daddr=Parking+Structure+for+CalIT2%4033.643082,+-117.837593&amp;amp;geocode=CSJ9b4xJxrzxFUpaAQId5_D5-A&amp;amp;iwloc=1&amp;amp;dq=calit2,+uc+irvine,+ca&amp;amp;cid=33643082,-117837593,16505793731713499531&amp;amp;ei=v3bvSabfO6LejAOR2pjgAQ Anteater Parking Structure]&lt;br /&gt;
&lt;br /&gt;
I can only unofficially say that if you park in the nearby shopping centers and walk, you may be able to park for free.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;The Rise of Threat Analysis and the Fall of Compliance, Policies, and Standards in mitigating Web Application Security Risks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Apr 30, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Our fourth OC OWASP meeting will be an informal, roundtable discussion of current application security issues. Feel free to bring some ideas, code, slides, etc to contribute to the discussion. Hope to see everyone there!&lt;br /&gt;
&lt;br /&gt;
====Feb 19, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come talk application security at the third OWASP OC meeting. We'll discuss current application security topics and chapter issues over pizza. We have a room booked for 15-20 people so we'll be able to rant without disturbing the patrons :) See you there! [https://www.owasp.org/images/5/58/Cloud_Computing_Security.pdf Presentation Slides]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dec 17, 2008 6PM - 9PM====&lt;br /&gt;
Microsoft Campus&lt;br /&gt;
Room MPR1, 3 Park Plaza, Suite 1600, Irvine, CA, 92614&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=microsoft,+Irvine,+CA,+92614&amp;amp;sll=33.678479,-117.838368&amp;amp;sspn=0.009892,0.022745&amp;amp;g=3+Park+Plaza,+Irvine,+CA,+92614&amp;amp;ie=UTF8&amp;amp;ei=sCFJSfKPEo3UNc2ZmCc&amp;amp;cd=1&amp;amp;cid=33728042,-117783305,17507068988286890825&amp;amp;li=lmd&amp;amp;ll=33.731835,-117.78142&amp;amp;spn=0.039545,0.090981&amp;amp;z=14&amp;amp;iwloc=A Google Map]&lt;br /&gt;
&lt;br /&gt;
This meeting will be a roundtable discussion of application security news, plus a few OWASP-themed challenges with prizes. Pizza will be provided and we'll head to the Yard House after the meeting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Aug 27, 2008, 7 PM - 9 PM====&lt;br /&gt;
Penny Saver&lt;br /&gt;
&lt;br /&gt;
603 Valencia, Brea, CA 92822&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=603+valencia,+Brea,+CA+92822&amp;amp;sll=33.911348,-117.851629&amp;amp;sspn=0.009865,0.022745&amp;amp;ie=UTF8&amp;amp;ll=33.909478,-117.852917&amp;amp;spn=0.009866,0.022745&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come meet up with web security professionals, have some pizza, and offer your thoughts for the direction of the OC chapter at our inaugural meeting! We are looking for speakers and venue sponsors for the next meeting. If you are interested, please contact the chapter leaders. Everyone is welcome to join us at our chapter meetings.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Chapter]]&lt;br /&gt;
&lt;br /&gt;
= Orange County OWASP Board Members =&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; [mailto:neil@owasp.org Neil Matatall]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Shong Chong&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Rob LaViolette&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Treasurer:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Recording Secretary:&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:California]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=134613</id>
		<title>Orange County</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=134613"/>
				<updated>2012-08-22T17:51:01Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chapter Template|chaptername=Orange County|extra=Lead by the co-presidents [mailto:neil@owasp.org Neil Matatall], [mailto:roblav@owasp.org Rob LaViolette] and [mailto:shong.chong@owasp.org Shong Chong]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;paypal&amp;gt;Orange County&amp;lt;/paypal&amp;gt;&lt;br /&gt;
|mailinglistsite=http://lists.owasp.org/mailman/listinfo/owasp-Orange_County|emailarchives=http://lists.owasp.org/pipermail/owasp-Orange_County}}&lt;br /&gt;
The chapter leader is [mailto:shong.chong@owasp.org Shong Chong].&lt;br /&gt;
&lt;br /&gt;
Follow OWASP OC on Twitter: https://twitter.com/OWASPOC for the latest news (so I don't spam your inboxes)&lt;br /&gt;
&lt;br /&gt;
== Sponsor ==&lt;br /&gt;
&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
&lt;br /&gt;
== Local News ==&lt;br /&gt;
&lt;br /&gt;
===Future Meetings ===&lt;br /&gt;
&lt;br /&gt;
===Previous Meetings===&lt;br /&gt;
&lt;br /&gt;
==== OWASP LA Event: Security Summit: April 25, 2012, 3:00PM - 8PM  ====&lt;br /&gt;
&lt;br /&gt;
(Note different time and location)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jerry Hoff VP, Static Code Analysis Division at WhiteHat Security, will be speaking about Webgoat. Shakeel Tufail, Federal Practice Director for HP Enterprise Security Solutions, will be speaking on securing software. Noa Bar Yosef, Senior Security Strategist at Imperva, will be speaking on &amp;quot;De-Anonymizing Anonymous&amp;quot;. A concluding panel, moderated by Richard Greenberg, Information Security Officer for LA County Public Health, will have the speakers joined by Adnan Masood, a Software Engineer and Architect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== March 28th 2012 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: March 28th 7pm&lt;br /&gt;
&lt;br /&gt;
Where: Irvine - 5151 California Ave, Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:30: Presentation&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;WebGoat.NET&amp;quot;====&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
Jerry Hoff, the project leader of the OWASP Appsec Tutorial Series, and VP of the Static Code Analysis Division at WhiteHat Security, will be discussing his newest OWASP project, WebGoat.NET.  For many years, the Java version of WebGoat has been available as a fantastic tool for learning application security from the Java perspective.  Jerry has now created a parallel tool for ASP.NET developers to learn about application security.  Jerry will be discussing how this tool can be used in a learning environment, and other issues related to application security education.&lt;br /&gt;
&lt;br /&gt;
====Speaker Bio:====&lt;br /&gt;
Jerry Hoff is vice president of the Static Code Analysis division at WhiteHat Security. In this role, he oversees the development of WhiteHats cloud-based static application security testing (SAST) service. Prior to WhiteHat, Mr. Hoff was co-founder and managing partner ofInfrared Security, a leading application security professional services firm. Mr. Hoff is an experienced application security consultant with years of professional development and training delivery. He is also the lead of the OWASP AppSec Tutorial Series. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== September 14th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: Wednesday September 17th 7pm&lt;br /&gt;
Where: TBD (Irvine)&lt;br /&gt;
http://www.meetup.com/ocrails/events/30043551/&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:00: Brakeman with Justin Collins&lt;br /&gt;
8:00 - 8:15: Lightning Rounds&lt;br /&gt;
8:15 - 8:30: Brakeman Demo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brakeman with Justin Collins: &lt;br /&gt;
While the popular Ruby on Rails web framework provides built-in protection &lt;br /&gt;
for many security vulnerabilities, it is still possible to misuse these&lt;br /&gt;
features or introduce other vulnerabilities to an application. Brakeman is a static code analysis tool designed specifically to find vulnerabilities and configuration issues  in Ruby on Rails applications. Since it works at the source code level, Brakeman can be used at any point in development without the need for deploying the full application stack. To make it even simpler, &lt;br /&gt;
Brakeman can be integrated with Hudson/Jenkins to provide automatic monitoring of Brakeman results as code is committed. This talk will discuss how to use Brakeman and how it can help you create safer Rails applications.&lt;br /&gt;
&lt;br /&gt;
Lightning Rounds:&lt;br /&gt;
&lt;br /&gt;
Neil Matatall: Friendly_id + ancsetry&lt;br /&gt;
&lt;br /&gt;
Drew Deponte: Guard, spork, BDD&lt;br /&gt;
&lt;br /&gt;
==== June 29th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
[[http://owaspoc.eventbrite.com/ Registration Link]]&lt;br /&gt;
&lt;br /&gt;
'''When''': Wednesday june 29th, 2011 7pm&lt;br /&gt;
&lt;br /&gt;
'''Where:  HireRight Offices'''&lt;br /&gt;
5151 California Avenue&lt;br /&gt;
Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
'''Pizza and refreshments will be provided by the sponsors of this meeting.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
===== Meeting Sponsors =====&lt;br /&gt;
 &lt;br /&gt;
Food and refreshments:&lt;br /&gt;
[[File:AppSecDC2010-Sponsor-trustwave.gif]]&lt;br /&gt;
&lt;br /&gt;
Meeting location:&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
 &lt;br /&gt;
===== Presentation Topic: =====&lt;br /&gt;
Featuring analysis of more than 220 data breach investigations and more than 2,300 penetration tests conducted by Trustwave's SpiderLabs, the Global Security Report 2011 identifies the top vulnerabilities business encountered in 2010 as well as a list of strategic initiatives to help your business improve its overall security.&lt;br /&gt;
 &lt;br /&gt;
The data gathered from these engagements is substantial and comprehensive. This presentation will be a summary of the results of the analysis of the data gathered during 2010. The results will be presented both technical and business impact analysis.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Charles Henderson, Director of Application Security Services of SpiderLabs at Trustwave =====&lt;br /&gt;
 &lt;br /&gt;
Henderson began his career in computer security in 1993, specializing in penetration testing as well as security and vulnerability research. As Director of Application Security Services at SpiderLabs, he leads the team responsible for Application Penetration Testing, Code Review, Secure Development Training, and other elite application security consulting services.&lt;br /&gt;
 &lt;br /&gt;
Prior to joining SpiderLabs, Henderson ran his own boutique application&lt;br /&gt;
security testing firm. Henderson’s firm provided offensive security services to a wide variety of clients in the United States and Europe.&lt;br /&gt;
 &lt;br /&gt;
Henderson speaks frequently at major industry events and conferences, including BlackHat, DEF CON,  AppSec US, AppSec EU, SOURCE, and the International Association of Financial Crime Investigators convention.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====January 28th, 2011====&lt;br /&gt;
&lt;br /&gt;
'''Registration link: [https://www.regonline.com/owasp_oc_jan]'''&lt;br /&gt;
&lt;br /&gt;
'''Time:''' 1 PM - 5PM&lt;br /&gt;
&lt;br /&gt;
'''Location: '''&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=5151+California+Ave&amp;amp;sll=33.621597,-117.740797&amp;amp;sspn=0.010489,0.019011&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=5151+California+Ave,+Irvine,+Orange,+California+92617&amp;amp;z=16&amp;amp;iwloc=A Hireright] &lt;br /&gt;
&lt;br /&gt;
5151 California Ave&lt;br /&gt;
&lt;br /&gt;
Irvine, California 92617&lt;br /&gt;
&lt;br /&gt;
United States.   &lt;br /&gt;
&lt;br /&gt;
'''Topics:''' Threat Modeling, Application Security&lt;br /&gt;
&lt;br /&gt;
'''Food:''' Provided&lt;br /&gt;
&lt;br /&gt;
Speakers:  &lt;br /&gt;
&lt;br /&gt;
'''Samy Kamkar'''&lt;br /&gt;
&lt;br /&gt;
Online Privacy and the Evercookie&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Samy Kamkar has lectured on computer security issues in over a dozen&lt;br /&gt;
countries, and his work has been featured on the front page of the New&lt;br /&gt;
York Times. As a grey-hat hacker, he makes and breaks computer&lt;br /&gt;
security for tech companies. In addition to his independent security&lt;br /&gt;
research, he co-founded Fonality, an IP PBX company.&lt;br /&gt;
&lt;br /&gt;
'''Jim Manico'''&lt;br /&gt;
&lt;br /&gt;
Back to Basics: Defensive Coding Principles for Web Development 101&lt;br /&gt;
&lt;br /&gt;
The application security community is in deep need of prescriptive&lt;br /&gt;
solutions for developers. This talk will review the world of Web&lt;br /&gt;
Application Security from a &amp;quot;builder&amp;quot; point of view, focusing on&lt;br /&gt;
critical controls that all developers must master if they wish to build&lt;br /&gt;
low risk web applications today.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Jim Manico is the chair of the OWASP Connections committee where he&lt;br /&gt;
focuses on producing and hosting the OWASP Podcast. Jim also is a&lt;br /&gt;
co-manager of the OWASP ESAPI Open Source project. Professionally, Jim&lt;br /&gt;
is an independent application security architect specializing in the&lt;br /&gt;
construction of low-risk web applications. Jim is also an application&lt;br /&gt;
security educator and assessment specialist.&lt;br /&gt;
&lt;br /&gt;
'''Edward Bonver'''&lt;br /&gt;
Talk Title:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling at Symantec&lt;br /&gt;
[[File:OWASP-WWW-2011-Edward-Bonver-Threat-Modelint-at-Symantec.pptx]]&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling is one of the most important security activities that a development/QA team needs to perform as part of a Security Development Lifecycle. This activity allows the team to build a complete security profile of the system being built. Threat Modeling is not always easy to get going for a team that has little or no security experience. In this presentation we’ll take a look at why Threat Modeling is so important; we’ll explore the process behind it, and how the process is being implemented and followed across Symantec.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Edward Bonver is a principal software engineer on the product security team under the Office of the CTO at Symantec Corporation.  In this capacity, Edward is responsible for working with software developers and quality assurance (QA) professionals across Symantec to continuously enhance the company’s software security practices through the adoption of methodologies, procedures and tools for secure coding and security testing.  Within Symantec, Edward teaches secure coding and security testing classes for Symantec engineers, and also leads the company’s QA Security Task Force, which he founded.  Prior to joining Symantec, Edward held software engineering and QA roles at Digital Equipment Corporation, Nbase and Zuma Networks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edward is a Certified Information Systems Security Professional (CISSP) and a Certified Secure Software Lifecycle Professional (CSSLP).  He holds a master’s degree in computer science from California State University, Northridge, and a bachelor’s degree in computer science from Rochester Institute of Technology. Edward is a Ph.D. student at NOVA Southeastern University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, January 21st 2010====&lt;br /&gt;
&lt;br /&gt;
Time: 7:30&lt;br /&gt;
Location: We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus. The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020. Parking is $7 but feel free to park off campus and walk to the building. http://www.oit.uci.edu/computing/labs/training.html Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdfBD&lt;br /&gt;
&lt;br /&gt;
For those who would like to avoid paying for parking, you can park in the University Center and take the campus shuttle: http://www.shuttle.uci.edu/maincampus/index.php&lt;br /&gt;
&lt;br /&gt;
The shuttle runs until 10:45PM.  The shuttle costs $1 per ride, but fees are rarely collected ;)&lt;br /&gt;
&lt;br /&gt;
Title: Do VLANs allow for good application security? &lt;br /&gt;
 &lt;br /&gt;
Virtual Local Area Networks (VLANs) are not a new concept, and can help&lt;br /&gt;
any organization better control network access.  I will present some of&lt;br /&gt;
the previous issues identified, what was the root cause, and how these&lt;br /&gt;
have been fixed in current technology.  In addition we will talk about&lt;br /&gt;
how this can help to enhance security in your environment, and what&lt;br /&gt;
controls must be in place in order to implement such an environment.  We&lt;br /&gt;
will also touch on how this can complicate your application environment,&lt;br /&gt;
but improve overall security.&lt;br /&gt;
&lt;br /&gt;
I will touch on the controls that need to be reviewed and audited when&lt;br /&gt;
working with VMware, VLANs, and web applications, to ensure that these&lt;br /&gt;
networks are secure, and what to look for to potentially pass audit&lt;br /&gt;
criteria.  I will also talk about where and how these controls have been&lt;br /&gt;
implemented in order to protect thousands of users while accessing one&lt;br /&gt;
of the most hostile networks in the world.&lt;br /&gt;
&lt;br /&gt;
David M. N. Bryan &lt;br /&gt;
Senior Security Consultant &lt;br /&gt;
&lt;br /&gt;
David has over 9+ years of computer security experience including,&lt;br /&gt;
consulting, engineering and administration.  He has performed security&lt;br /&gt;
assessment projects for health care, nuclear, manufacturing,&lt;br /&gt;
pharmaceutical, banking and educational sectors.   As an active&lt;br /&gt;
participant in the information security community, he volunteers at&lt;br /&gt;
DEFCON where he designs and implements the Firewall and Network for what&lt;br /&gt;
is said to be the most hostile network environment in the world.  &lt;br /&gt;
&lt;br /&gt;
He is also an active participant in the local Minneapolis security&lt;br /&gt;
groups both as a board member of OWASP MSP and DC612.  His roots and&lt;br /&gt;
experience come from working for a large enterprise banks, designing and&lt;br /&gt;
managing enterprise security systems.  In the more recent years he has&lt;br /&gt;
been working as an Information Security Consultant to review the&lt;br /&gt;
security and architecture of information computing environments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday December 17th 2009====&lt;br /&gt;
&lt;br /&gt;
7:30 PM, UC Irvine Campus, Room AIRB 1020&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus.  The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020.  Parking is $7 but feel free to park off campus and walk to the building.&lt;br /&gt;
http://www.oit.uci.edu/computing/labs/training.html&lt;br /&gt;
Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf&lt;br /&gt;
&lt;br /&gt;
'''Abstract'''&lt;br /&gt;
&lt;br /&gt;
'''Title: Pulling the Plug: Security Risks in the Next Generation of Offline Web Applications'''&lt;br /&gt;
&lt;br /&gt;
As the line between desktop and web applications becomes increasingly blurry in a web 2.0 world, browser functionality is being pushed well beyond what it was originally intended for. Persistent client side storage has become a requirement for web applications if they are to be available both online and off. This need is being filled by a variety of technologies such as [http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage Gears (formerly Google Gears) and the Database Storage]   functionality included in the emerging [http://dev.w3.org/html5/spec/Overview.html HTML 5 specification]. While all such technologies offer great promise, it is clear that the vast majority of developers simply do not understand their security implications.&lt;br /&gt;
&lt;br /&gt;
Researching a variety of currently deployed implementations of these technologies has revealed a broad scope of vulnerabilities with frightening implications. Now attackers can target victims not just once, but every time they visit a site as the victim now carries and stores the attack with them. Imagine a scenario whereby updated confidential information is forwarded to an attacker every time a victim interacts with a given we application. The attacker no longer needs to worry about timing their attacks to ensure that the victim is authenticated as the victim attacks himself! Limited storage? Cookies that expire? Not a problem when entire databases are accessible with virtually unlimited storage and an infinite lifespan. Think these attacks are theoretical? Think again. In this talk we dive into these technologies and break down the risk posed by them when not properly understood. We will then detail a variety of real-world vulnerabilities that have been uncovered, including a new class of cross-site scripting and client-side SQL injection.&lt;br /&gt;
&lt;br /&gt;
'''Bio'''&lt;br /&gt;
&lt;br /&gt;
'''Michael Sutton'''&lt;br /&gt;
'''Vice President, Security Research – Zscaler'''&lt;br /&gt;
&lt;br /&gt;
Michael Sutton has spent more than a decade in the security industry conducting leading-edge research, building teams of world-class researchers and educating others on a variety of security topics. As VP of Security Research, Michael heads Zscaler Labs, the research and development arm of the company. Zscaler Labs is responsible for researching emerging topics in web security and developing innovative security controls, which leverage the Zscaler in-the-cloud model. The team is comprised of researchers with a wealth of experience in the security industry.    &lt;br /&gt;
&lt;br /&gt;
Prior to joining Zscaler, Michael was the Security Evangelist for SPI Dynamics where, as an industry expert, he was responsible for researching, publishing and presenting on various security issues. In 2007, SPI Dynamics was acquired by Hewlett-Packard. Previously, Michael was a Research Director at iDefense where he led iDefense Labs, a team responsible for discovering and researching security vulnerabilities in a variety of technologies. iDefense was acquired by VeriSign in 2005. Michael is a frequent speaker at major information security conferences; he is regularly quoted by the media on various information security topics, has authored numerous articles and is the co-author of Fuzzing: Brute Force Vulnerability Discovery, an Addison-Wesley publication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, November 19th 2009====&lt;br /&gt;
&lt;br /&gt;
When: November 19th 2009, 7:30PM&lt;br /&gt;
Where: Gina's Pizza, Irvine&lt;br /&gt;
Topics: Facebook privacy, web application firewalls, penetration testing, the reluctance for hackers to execute attacks, and random new technology.  Announced OWASP OC/LAs intention to submit a proposal for AppSec 2010.&lt;br /&gt;
&lt;br /&gt;
====Wednesday, October 14th 2009====&lt;br /&gt;
&lt;br /&gt;
Separate meetings will be held for OWASP OC and OWASP@UCI (student group).&lt;br /&gt;
&lt;br /&gt;
When:  Wednesday 10/14  7:30PM&lt;br /&gt;
Where:  Steelhead Brewery&lt;br /&gt;
Topics:  News, Ideas, Chit-chat&lt;br /&gt;
&lt;br /&gt;
This is a restaurant/bar with plenty of seating, but room for a projector is out of the question so this would be an informal round table discussion.&lt;br /&gt;
&lt;br /&gt;
I have a presentation I'm working on regarding WAFs and Vulnerability Assessment Tools.  If it pleases the group, I'd love to go over the presentation and discuss everyone's experiences.  Also, it's a great way to get feedback :)&lt;br /&gt;
&lt;br /&gt;
Neil&lt;br /&gt;
&lt;br /&gt;
I'm open to suggestions of any kind: location, time, topics, etc&lt;br /&gt;
&lt;br /&gt;
====Thursday, September 17th, 2009 7:30PM ====&lt;br /&gt;
'''Location:''' UC Irvine &lt;br /&gt;
Building: Calit2 building,building number 325 in quadrant H8 on the [http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf UC Irvine Map]&lt;br /&gt;
Room: 3008&lt;br /&gt;
&lt;br /&gt;
Parking will be $7.&lt;br /&gt;
Please park in the [http://maps.google.com/maps?li=d&amp;amp;hl=en&amp;amp;f=d&amp;amp;iwstate1=dir:to&amp;amp;daddr=Parking+Structure+for+CalIT2%4033.643082,+-117.837593&amp;amp;geocode=CSJ9b4xJxrzxFUpaAQId5_D5-A&amp;amp;iwloc=1&amp;amp;dq=calit2,+uc+irvine,+ca&amp;amp;cid=33643082,-117837593,16505793731713499531&amp;amp;ei=v3bvSabfO6LejAOR2pjgAQ Anteater Parking Structure]&lt;br /&gt;
&lt;br /&gt;
I can only unofficially say that if you park in the nearby shopping centers and walk, you may be able to park for free.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;The Rise of Threat Analysis and the Fall of Compliance, Policies, and Standards in mitigating Web Application Security Risks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Apr 30, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Our fourth OC OWASP meeting will be an informal, roundtable discussion of current application security issues. Feel free to bring some ideas, code, slides, etc to contribute to the discussion. Hope to see everyone there!&lt;br /&gt;
&lt;br /&gt;
====Feb 19, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come talk application security at the third OWASP OC meeting. We'll discuss current application security topics and chapter issues over pizza. We have a room booked for 15-20 people so we'll be able to rant without disturbing the patrons :) See you there! [https://www.owasp.org/images/5/58/Cloud_Computing_Security.pdf Presentation Slides]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dec 17, 2008 6PM - 9PM====&lt;br /&gt;
Microsoft Campus&lt;br /&gt;
Room MPR1, 3 Park Plaza, Suite 1600, Irvine, CA, 92614&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=microsoft,+Irvine,+CA,+92614&amp;amp;sll=33.678479,-117.838368&amp;amp;sspn=0.009892,0.022745&amp;amp;g=3+Park+Plaza,+Irvine,+CA,+92614&amp;amp;ie=UTF8&amp;amp;ei=sCFJSfKPEo3UNc2ZmCc&amp;amp;cd=1&amp;amp;cid=33728042,-117783305,17507068988286890825&amp;amp;li=lmd&amp;amp;ll=33.731835,-117.78142&amp;amp;spn=0.039545,0.090981&amp;amp;z=14&amp;amp;iwloc=A Google Map]&lt;br /&gt;
&lt;br /&gt;
This meeting will be a roundtable discussion of application security news, plus a few OWASP-themed challenges with prizes. Pizza will be provided and we'll head to the Yard House after the meeting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Aug 27, 2008, 7 PM - 9 PM====&lt;br /&gt;
Penny Saver&lt;br /&gt;
&lt;br /&gt;
603 Valencia, Brea, CA 92822&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=603+valencia,+Brea,+CA+92822&amp;amp;sll=33.911348,-117.851629&amp;amp;sspn=0.009865,0.022745&amp;amp;ie=UTF8&amp;amp;ll=33.909478,-117.852917&amp;amp;spn=0.009866,0.022745&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come meet up with web security professionals, have some pizza, and offer your thoughts for the direction of the OC chapter at our inaugural meeting! We are looking for speakers and venue sponsors for the next meeting. If you are interested, please contact the chapter leaders. Everyone is welcome to join us at our chapter meetings.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Chapter]]&lt;br /&gt;
&lt;br /&gt;
= Orange County OWASP Board Members =&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; [mailto:neil@owasp.org Neil Matatall]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Shong Chong&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Rob LaViolette&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Treasurer:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Recording Secretary:&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:California]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=127834</id>
		<title>Orange County</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=127834"/>
				<updated>2012-04-13T21:29:57Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Local News */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chapter Template|chaptername=Orange County|extra=Lead by the co-presidents [mailto:neil@owasp.org Neil Matatall], [mailto:roblav@owasp.org Rob LaViolette] and [mailto:shong.chong@owasp.org Shong Chong]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;paypal&amp;gt;Orange County&amp;lt;/paypal&amp;gt;&lt;br /&gt;
|mailinglistsite=http://lists.owasp.org/mailman/listinfo/owasp-Orange_County|emailarchives=http://lists.owasp.org/pipermail/owasp-Orange_County}}&lt;br /&gt;
The chapter leaders are [mailto:neil@owasp.org Neil Matatall], Rob LaViolette, and Shong Chong.&lt;br /&gt;
&lt;br /&gt;
Follow OWASP OC on Twitter: https://twitter.com/OWASPOC for the latest news (so I don't spam your inboxes)&lt;br /&gt;
&lt;br /&gt;
== Sponsor ==&lt;br /&gt;
&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
&lt;br /&gt;
== Local News ==&lt;br /&gt;
&lt;br /&gt;
===Future Meetings ===&lt;br /&gt;
&lt;br /&gt;
==== OWASP LA Event: Security Summit: April 25, 2012, 3:00PM - 8PM  ====&lt;br /&gt;
&lt;br /&gt;
(Note different time and location)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Jerry Hoff VP, Static Code Analysis Division at WhiteHat Security, will be speaking about Webgoat. Shakeel Tufail, Federal Practice Director for HP Enterprise Security Solutions, will be speaking on securing software. Noa Bar Yosef, Senior Security Strategist at Imperva, will be speaking on &amp;quot;De-Anonymizing Anonymous&amp;quot;. A concluding panel, moderated by Richard Greenberg, Information Security Officer for LA County Public Health, will have the speakers joined by Adnan Masood, a Software Engineer and Architect.&lt;br /&gt;
&lt;br /&gt;
''Food and drinks will follow''.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- '''''Location:'''''&amp;lt;br&amp;gt;  --&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; &lt;br /&gt;
Location:&lt;br /&gt;
&lt;br /&gt;
Four Points by Sheraton Los Angeles &amp;lt;/b&amp;gt; &lt;br /&gt;
&lt;br /&gt;
5990 Green Valley Cir&lt;br /&gt;
&lt;br /&gt;
Culver City, CA 90230 &lt;br /&gt;
&lt;br /&gt;
(310) 641-7740 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RSVP at http://www.meetup.com/OWASP-Los-Angeles/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== March 28th 2012 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: March 28th 7pm&lt;br /&gt;
&lt;br /&gt;
Where: Irvine - 5151 California Ave, Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:30: Presentation&lt;br /&gt;
&lt;br /&gt;
====&amp;quot;WebGoat.NET&amp;quot;====&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
Jerry Hoff, the project leader of the OWASP Appsec Tutorial Series, and VP of the Static Code Analysis Division at WhiteHat Security, will be discussing his newest OWASP project, WebGoat.NET.  For many years, the Java version of WebGoat has been available as a fantastic tool for learning application security from the Java perspective.  Jerry has now created a parallel tool for ASP.NET developers to learn about application security.  Jerry will be discussing how this tool can be used in a learning environment, and other issues related to application security education.&lt;br /&gt;
&lt;br /&gt;
====Speaker Bio:====&lt;br /&gt;
Jerry Hoff is vice president of the Static Code Analysis division at WhiteHat Security. In this role, he oversees the development of WhiteHats cloud-based static application security testing (SAST) service. Prior to WhiteHat, Mr. Hoff was co-founder and managing partner ofInfrared Security, a leading application security professional services firm. Mr. Hoff is an experienced application security consultant with years of professional development and training delivery. He is also the lead of the OWASP AppSec Tutorial Series. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You: ???&lt;br /&gt;
&lt;br /&gt;
===Previous Meetings===&lt;br /&gt;
&lt;br /&gt;
==== September 14th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: Wednesday September 17th 7pm&lt;br /&gt;
Where: TBD (Irvine)&lt;br /&gt;
http://www.meetup.com/ocrails/events/30043551/&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:00: Brakeman with Justin Collins&lt;br /&gt;
8:00 - 8:15: Lightning Rounds&lt;br /&gt;
8:15 - 8:30: Brakeman Demo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brakeman with Justin Collins: &lt;br /&gt;
While the popular Ruby on Rails web framework provides built-in protection &lt;br /&gt;
for many security vulnerabilities, it is still possible to misuse these&lt;br /&gt;
features or introduce other vulnerabilities to an application. Brakeman is a static code analysis tool designed specifically to find vulnerabilities and configuration issues  in Ruby on Rails applications. Since it works at the source code level, Brakeman can be used at any point in development without the need for deploying the full application stack. To make it even simpler, &lt;br /&gt;
Brakeman can be integrated with Hudson/Jenkins to provide automatic monitoring of Brakeman results as code is committed. This talk will discuss how to use Brakeman and how it can help you create safer Rails applications.&lt;br /&gt;
&lt;br /&gt;
Lightning Rounds:&lt;br /&gt;
&lt;br /&gt;
Neil Matatall: Friendly_id + ancsetry&lt;br /&gt;
&lt;br /&gt;
Drew Deponte: Guard, spork, BDD&lt;br /&gt;
&lt;br /&gt;
==== June 29th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
[[http://owaspoc.eventbrite.com/ Registration Link]]&lt;br /&gt;
&lt;br /&gt;
'''When''': Wednesday june 29th, 2011 7pm&lt;br /&gt;
&lt;br /&gt;
'''Where:  HireRight Offices'''&lt;br /&gt;
5151 California Avenue&lt;br /&gt;
Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
'''Pizza and refreshments will be provided by the sponsors of this meeting.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
===== Meeting Sponsors =====&lt;br /&gt;
 &lt;br /&gt;
Food and refreshments:&lt;br /&gt;
[[File:AppSecDC2010-Sponsor-trustwave.gif]]&lt;br /&gt;
&lt;br /&gt;
Meeting location:&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
 &lt;br /&gt;
===== Presentation Topic: =====&lt;br /&gt;
Featuring analysis of more than 220 data breach investigations and more than 2,300 penetration tests conducted by Trustwave's SpiderLabs, the Global Security Report 2011 identifies the top vulnerabilities business encountered in 2010 as well as a list of strategic initiatives to help your business improve its overall security.&lt;br /&gt;
 &lt;br /&gt;
The data gathered from these engagements is substantial and comprehensive. This presentation will be a summary of the results of the analysis of the data gathered during 2010. The results will be presented both technical and business impact analysis.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Charles Henderson, Director of Application Security Services of SpiderLabs at Trustwave =====&lt;br /&gt;
 &lt;br /&gt;
Henderson began his career in computer security in 1993, specializing in penetration testing as well as security and vulnerability research. As Director of Application Security Services at SpiderLabs, he leads the team responsible for Application Penetration Testing, Code Review, Secure Development Training, and other elite application security consulting services.&lt;br /&gt;
 &lt;br /&gt;
Prior to joining SpiderLabs, Henderson ran his own boutique application&lt;br /&gt;
security testing firm. Henderson’s firm provided offensive security services to a wide variety of clients in the United States and Europe.&lt;br /&gt;
 &lt;br /&gt;
Henderson speaks frequently at major industry events and conferences, including BlackHat, DEF CON,  AppSec US, AppSec EU, SOURCE, and the International Association of Financial Crime Investigators convention.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====January 28th, 2011====&lt;br /&gt;
&lt;br /&gt;
'''Registration link: [https://www.regonline.com/owasp_oc_jan]'''&lt;br /&gt;
&lt;br /&gt;
'''Time:''' 1 PM - 5PM&lt;br /&gt;
&lt;br /&gt;
'''Location: '''&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=5151+California+Ave&amp;amp;sll=33.621597,-117.740797&amp;amp;sspn=0.010489,0.019011&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=5151+California+Ave,+Irvine,+Orange,+California+92617&amp;amp;z=16&amp;amp;iwloc=A Hireright] &lt;br /&gt;
&lt;br /&gt;
5151 California Ave&lt;br /&gt;
&lt;br /&gt;
Irvine, California 92617&lt;br /&gt;
&lt;br /&gt;
United States.   &lt;br /&gt;
&lt;br /&gt;
'''Topics:''' Threat Modeling, Application Security&lt;br /&gt;
&lt;br /&gt;
'''Food:''' Provided&lt;br /&gt;
&lt;br /&gt;
Speakers:  &lt;br /&gt;
&lt;br /&gt;
'''Samy Kamkar'''&lt;br /&gt;
&lt;br /&gt;
Online Privacy and the Evercookie&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Samy Kamkar has lectured on computer security issues in over a dozen&lt;br /&gt;
countries, and his work has been featured on the front page of the New&lt;br /&gt;
York Times. As a grey-hat hacker, he makes and breaks computer&lt;br /&gt;
security for tech companies. In addition to his independent security&lt;br /&gt;
research, he co-founded Fonality, an IP PBX company.&lt;br /&gt;
&lt;br /&gt;
'''Jim Manico'''&lt;br /&gt;
&lt;br /&gt;
Back to Basics: Defensive Coding Principles for Web Development 101&lt;br /&gt;
&lt;br /&gt;
The application security community is in deep need of prescriptive&lt;br /&gt;
solutions for developers. This talk will review the world of Web&lt;br /&gt;
Application Security from a &amp;quot;builder&amp;quot; point of view, focusing on&lt;br /&gt;
critical controls that all developers must master if they wish to build&lt;br /&gt;
low risk web applications today.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Jim Manico is the chair of the OWASP Connections committee where he&lt;br /&gt;
focuses on producing and hosting the OWASP Podcast. Jim also is a&lt;br /&gt;
co-manager of the OWASP ESAPI Open Source project. Professionally, Jim&lt;br /&gt;
is an independent application security architect specializing in the&lt;br /&gt;
construction of low-risk web applications. Jim is also an application&lt;br /&gt;
security educator and assessment specialist.&lt;br /&gt;
&lt;br /&gt;
'''Edward Bonver'''&lt;br /&gt;
Talk Title:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling at Symantec&lt;br /&gt;
[[File:OWASP-WWW-2011-Edward-Bonver-Threat-Modelint-at-Symantec.pptx]]&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling is one of the most important security activities that a development/QA team needs to perform as part of a Security Development Lifecycle. This activity allows the team to build a complete security profile of the system being built. Threat Modeling is not always easy to get going for a team that has little or no security experience. In this presentation we’ll take a look at why Threat Modeling is so important; we’ll explore the process behind it, and how the process is being implemented and followed across Symantec.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Edward Bonver is a principal software engineer on the product security team under the Office of the CTO at Symantec Corporation.  In this capacity, Edward is responsible for working with software developers and quality assurance (QA) professionals across Symantec to continuously enhance the company’s software security practices through the adoption of methodologies, procedures and tools for secure coding and security testing.  Within Symantec, Edward teaches secure coding and security testing classes for Symantec engineers, and also leads the company’s QA Security Task Force, which he founded.  Prior to joining Symantec, Edward held software engineering and QA roles at Digital Equipment Corporation, Nbase and Zuma Networks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edward is a Certified Information Systems Security Professional (CISSP) and a Certified Secure Software Lifecycle Professional (CSSLP).  He holds a master’s degree in computer science from California State University, Northridge, and a bachelor’s degree in computer science from Rochester Institute of Technology. Edward is a Ph.D. student at NOVA Southeastern University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, January 21st 2010====&lt;br /&gt;
&lt;br /&gt;
Time: 7:30&lt;br /&gt;
Location: We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus. The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020. Parking is $7 but feel free to park off campus and walk to the building. http://www.oit.uci.edu/computing/labs/training.html Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdfBD&lt;br /&gt;
&lt;br /&gt;
For those who would like to avoid paying for parking, you can park in the University Center and take the campus shuttle: http://www.shuttle.uci.edu/maincampus/index.php&lt;br /&gt;
&lt;br /&gt;
The shuttle runs until 10:45PM.  The shuttle costs $1 per ride, but fees are rarely collected ;)&lt;br /&gt;
&lt;br /&gt;
Title: Do VLANs allow for good application security? &lt;br /&gt;
 &lt;br /&gt;
Virtual Local Area Networks (VLANs) are not a new concept, and can help&lt;br /&gt;
any organization better control network access.  I will present some of&lt;br /&gt;
the previous issues identified, what was the root cause, and how these&lt;br /&gt;
have been fixed in current technology.  In addition we will talk about&lt;br /&gt;
how this can help to enhance security in your environment, and what&lt;br /&gt;
controls must be in place in order to implement such an environment.  We&lt;br /&gt;
will also touch on how this can complicate your application environment,&lt;br /&gt;
but improve overall security.&lt;br /&gt;
&lt;br /&gt;
I will touch on the controls that need to be reviewed and audited when&lt;br /&gt;
working with VMware, VLANs, and web applications, to ensure that these&lt;br /&gt;
networks are secure, and what to look for to potentially pass audit&lt;br /&gt;
criteria.  I will also talk about where and how these controls have been&lt;br /&gt;
implemented in order to protect thousands of users while accessing one&lt;br /&gt;
of the most hostile networks in the world.&lt;br /&gt;
&lt;br /&gt;
David M. N. Bryan &lt;br /&gt;
Senior Security Consultant &lt;br /&gt;
&lt;br /&gt;
David has over 9+ years of computer security experience including,&lt;br /&gt;
consulting, engineering and administration.  He has performed security&lt;br /&gt;
assessment projects for health care, nuclear, manufacturing,&lt;br /&gt;
pharmaceutical, banking and educational sectors.   As an active&lt;br /&gt;
participant in the information security community, he volunteers at&lt;br /&gt;
DEFCON where he designs and implements the Firewall and Network for what&lt;br /&gt;
is said to be the most hostile network environment in the world.  &lt;br /&gt;
&lt;br /&gt;
He is also an active participant in the local Minneapolis security&lt;br /&gt;
groups both as a board member of OWASP MSP and DC612.  His roots and&lt;br /&gt;
experience come from working for a large enterprise banks, designing and&lt;br /&gt;
managing enterprise security systems.  In the more recent years he has&lt;br /&gt;
been working as an Information Security Consultant to review the&lt;br /&gt;
security and architecture of information computing environments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday December 17th 2009====&lt;br /&gt;
&lt;br /&gt;
7:30 PM, UC Irvine Campus, Room AIRB 1020&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus.  The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020.  Parking is $7 but feel free to park off campus and walk to the building.&lt;br /&gt;
http://www.oit.uci.edu/computing/labs/training.html&lt;br /&gt;
Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf&lt;br /&gt;
&lt;br /&gt;
'''Abstract'''&lt;br /&gt;
&lt;br /&gt;
'''Title: Pulling the Plug: Security Risks in the Next Generation of Offline Web Applications'''&lt;br /&gt;
&lt;br /&gt;
As the line between desktop and web applications becomes increasingly blurry in a web 2.0 world, browser functionality is being pushed well beyond what it was originally intended for. Persistent client side storage has become a requirement for web applications if they are to be available both online and off. This need is being filled by a variety of technologies such as [http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage Gears (formerly Google Gears) and the Database Storage]   functionality included in the emerging [http://dev.w3.org/html5/spec/Overview.html HTML 5 specification]. While all such technologies offer great promise, it is clear that the vast majority of developers simply do not understand their security implications.&lt;br /&gt;
&lt;br /&gt;
Researching a variety of currently deployed implementations of these technologies has revealed a broad scope of vulnerabilities with frightening implications. Now attackers can target victims not just once, but every time they visit a site as the victim now carries and stores the attack with them. Imagine a scenario whereby updated confidential information is forwarded to an attacker every time a victim interacts with a given we application. The attacker no longer needs to worry about timing their attacks to ensure that the victim is authenticated as the victim attacks himself! Limited storage? Cookies that expire? Not a problem when entire databases are accessible with virtually unlimited storage and an infinite lifespan. Think these attacks are theoretical? Think again. In this talk we dive into these technologies and break down the risk posed by them when not properly understood. We will then detail a variety of real-world vulnerabilities that have been uncovered, including a new class of cross-site scripting and client-side SQL injection.&lt;br /&gt;
&lt;br /&gt;
'''Bio'''&lt;br /&gt;
&lt;br /&gt;
'''Michael Sutton'''&lt;br /&gt;
'''Vice President, Security Research – Zscaler'''&lt;br /&gt;
&lt;br /&gt;
Michael Sutton has spent more than a decade in the security industry conducting leading-edge research, building teams of world-class researchers and educating others on a variety of security topics. As VP of Security Research, Michael heads Zscaler Labs, the research and development arm of the company. Zscaler Labs is responsible for researching emerging topics in web security and developing innovative security controls, which leverage the Zscaler in-the-cloud model. The team is comprised of researchers with a wealth of experience in the security industry.    &lt;br /&gt;
&lt;br /&gt;
Prior to joining Zscaler, Michael was the Security Evangelist for SPI Dynamics where, as an industry expert, he was responsible for researching, publishing and presenting on various security issues. In 2007, SPI Dynamics was acquired by Hewlett-Packard. Previously, Michael was a Research Director at iDefense where he led iDefense Labs, a team responsible for discovering and researching security vulnerabilities in a variety of technologies. iDefense was acquired by VeriSign in 2005. Michael is a frequent speaker at major information security conferences; he is regularly quoted by the media on various information security topics, has authored numerous articles and is the co-author of Fuzzing: Brute Force Vulnerability Discovery, an Addison-Wesley publication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, November 19th 2009====&lt;br /&gt;
&lt;br /&gt;
When: November 19th 2009, 7:30PM&lt;br /&gt;
Where: Gina's Pizza, Irvine&lt;br /&gt;
Topics: Facebook privacy, web application firewalls, penetration testing, the reluctance for hackers to execute attacks, and random new technology.  Announced OWASP OC/LAs intention to submit a proposal for AppSec 2010.&lt;br /&gt;
&lt;br /&gt;
====Wednesday, October 14th 2009====&lt;br /&gt;
&lt;br /&gt;
Separate meetings will be held for OWASP OC and OWASP@UCI (student group).&lt;br /&gt;
&lt;br /&gt;
When:  Wednesday 10/14  7:30PM&lt;br /&gt;
Where:  Steelhead Brewery&lt;br /&gt;
Topics:  News, Ideas, Chit-chat&lt;br /&gt;
&lt;br /&gt;
This is a restaurant/bar with plenty of seating, but room for a projector is out of the question so this would be an informal round table discussion.&lt;br /&gt;
&lt;br /&gt;
I have a presentation I'm working on regarding WAFs and Vulnerability Assessment Tools.  If it pleases the group, I'd love to go over the presentation and discuss everyone's experiences.  Also, it's a great way to get feedback :)&lt;br /&gt;
&lt;br /&gt;
Neil&lt;br /&gt;
&lt;br /&gt;
I'm open to suggestions of any kind: location, time, topics, etc&lt;br /&gt;
&lt;br /&gt;
====Thursday, September 17th, 2009 7:30PM ====&lt;br /&gt;
'''Location:''' UC Irvine &lt;br /&gt;
Building: Calit2 building,building number 325 in quadrant H8 on the [http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf UC Irvine Map]&lt;br /&gt;
Room: 3008&lt;br /&gt;
&lt;br /&gt;
Parking will be $7.&lt;br /&gt;
Please park in the [http://maps.google.com/maps?li=d&amp;amp;hl=en&amp;amp;f=d&amp;amp;iwstate1=dir:to&amp;amp;daddr=Parking+Structure+for+CalIT2%4033.643082,+-117.837593&amp;amp;geocode=CSJ9b4xJxrzxFUpaAQId5_D5-A&amp;amp;iwloc=1&amp;amp;dq=calit2,+uc+irvine,+ca&amp;amp;cid=33643082,-117837593,16505793731713499531&amp;amp;ei=v3bvSabfO6LejAOR2pjgAQ Anteater Parking Structure]&lt;br /&gt;
&lt;br /&gt;
I can only unofficially say that if you park in the nearby shopping centers and walk, you may be able to park for free.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;The Rise of Threat Analysis and the Fall of Compliance, Policies, and Standards in mitigating Web Application Security Risks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Apr 30, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Our fourth OC OWASP meeting will be an informal, roundtable discussion of current application security issues. Feel free to bring some ideas, code, slides, etc to contribute to the discussion. Hope to see everyone there!&lt;br /&gt;
&lt;br /&gt;
====Feb 19, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come talk application security at the third OWASP OC meeting. We'll discuss current application security topics and chapter issues over pizza. We have a room booked for 15-20 people so we'll be able to rant without disturbing the patrons :) See you there! [https://www.owasp.org/images/5/58/Cloud_Computing_Security.pdf Presentation Slides]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dec 17, 2008 6PM - 9PM====&lt;br /&gt;
Microsoft Campus&lt;br /&gt;
Room MPR1, 3 Park Plaza, Suite 1600, Irvine, CA, 92614&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=microsoft,+Irvine,+CA,+92614&amp;amp;sll=33.678479,-117.838368&amp;amp;sspn=0.009892,0.022745&amp;amp;g=3+Park+Plaza,+Irvine,+CA,+92614&amp;amp;ie=UTF8&amp;amp;ei=sCFJSfKPEo3UNc2ZmCc&amp;amp;cd=1&amp;amp;cid=33728042,-117783305,17507068988286890825&amp;amp;li=lmd&amp;amp;ll=33.731835,-117.78142&amp;amp;spn=0.039545,0.090981&amp;amp;z=14&amp;amp;iwloc=A Google Map]&lt;br /&gt;
&lt;br /&gt;
This meeting will be a roundtable discussion of application security news, plus a few OWASP-themed challenges with prizes. Pizza will be provided and we'll head to the Yard House after the meeting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Aug 27, 2008, 7 PM - 9 PM====&lt;br /&gt;
Penny Saver&lt;br /&gt;
&lt;br /&gt;
603 Valencia, Brea, CA 92822&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=603+valencia,+Brea,+CA+92822&amp;amp;sll=33.911348,-117.851629&amp;amp;sspn=0.009865,0.022745&amp;amp;ie=UTF8&amp;amp;ll=33.909478,-117.852917&amp;amp;spn=0.009866,0.022745&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come meet up with web security professionals, have some pizza, and offer your thoughts for the direction of the OC chapter at our inaugural meeting! We are looking for speakers and venue sponsors for the next meeting. If you are interested, please contact the chapter leaders. Everyone is welcome to join us at our chapter meetings.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Chapter]]&lt;br /&gt;
&lt;br /&gt;
= Orange County OWASP Board Members =&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; [mailto:neil@owasp.org Neil Matatall]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Shong Chong&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Rob LaViolette&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Treasurer:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Recording Secretary:&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:California]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120445</id>
		<title>Abridged SQL Injection Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120445"/>
				<updated>2011-11-18T22:20:16Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most damaging web vulnerabilities.  It represents a serious threat because SQL Injection allows evil attacker code to change the structure of a web application's SQL statement in a way that can steal data, modify data, or facilitate command injection.  This cheat sheet is a derivative work of the [[SQL Injection Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Parametrized Query Examples =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is best prevented through the use of [https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29 ''parametrized queries'']. The following chart demonstrates, with real-world code samples, how to build parametrized queries in most of the common web languages.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Language - Library&lt;br /&gt;
! Parametrized Query&lt;br /&gt;
|-&lt;br /&gt;
| Java - Standard&lt;br /&gt;
|   &lt;br /&gt;
 String custname = request.getParameter(&amp;quot;customerName&amp;quot;); &lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ? &amp;quot;;  &lt;br /&gt;
 '''PreparedStatement pstmt = connection.prepareStatement( query );'''&lt;br /&gt;
 '''pstmt.setString( 1, custname); '''&lt;br /&gt;
 ResultSet results = pstmt.executeQuery( );&lt;br /&gt;
|-&lt;br /&gt;
| Java - Hibernate&lt;br /&gt;
|&lt;br /&gt;
 Query safeHQLQuery = session.createQuery(&amp;quot;from Inventory where productID=:productid&amp;quot;);&lt;br /&gt;
 safeHQLQuery.setParameter(&amp;quot;productid&amp;quot;, userSuppliedParameter);&lt;br /&gt;
|-&lt;br /&gt;
| .NET/C#&lt;br /&gt;
|&lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ?&amp;quot;;&lt;br /&gt;
 try {&lt;br /&gt;
    OleDbCommand command = new OleDbCommand(query, connection);&lt;br /&gt;
    '''command.Parameters.Add(new OleDbParameter(&amp;quot;customerName&amp;quot;, CustomerName Name.Text));'''&lt;br /&gt;
    OleDbDataReader reader = command.ExecuteReader();&lt;br /&gt;
    // …&lt;br /&gt;
 } catch (OleDbException se) {&lt;br /&gt;
    // error handling&lt;br /&gt;
 } &lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET&lt;br /&gt;
|&lt;br /&gt;
 string sql = &amp;quot;SELECT * FROM Customers WHERE CustomerId = @CustomerId&amp;quot;;&lt;br /&gt;
 '''SqlCommand command = new SqlCommand(sql);'''&lt;br /&gt;
 '''command.Parameters.Add(new SqlParameter(&amp;quot;@CustomerId&amp;quot;, System.Data.SqlDbType.Int));'''&lt;br /&gt;
 command.Parameters[&amp;quot;@CustomerId&amp;quot;].Value = 1;&lt;br /&gt;
|-&lt;br /&gt;
| Ruby - ActiveRecord&lt;br /&gt;
|  &lt;br /&gt;
 '''# Create'''&lt;br /&gt;
 Project.create!(:name =&amp;gt; 'owasp')&lt;br /&gt;
 '''# Read'''&lt;br /&gt;
 Project.all(:conditions =&amp;gt; &amp;quot;name = ?&amp;quot;, name)&lt;br /&gt;
 Project.all(:conditions =&amp;gt; { :name =&amp;gt; name })&lt;br /&gt;
 Project.where(&amp;quot;name = :name&amp;quot;, :name =&amp;gt; name)&lt;br /&gt;
 '''# Update'''&lt;br /&gt;
 project.update_attributes(:name =&amp;gt; 'owasp')&lt;br /&gt;
 '''# Delete'''&lt;br /&gt;
 Project.delete(:name =&amp;gt; 'name')&lt;br /&gt;
|-&lt;br /&gt;
| Ruby&lt;br /&gt;
|&lt;br /&gt;
 insert_new_user = db.prepare &amp;quot;INSERT INTO users (name, age, gender) VALUES (?, ? ,?)&amp;quot;&lt;br /&gt;
 insert_new_user.execute 'aizatto', '20', 'male'&lt;br /&gt;
|-&lt;br /&gt;
| PHP - PDO&lt;br /&gt;
| &lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&amp;quot;);&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':name', $name);'''&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':value', $value);'''&lt;br /&gt;
|-&lt;br /&gt;
| Cold Fusion&lt;br /&gt;
| &lt;br /&gt;
 &amp;lt;cfquery name = &amp;quot;getFirst&amp;quot; dataSource = &amp;quot;cfsnippets&amp;quot;&amp;gt;&lt;br /&gt;
     '''SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID ='''&lt;br /&gt;
     '''&amp;lt;cfqueryparam value = #intCourseID# CFSQLType = &amp;quot;CF_SQL_INTEGER&amp;quot;&amp;gt;'''&lt;br /&gt;
 &amp;lt;/cfquery&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Perl - DBI&lt;br /&gt;
| &lt;br /&gt;
 my $sql = &amp;quot;INSERT INTO foo (bar, baz) VALUES ( ?, ? )&amp;quot;;&lt;br /&gt;
 '''my $sth = $dbh-&amp;gt;prepare( $sql );'''&lt;br /&gt;
 '''$sth-&amp;gt;execute( $bar, $baz );'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120444</id>
		<title>Abridged SQL Injection Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120444"/>
				<updated>2011-11-18T22:04:18Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Parametrized Query Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most damaging web vulnerabilities.  It represents a serious threat because SQL Injection allows evil attacker code to change the structure of a web application's SQL statement in a way that can steal data, modify data, or facilitate command injection.  This cheat sheet is a derivative work of the [[SQL Injection Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Parametrized Query Examples =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is best prevented through the use of [https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29 ''parametrized queries'']. The following chart demonstrates, with real-world code samples, how to build parametrized queries in most of the common web languages.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Language - Library&lt;br /&gt;
! Parametrized Query&lt;br /&gt;
|-&lt;br /&gt;
| Java - Standard&lt;br /&gt;
|   &lt;br /&gt;
 String custname = request.getParameter(&amp;quot;customerName&amp;quot;); &lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ? &amp;quot;;  &lt;br /&gt;
 '''PreparedStatement pstmt = connection.prepareStatement( query );'''&lt;br /&gt;
 '''pstmt.setString( 1, custname); '''&lt;br /&gt;
 ResultSet results = pstmt.executeQuery( );&lt;br /&gt;
|-&lt;br /&gt;
| Java - Hibernate&lt;br /&gt;
|&lt;br /&gt;
 Query safeHQLQuery = session.createQuery(&amp;quot;from Inventory where productID=:productid&amp;quot;);&lt;br /&gt;
 safeHQLQuery.setParameter(&amp;quot;productid&amp;quot;, userSuppliedParameter);&lt;br /&gt;
|-&lt;br /&gt;
| .NET/C#&lt;br /&gt;
|&lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ?&amp;quot;;&lt;br /&gt;
 try {&lt;br /&gt;
    OleDbCommand command = new OleDbCommand(query, connection);&lt;br /&gt;
    '''command.Parameters.Add(new OleDbParameter(&amp;quot;customerName&amp;quot;, CustomerName Name.Text));'''&lt;br /&gt;
    OleDbDataReader reader = command.ExecuteReader();&lt;br /&gt;
    // …&lt;br /&gt;
 } catch (OleDbException se) {&lt;br /&gt;
    // error handling&lt;br /&gt;
 } &lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET&lt;br /&gt;
|&lt;br /&gt;
 string sql = &amp;quot;SELECT * FROM Customers WHERE CustomerId = @CustomerId&amp;quot;;&lt;br /&gt;
 '''SqlCommand command = new SqlCommand(sql);'''&lt;br /&gt;
 '''command.Parameters.Add(new SqlParameter(&amp;quot;@CustomerId&amp;quot;, System.Data.SqlDbType.Int));'''&lt;br /&gt;
 command.Parameters[&amp;quot;@CustomerId&amp;quot;].Value = 1;&lt;br /&gt;
|-&lt;br /&gt;
| Ruby - ActiveRecord&lt;br /&gt;
|  &lt;br /&gt;
 '''# Create'''&lt;br /&gt;
 Project.create!(:name =&amp;gt; 'owasp')&lt;br /&gt;
 '''# Read'''&lt;br /&gt;
 Project.all(:conditions =&amp;gt; &amp;quot;name = ?&amp;quot;, name)&lt;br /&gt;
 Project.all(:conditions =&amp;gt; { :name =&amp;gt; name })&lt;br /&gt;
 Project.where(&amp;quot;name = :name&amp;quot;, :name =&amp;gt; name)&lt;br /&gt;
 '''# Update'''&lt;br /&gt;
 project.update_attributes(:name =&amp;gt; 'owasp')&lt;br /&gt;
 '''# Delete'''&lt;br /&gt;
 Project.delete(:name =&amp;gt; 'name')&lt;br /&gt;
|-&lt;br /&gt;
| PHP - PDO&lt;br /&gt;
| &lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&amp;quot;);&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':name', $name);'''&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':value', $value);'''&lt;br /&gt;
|-&lt;br /&gt;
| Cold Fusion&lt;br /&gt;
| &lt;br /&gt;
 &amp;lt;cfquery name = &amp;quot;getFirst&amp;quot; dataSource = &amp;quot;cfsnippets&amp;quot;&amp;gt;&lt;br /&gt;
     '''SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID ='''&lt;br /&gt;
     '''&amp;lt;cfqueryparam value = #intCourseID# CFSQLType = &amp;quot;CF_SQL_INTEGER&amp;quot;&amp;gt;'''&lt;br /&gt;
 &amp;lt;/cfquery&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Perl - DBI&lt;br /&gt;
| &lt;br /&gt;
 my $sql = &amp;quot;INSERT INTO foo (bar, baz) VALUES ( ?, ? )&amp;quot;;&lt;br /&gt;
 '''my $sth = $dbh-&amp;gt;prepare( $sql );'''&lt;br /&gt;
 '''$sth-&amp;gt;execute( $bar, $baz );'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120442</id>
		<title>Abridged SQL Injection Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120442"/>
				<updated>2011-11-18T21:46:15Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most damaging web vulnerabilities.  It represents a serious threat because SQL Injection allows evil attacker code to change the structure of a web application's SQL statement in a way that can steal data, modify data, or facilitate command injection.  This cheat sheet is a derivative work of the [[SQL Injection Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Parametrized Query Examples =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is best prevented through the use of [https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29 ''parametrized queries'']. The following chart demonstrates, with real-world code samples, how to build parametrized queries in most of the common web languages.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Language - Library&lt;br /&gt;
! Parametrized Query&lt;br /&gt;
|-&lt;br /&gt;
| Java - Standard&lt;br /&gt;
|   &lt;br /&gt;
 String custname = request.getParameter(&amp;quot;customerName&amp;quot;); &lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ? &amp;quot;;  &lt;br /&gt;
 '''PreparedStatement pstmt = connection.prepareStatement( query );'''&lt;br /&gt;
 '''pstmt.setString( 1, custname); '''&lt;br /&gt;
 ResultSet results = pstmt.executeQuery( );&lt;br /&gt;
|-&lt;br /&gt;
| Java - Hibernate&lt;br /&gt;
|&lt;br /&gt;
 Query safeHQLQuery = session.createQuery(&amp;quot;from Inventory where productID=:productid&amp;quot;);&lt;br /&gt;
 safeHQLQuery.setParameter(&amp;quot;productid&amp;quot;, userSuppliedParameter);&lt;br /&gt;
|-&lt;br /&gt;
| .NET/C#&lt;br /&gt;
|&lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ?&amp;quot;;&lt;br /&gt;
 try {&lt;br /&gt;
    OleDbCommand command = new OleDbCommand(query, connection);&lt;br /&gt;
    '''command.Parameters.Add(new OleDbParameter(&amp;quot;customerName&amp;quot;, CustomerName Name.Text));'''&lt;br /&gt;
    OleDbDataReader reader = command.ExecuteReader();&lt;br /&gt;
    // …&lt;br /&gt;
 } catch (OleDbException se) {&lt;br /&gt;
    // error handling&lt;br /&gt;
 } &lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET&lt;br /&gt;
|&lt;br /&gt;
 string sql = &amp;quot;SELECT * FROM Customers WHERE CustomerId = @CustomerId&amp;quot;;&lt;br /&gt;
 '''SqlCommand command = new SqlCommand(sql);'''&lt;br /&gt;
 '''command.Parameters.Add(new SqlParameter(&amp;quot;@CustomerId&amp;quot;, System.Data.SqlDbType.Int));'''&lt;br /&gt;
 command.Parameters[&amp;quot;@CustomerId&amp;quot;].Value = 1;&lt;br /&gt;
|-&lt;br /&gt;
| Ruby - ActiveRecord&lt;br /&gt;
|  &lt;br /&gt;
 '''# Create'''&lt;br /&gt;
 '''Project.create!(:name =&amp;gt; 'owasp')'''&lt;br /&gt;
 '''# Read'''&lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; &amp;quot;name = ?&amp;quot;, name)'''&lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; { :name =&amp;gt; name })'''&lt;br /&gt;
 '''Project.where(&amp;quot;name = :name&amp;quot;, :name =&amp;gt; name)'''&lt;br /&gt;
 '''# Update'''&lt;br /&gt;
 '''project.update_attributes(:name =&amp;gt; 'owasp')'''&lt;br /&gt;
 '''# Delete'''&lt;br /&gt;
 '''Project.delete(:name =&amp;gt; 'name')'''&lt;br /&gt;
|-&lt;br /&gt;
| PHP - PDO&lt;br /&gt;
| &lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&amp;quot;);&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':name', $name);'''&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':value', $value);'''&lt;br /&gt;
|-&lt;br /&gt;
| Cold Fusion&lt;br /&gt;
| &lt;br /&gt;
 &amp;lt;cfquery name = &amp;quot;getFirst&amp;quot; dataSource = &amp;quot;cfsnippets&amp;quot;&amp;gt;&lt;br /&gt;
     '''SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID ='''&lt;br /&gt;
     '''&amp;lt;cfqueryparam value = #intCourseID# CFSQLType = &amp;quot;CF_SQL_INTEGER&amp;quot;&amp;gt;'''&lt;br /&gt;
 &amp;lt;/cfquery&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Perl - DBI&lt;br /&gt;
| &lt;br /&gt;
 my $sql = &amp;quot;INSERT INTO foo (bar, baz) VALUES ( ?, ? )&amp;quot;;&lt;br /&gt;
 '''my $sth = $dbh-&amp;gt;prepare( $sql );'''&lt;br /&gt;
 '''$sth-&amp;gt;execute( $bar, $baz );'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120441</id>
		<title>Abridged SQL Injection Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120441"/>
				<updated>2011-11-18T21:40:08Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Parametrized Query Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most damaging web vulnerabilities.  It represents a serious threat because SQL Injection allows evil attacker code to change the structure of a web application's SQL statement in a way that can steal data, modify data, or facilitate command injection.  This cheat sheet is a derivative work of the [[SQL Injection Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Parametrized Query Examples =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is best prevented through the use of [https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29 ''parametrized queries'']. The following chart demonstrates, with real-world code samples, how to build parametrized queries in most of the common web languages.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Language - Library&lt;br /&gt;
! Parametrized Query&lt;br /&gt;
|-&lt;br /&gt;
| Java - Standard&lt;br /&gt;
|   &lt;br /&gt;
 String custname = request.getParameter(&amp;quot;customerName&amp;quot;); &lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ? &amp;quot;;  &lt;br /&gt;
 '''PreparedStatement pstmt = connection.prepareStatement( query );'''&lt;br /&gt;
 '''pstmt.setString( 1, custname); '''&lt;br /&gt;
 ResultSet results = pstmt.executeQuery( );&lt;br /&gt;
|-&lt;br /&gt;
| Java - Hibernate&lt;br /&gt;
|&lt;br /&gt;
 Query safeHQLQuery = session.createQuery(&amp;quot;from Inventory where productID=:productid&amp;quot;);&lt;br /&gt;
 safeHQLQuery.setParameter(&amp;quot;productid&amp;quot;, userSuppliedParameter);&lt;br /&gt;
|-&lt;br /&gt;
| .NET/C#&lt;br /&gt;
|&lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ?&amp;quot;;&lt;br /&gt;
 try {&lt;br /&gt;
    OleDbCommand command = new OleDbCommand(query, connection);&lt;br /&gt;
    '''command.Parameters.Add(new OleDbParameter(&amp;quot;customerName&amp;quot;, CustomerName Name.Text));'''&lt;br /&gt;
    OleDbDataReader reader = command.ExecuteReader();&lt;br /&gt;
    // …&lt;br /&gt;
 } catch (OleDbException se) {&lt;br /&gt;
    // error handling&lt;br /&gt;
 } &lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET&lt;br /&gt;
|&lt;br /&gt;
 string sql = &amp;quot;SELECT * FROM Customers WHERE CustomerId = @CustomerId&amp;quot;;&lt;br /&gt;
 '''SqlCommand command = new SqlCommand(sql);'''&lt;br /&gt;
 '''command.Parameters.Add(new SqlParameter(&amp;quot;@CustomerId&amp;quot;, System.Data.SqlDbType.Int));'''&lt;br /&gt;
 command.Parameters[&amp;quot;@CustomerId&amp;quot;].Value = 1;&lt;br /&gt;
|-&lt;br /&gt;
| Ruby - ActiveRecord&lt;br /&gt;
| &lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; &amp;quot;name = ?&amp;quot;, name)'''&lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; { :name =&amp;gt; name })'''&lt;br /&gt;
 '''Project.where(&amp;quot;name = :name&amp;quot;, :name =&amp;gt; name)'''&lt;br /&gt;
|-&lt;br /&gt;
| PHP - PDO&lt;br /&gt;
| &lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&amp;quot;);&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':name', $name);'''&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':value', $value);'''&lt;br /&gt;
|-&lt;br /&gt;
| Cold Fusion&lt;br /&gt;
| &lt;br /&gt;
 &amp;lt;cfquery name = &amp;quot;getFirst&amp;quot; dataSource = &amp;quot;cfsnippets&amp;quot;&amp;gt;&lt;br /&gt;
     '''SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID ='''&lt;br /&gt;
     '''&amp;lt;cfqueryparam value = #intCourseID# CFSQLType = &amp;quot;CF_SQL_INTEGER&amp;quot;&amp;gt;'''&lt;br /&gt;
 &amp;lt;/cfquery&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Perl - DBI&lt;br /&gt;
| &lt;br /&gt;
 my $sql = &amp;quot;INSERT INTO foo (bar, baz) VALUES ( ?, ? )&amp;quot;;&lt;br /&gt;
 '''my $sth = $dbh-&amp;gt;prepare( $sql );'''&lt;br /&gt;
 '''$sth-&amp;gt;execute( $bar, $baz );'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120440</id>
		<title>Abridged SQL Injection Prevention Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Abridged_SQL_Injection_Prevention_Cheat_Sheet&amp;diff=120440"/>
				<updated>2011-11-18T21:39:16Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Parametrized Query Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= DRAFT CHEAT SHEET - WORK IN PROGRESS =&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is one of the most damaging web vulnerabilities.  It represents a serious threat because SQL Injection allows evil attacker code to change the structure of a web application's SQL statement in a way that can steal data, modify data, or facilitate command injection.  This cheat sheet is a derivative work of the [[SQL Injection Prevention Cheat Sheet]].&lt;br /&gt;
&lt;br /&gt;
= Parametrized Query Examples =&lt;br /&gt;
&lt;br /&gt;
SQL Injection is best prevented through the use of [https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet#Defense_Option_1:_Prepared_Statements_.28Parameterized_Queries.29 ''parametrized queries'']. The following chart demonstrates, with real-world code samples, how to build parametrized queries in most of the common web languages.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable nowraplinks&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Language - Library&lt;br /&gt;
! Parametrized Query&lt;br /&gt;
|-&lt;br /&gt;
| Java - Standard&lt;br /&gt;
|   &lt;br /&gt;
 String custname = request.getParameter(&amp;quot;customerName&amp;quot;); &lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ? &amp;quot;;  &lt;br /&gt;
 '''PreparedStatement pstmt = connection.prepareStatement( query );'''&lt;br /&gt;
 '''pstmt.setString( 1, custname); '''&lt;br /&gt;
 ResultSet results = pstmt.executeQuery( );&lt;br /&gt;
|-&lt;br /&gt;
| Java - Hibernate&lt;br /&gt;
|&lt;br /&gt;
 Query safeHQLQuery = session.createQuery(&amp;quot;from Inventory where productID=:productid&amp;quot;);&lt;br /&gt;
 safeHQLQuery.setParameter(&amp;quot;productid&amp;quot;, userSuppliedParameter);&lt;br /&gt;
|-&lt;br /&gt;
| .NET/C#&lt;br /&gt;
|&lt;br /&gt;
 String query = &amp;quot;SELECT account_balance FROM user_data WHERE user_name = ?&amp;quot;;&lt;br /&gt;
 try {&lt;br /&gt;
    OleDbCommand command = new OleDbCommand(query, connection);&lt;br /&gt;
    '''command.Parameters.Add(new OleDbParameter(&amp;quot;customerName&amp;quot;, CustomerName Name.Text));'''&lt;br /&gt;
    OleDbDataReader reader = command.ExecuteReader();&lt;br /&gt;
    // …&lt;br /&gt;
 } catch (OleDbException se) {&lt;br /&gt;
    // error handling&lt;br /&gt;
 } &lt;br /&gt;
|-&lt;br /&gt;
| ASP.NET&lt;br /&gt;
|&lt;br /&gt;
 string sql = &amp;quot;SELECT * FROM Customers WHERE CustomerId = @CustomerId&amp;quot;;&lt;br /&gt;
 '''SqlCommand command = new SqlCommand(sql);'''&lt;br /&gt;
 '''command.Parameters.Add(new SqlParameter(&amp;quot;@CustomerId&amp;quot;, System.Data.SqlDbType.Int));'''&lt;br /&gt;
 command.Parameters[&amp;quot;@CustomerId&amp;quot;].Value = 1;&lt;br /&gt;
|-&lt;br /&gt;
| Ruby&lt;br /&gt;
| &lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; &amp;quot;name = ?&amp;quot;, name)'''&lt;br /&gt;
 '''Project.all(:conditions =&amp;gt; { :name =&amp;gt; name })'''&lt;br /&gt;
|-&lt;br /&gt;
| PHP - PDO&lt;br /&gt;
| &lt;br /&gt;
 $stmt = $dbh-&amp;gt;prepare(&amp;quot;INSERT INTO REGISTRY (name, value) VALUES (:name, :value)&amp;quot;);&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':name', $name);'''&lt;br /&gt;
 '''$stmt-&amp;gt;bindParam(':value', $value);'''&lt;br /&gt;
|-&lt;br /&gt;
| Cold Fusion&lt;br /&gt;
| &lt;br /&gt;
 &amp;lt;cfquery name = &amp;quot;getFirst&amp;quot; dataSource = &amp;quot;cfsnippets&amp;quot;&amp;gt;&lt;br /&gt;
     '''SELECT * FROM #strDatabasePrefix#_courses WHERE intCourseID ='''&lt;br /&gt;
     '''&amp;lt;cfqueryparam value = #intCourseID# CFSQLType = &amp;quot;CF_SQL_INTEGER&amp;quot;&amp;gt;'''&lt;br /&gt;
 &amp;lt;/cfquery&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Perl - DBI&lt;br /&gt;
| &lt;br /&gt;
 my $sql = &amp;quot;INSERT INTO foo (bar, baz) VALUES ( ?, ? )&amp;quot;;&lt;br /&gt;
 '''my $sth = $dbh-&amp;gt;prepare( $sql );'''&lt;br /&gt;
 '''$sth-&amp;gt;execute( $bar, $baz );'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Related Articles =&lt;br /&gt;
&lt;br /&gt;
{{Cheatsheet_Navigation}}&lt;br /&gt;
&lt;br /&gt;
= Authors and Primary Editors  =&lt;br /&gt;
&lt;br /&gt;
Jim Manico - jim [at] owasp.org&lt;br /&gt;
&lt;br /&gt;
[[Category:Cheatsheets]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/Current&amp;diff=119759</id>
		<title>Projects/OWASP Passw3rd Project/Releases/Current</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/Current&amp;diff=119759"/>
				<updated>2011-11-02T18:20:38Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: Redirected page to Projects/OWASP Passw3rd Project/Releases/passw3rd-0.1.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;  #REDIRECT [[Projects/OWASP Passw3rd Project/Releases/passw3rd-0.1.0]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/Current&amp;diff=119758</id>
		<title>Projects/OWASP Passw3rd Project/Releases/Current</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/Current&amp;diff=119758"/>
				<updated>2011-11-02T18:19:35Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: Redirected page to Https://www.owasp.org/index.php/Projects/OWASP Passw3rd Project/Releases/passw3rd-0.1.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;  #REDIRECT [[https://www.owasp.org/index.php/Projects/OWASP_Passw3rd_Project/Releases/passw3rd-0.1.0]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/passw3rd-0.1.0&amp;diff=119757</id>
		<title>Projects/OWASP Passw3rd Project/Releases/passw3rd-0.1.0</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/passw3rd-0.1.0&amp;diff=119757"/>
				<updated>2011-11-02T18:18:46Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: Created page with &amp;quot;{{Template: &amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Release About&amp;lt;/noinclude&amp;gt; | project_name = Passw3rd | project_home_page = https://www.owasp.org/index.php/OWASP_Passw3rd_...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template: &amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Release About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = Passw3rd&lt;br /&gt;
| project_home_page = https://www.owasp.org/index.php/OWASP_Passw3rd_Project&lt;br /&gt;
&lt;br /&gt;
| release_name = passw3rd-0.1.0&lt;br /&gt;
| release_date = Nov 1, 2011&lt;br /&gt;
| release_description = AES 256 by default, support URIs, production level code (hopefully)&lt;br /&gt;
| release_license = MIT&lt;br /&gt;
| release_download_link = https://rubygems.org/gems/passw3rd/versions/0.1.0&lt;br /&gt;
 &lt;br /&gt;
| leader_name[1] = Neil Matatall&lt;br /&gt;
| leader_email[1] = neil@owasp.org&lt;br /&gt;
| leader_username[1] = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1] = Neil Matatall&lt;br /&gt;
| contributor_email[1] = neil@owasp.org&lt;br /&gt;
| contributor_username[1] =  nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[2] = Edward Bonver&lt;br /&gt;
| contributor_name[3] = Ben Duoung&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
| release_notes = https://github.com/oreoshake/passw3rd/commit/4ff412fe03c201ca86bb76466a7e095870d19973&lt;br /&gt;
&lt;br /&gt;
| links_url[1] = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name[1] = Github page&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119756</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119756"/>
				<updated>2011-11-02T18:11:38Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = Brendon Murphey&lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/f/f7/Passw3rd.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url4 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name4 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url3 = https://github.com/bemurphy&lt;br /&gt;
| links_name3 = Brendon Murphey's Github Page&lt;br /&gt;
| links_url2 = http://www.youtube.com/watch?v=BzbiSPOJUxc&amp;amp;feature=channel_video_title&lt;br /&gt;
| links_name2 = OC Rails Passw3rd Presentation on youtube&lt;br /&gt;
| links_url[5-10] = &lt;br /&gt;
| links_name[5-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = passw3rd-0.1.0&lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Passw3rd.pptx&amp;diff=119755</id>
		<title>File:Passw3rd.pptx</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Passw3rd.pptx&amp;diff=119755"/>
				<updated>2011-11-02T18:10:26Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119569</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119569"/>
				<updated>2011-10-26T07:54:36Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = Brendon Murphey&lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = &lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url4 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name4 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url3 = https://github.com/bemurphy&lt;br /&gt;
| links_name3 = Brendon Murphey's Github Page&lt;br /&gt;
| links_url2 = http://www.youtube.com/watch?v=BzbiSPOJUxc&amp;amp;feature=channel_video_title&lt;br /&gt;
| links_name2 = OC Rails Passw3rd Presentation on youtube&lt;br /&gt;
| links_url[5-10] = &lt;br /&gt;
| links_name[5-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = &lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119568</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119568"/>
				<updated>2011-10-26T07:53:43Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = Brendon Murphey&lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = &lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url2 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name2 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url3 = https://github.com/bemurphy&lt;br /&gt;
| links_name3 = Brendon Murphey's Github Page&lt;br /&gt;
| links_url4 = http://www.youtube.com/watch?v=BzbiSPOJUxc&amp;amp;feature=channel_video_title&lt;br /&gt;
| links_name4 = Github Presentation on youtube&lt;br /&gt;
| links_url[5-10] = &lt;br /&gt;
| links_name[5-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = &lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119567</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=119567"/>
				<updated>2011-10-26T07:52:29Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = Brendon Murphey&lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = &lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url2 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name2 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url[3] = https://github.com/bemurphy&lt;br /&gt;
| links_name[3] = Brendon Murphey's Github Page&lt;br /&gt;
| links_url[4] = http://www.youtube.com/watch?v=BzbiSPOJUxc&amp;amp;feature=channel_video_title&lt;br /&gt;
| links_name[4] = Github Presentation on youtube&lt;br /&gt;
| links_url[5-10] = &lt;br /&gt;
| links_name[5-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = &lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=118992</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=118992"/>
				<updated>2011-10-13T06:37:18Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = Brendon Murphey&lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = &lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url2 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name2 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url[3] = https://github.com/bemurphy&lt;br /&gt;
| links_name[3] = Brendon Murphey's Github Page&lt;br /&gt;
| links_url[4-10] = &lt;br /&gt;
| links_name[3-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = &lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=118657</id>
		<title>Projects/OWASP Passw3rd Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project&amp;diff=118657"/>
				<updated>2011-10-06T17:40:27Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:&amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Project About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
| project_description = Store passwords in encrypted files with an easy to use command line interface, and utilities to use the passwords in code.  In its simplest form, the keys are generated per environment with OS access controls while the password files are stored in SCM.&lt;br /&gt;
&lt;br /&gt;
| project_license = MIT&lt;br /&gt;
&lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = &lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] = &lt;br /&gt;
&lt;br /&gt;
| pamphlet_link = &lt;br /&gt;
&lt;br /&gt;
| presentation_link = https://www.owasp.org/images/8/86/Passw3rd-Pamphlet.pptx&lt;br /&gt;
&lt;br /&gt;
| mailing_list_name = https://lists.owasp.org/mailman/listinfo/owasp-passw3rd-project&lt;br /&gt;
&lt;br /&gt;
| project_road_map = https://www.owasp.org/index.php/OWASP_Passw3rd_Project/Roadmap&lt;br /&gt;
&lt;br /&gt;
| links_url1 = https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Passw3rd @ Github&lt;br /&gt;
&lt;br /&gt;
| links_url2 = http://rubygems.org/gems/passw3rd&lt;br /&gt;
| links_name2 =  Passw3rd @ Ruby Gems&lt;br /&gt;
&lt;br /&gt;
| links_url[3-10] = &lt;br /&gt;
| links_name[3-10] = &lt;br /&gt;
&lt;br /&gt;
| release_1 = password-0.0.5&lt;br /&gt;
| release_2 = &lt;br /&gt;
| release_3 =&lt;br /&gt;
| release_4 =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- The line below is for GPC usage only. Please do not edit it ---&amp;gt;&lt;br /&gt;
| project_about_page = Projects/OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=File:Passw3rd-Pamphlet.pptx&amp;diff=118656</id>
		<title>File:Passw3rd-Pamphlet.pptx</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=File:Passw3rd-Pamphlet.pptx&amp;diff=118656"/>
				<updated>2011-10-06T17:39:08Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/password-0.0.5&amp;diff=118577</id>
		<title>Projects/OWASP Passw3rd Project/Releases/password-0.0.5</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/password-0.0.5&amp;diff=118577"/>
				<updated>2011-10-04T20:16:31Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template: &amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Release About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
| release_name = password-0.0.5&lt;br /&gt;
| release_date = October 2011&lt;br /&gt;
| release_description = Working versions of the java and ruby libraries and clients.&lt;br /&gt;
| release_license = MIT&lt;br /&gt;
&lt;br /&gt;
| release_download_link =http://rubygems.org/gems/passw3rd&lt;br /&gt;
 &lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = &lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] =  &lt;br /&gt;
&lt;br /&gt;
| release_notes =&lt;br /&gt;
&lt;br /&gt;
| links_url1=https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Github Repository&lt;br /&gt;
&lt;br /&gt;
| links_url[1-10] =&lt;br /&gt;
| links_name[1-10] =&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/password-0.0.5&amp;diff=118576</id>
		<title>Projects/OWASP Passw3rd Project/Releases/password-0.0.5</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Projects/OWASP_Passw3rd_Project/Releases/password-0.0.5&amp;diff=118576"/>
				<updated>2011-10-04T20:15:05Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template: &amp;lt;includeonly&amp;gt;{{{1}}}&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;Release About&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
| project_name = OWASP Passw3rd Project&lt;br /&gt;
| project_home_page = OWASP Passw3rd Project&lt;br /&gt;
&lt;br /&gt;
| release_name = password-0.0.9&lt;br /&gt;
| release_date = October 2011&lt;br /&gt;
| release_description = Working versions of the java and ruby libraries and clients.&lt;br /&gt;
| release_license = MIT&lt;br /&gt;
&lt;br /&gt;
| release_download_link =http://rubygems.org/gems/passw3rd&lt;br /&gt;
 &lt;br /&gt;
| leader_name1 = Neil Matatall&lt;br /&gt;
| leader_email1 = neil@owasp.org&lt;br /&gt;
| leader_username1 = nmatatal&lt;br /&gt;
&lt;br /&gt;
| contributor_name[1-10] = &lt;br /&gt;
| contributor_email[1-10] = &lt;br /&gt;
| contributor_username[1-10] =  &lt;br /&gt;
&lt;br /&gt;
| release_notes =&lt;br /&gt;
&lt;br /&gt;
| links_url1=https://github.com/oreoshake/passw3rd&lt;br /&gt;
| links_name1 = Github Repository&lt;br /&gt;
&lt;br /&gt;
| links_url[1-10] =&lt;br /&gt;
| links_name[1-10] =&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=117220</id>
		<title>Orange County</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Orange_County&amp;diff=117220"/>
				<updated>2011-09-12T18:52:54Z</updated>
		
		<summary type="html">&lt;p&gt;Nmatatal: /* Orange County OWASP Board Members */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chapter Template|chaptername=Orange County|extra=Lead by the co-presidents [mailto:neil@owasp.org Neil Matatall], [mailto:roblav@owasp.org Rob LaViolette] and [mailto:shong.chong@owasp.org Shong Chong]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;paypal&amp;gt;Orange County&amp;lt;/paypal&amp;gt;&lt;br /&gt;
|mailinglistsite=http://lists.owasp.org/mailman/listinfo/owasp-Orange_County|emailarchives=http://lists.owasp.org/pipermail/owasp-Orange_County}}&lt;br /&gt;
The chapter leaders are [mailto:neil@owasp.org Neil Matatall], Rob LaViolette, and Shong Chong.&lt;br /&gt;
&lt;br /&gt;
Follow OWASP OC on Twitter: https://twitter.com/OWASPOC for the latest news (so I don't spam your inboxes)&lt;br /&gt;
&lt;br /&gt;
== Sponsor ==&lt;br /&gt;
&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
&lt;br /&gt;
== Local News ==&lt;br /&gt;
&lt;br /&gt;
===Future Meetings ===&lt;br /&gt;
&lt;br /&gt;
==== September 14th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
When: Wednesday September 17th 7pm&lt;br /&gt;
Where: TBD (Irvine)&lt;br /&gt;
http://www.meetup.com/ocrails/events/30043551/&lt;br /&gt;
&lt;br /&gt;
Loose Schedule:&lt;br /&gt;
7:00 - 7:30: Introduction and networking&lt;br /&gt;
7:30 - 8:00: Brakeman with Justin Collins&lt;br /&gt;
8:00 - 8:15: Lightning Rounds&lt;br /&gt;
8:15 - 8:30: Brakeman Demo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Brakeman with Justin Collins: &lt;br /&gt;
While the popular Ruby on Rails web framework provides built-in protection &lt;br /&gt;
for many security vulnerabilities, it is still possible to misuse these&lt;br /&gt;
features or introduce other vulnerabilities to an application. Brakeman is a static code analysis tool designed specifically to find vulnerabilities and configuration issues  in Ruby on Rails applications. Since it works at the source code level, Brakeman can be used at any point in development without the need for deploying the full application stack. To make it even simpler, &lt;br /&gt;
Brakeman can be integrated with Hudson/Jenkins to provide automatic monitoring of Brakeman results as code is committed. This talk will discuss how to use Brakeman and how it can help you create safer Rails applications.&lt;br /&gt;
&lt;br /&gt;
Lightning Rounds:&lt;br /&gt;
&lt;br /&gt;
Neil Matatall: Friendly_id + ancsetry&lt;br /&gt;
&lt;br /&gt;
Drew Deponte: Guard, spork, BDD&lt;br /&gt;
&lt;br /&gt;
You: ???&lt;br /&gt;
&lt;br /&gt;
===Previous Meetings===&lt;br /&gt;
&lt;br /&gt;
==== June 29th 2011 7PM ====&lt;br /&gt;
&lt;br /&gt;
[[http://owaspoc.eventbrite.com/ Registration Link]]&lt;br /&gt;
&lt;br /&gt;
'''When''': Wednesday june 29th, 2011 7pm&lt;br /&gt;
&lt;br /&gt;
'''Where:  HireRight Offices'''&lt;br /&gt;
5151 California Avenue&lt;br /&gt;
Irvine, CA 92617&lt;br /&gt;
&lt;br /&gt;
'''Pizza and refreshments will be provided by the sponsors of this meeting.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
===== Meeting Sponsors =====&lt;br /&gt;
 &lt;br /&gt;
Food and refreshments:&lt;br /&gt;
[[File:AppSecDC2010-Sponsor-trustwave.gif]]&lt;br /&gt;
&lt;br /&gt;
Meeting location:&lt;br /&gt;
[[File:Hireright.png]]&lt;br /&gt;
 &lt;br /&gt;
===== Presentation Topic: =====&lt;br /&gt;
Featuring analysis of more than 220 data breach investigations and more than 2,300 penetration tests conducted by Trustwave's SpiderLabs, the Global Security Report 2011 identifies the top vulnerabilities business encountered in 2010 as well as a list of strategic initiatives to help your business improve its overall security.&lt;br /&gt;
 &lt;br /&gt;
The data gathered from these engagements is substantial and comprehensive. This presentation will be a summary of the results of the analysis of the data gathered during 2010. The results will be presented both technical and business impact analysis.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
===== Charles Henderson, Director of Application Security Services of SpiderLabs at Trustwave =====&lt;br /&gt;
 &lt;br /&gt;
Henderson began his career in computer security in 1993, specializing in penetration testing as well as security and vulnerability research. As Director of Application Security Services at SpiderLabs, he leads the team responsible for Application Penetration Testing, Code Review, Secure Development Training, and other elite application security consulting services.&lt;br /&gt;
 &lt;br /&gt;
Prior to joining SpiderLabs, Henderson ran his own boutique application&lt;br /&gt;
security testing firm. Henderson’s firm provided offensive security services to a wide variety of clients in the United States and Europe.&lt;br /&gt;
 &lt;br /&gt;
Henderson speaks frequently at major industry events and conferences, including BlackHat, DEF CON,  AppSec US, AppSec EU, SOURCE, and the International Association of Financial Crime Investigators convention.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====January 28th, 2011====&lt;br /&gt;
&lt;br /&gt;
'''Registration link: [https://www.regonline.com/owasp_oc_jan]'''&lt;br /&gt;
&lt;br /&gt;
'''Time:''' 1 PM - 5PM&lt;br /&gt;
&lt;br /&gt;
'''Location: '''&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;source=s_q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=5151+California+Ave&amp;amp;sll=33.621597,-117.740797&amp;amp;sspn=0.010489,0.019011&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=5151+California+Ave,+Irvine,+Orange,+California+92617&amp;amp;z=16&amp;amp;iwloc=A Hireright] &lt;br /&gt;
&lt;br /&gt;
5151 California Ave&lt;br /&gt;
&lt;br /&gt;
Irvine, California 92617&lt;br /&gt;
&lt;br /&gt;
United States.   &lt;br /&gt;
&lt;br /&gt;
'''Topics:''' Threat Modeling, Application Security&lt;br /&gt;
&lt;br /&gt;
'''Food:''' Provided&lt;br /&gt;
&lt;br /&gt;
Speakers:  &lt;br /&gt;
&lt;br /&gt;
'''Samy Kamkar'''&lt;br /&gt;
&lt;br /&gt;
Online Privacy and the Evercookie&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Samy Kamkar has lectured on computer security issues in over a dozen&lt;br /&gt;
countries, and his work has been featured on the front page of the New&lt;br /&gt;
York Times. As a grey-hat hacker, he makes and breaks computer&lt;br /&gt;
security for tech companies. In addition to his independent security&lt;br /&gt;
research, he co-founded Fonality, an IP PBX company.&lt;br /&gt;
&lt;br /&gt;
'''Jim Manico'''&lt;br /&gt;
&lt;br /&gt;
Back to Basics: Defensive Coding Principles for Web Development 101&lt;br /&gt;
&lt;br /&gt;
The application security community is in deep need of prescriptive&lt;br /&gt;
solutions for developers. This talk will review the world of Web&lt;br /&gt;
Application Security from a &amp;quot;builder&amp;quot; point of view, focusing on&lt;br /&gt;
critical controls that all developers must master if they wish to build&lt;br /&gt;
low risk web applications today.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Jim Manico is the chair of the OWASP Connections committee where he&lt;br /&gt;
focuses on producing and hosting the OWASP Podcast. Jim also is a&lt;br /&gt;
co-manager of the OWASP ESAPI Open Source project. Professionally, Jim&lt;br /&gt;
is an independent application security architect specializing in the&lt;br /&gt;
construction of low-risk web applications. Jim is also an application&lt;br /&gt;
security educator and assessment specialist.&lt;br /&gt;
&lt;br /&gt;
'''Edward Bonver'''&lt;br /&gt;
Talk Title:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling at Symantec&lt;br /&gt;
[[File:OWASP-WWW-2011-Edward-Bonver-Threat-Modelint-at-Symantec.pptx]]&lt;br /&gt;
&lt;br /&gt;
Abstract:&lt;br /&gt;
&lt;br /&gt;
Threat Modeling is one of the most important security activities that a development/QA team needs to perform as part of a Security Development Lifecycle. This activity allows the team to build a complete security profile of the system being built. Threat Modeling is not always easy to get going for a team that has little or no security experience. In this presentation we’ll take a look at why Threat Modeling is so important; we’ll explore the process behind it, and how the process is being implemented and followed across Symantec.&lt;br /&gt;
&lt;br /&gt;
Bio:&lt;br /&gt;
&lt;br /&gt;
Edward Bonver is a principal software engineer on the product security team under the Office of the CTO at Symantec Corporation.  In this capacity, Edward is responsible for working with software developers and quality assurance (QA) professionals across Symantec to continuously enhance the company’s software security practices through the adoption of methodologies, procedures and tools for secure coding and security testing.  Within Symantec, Edward teaches secure coding and security testing classes for Symantec engineers, and also leads the company’s QA Security Task Force, which he founded.  Prior to joining Symantec, Edward held software engineering and QA roles at Digital Equipment Corporation, Nbase and Zuma Networks. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edward is a Certified Information Systems Security Professional (CISSP) and a Certified Secure Software Lifecycle Professional (CSSLP).  He holds a master’s degree in computer science from California State University, Northridge, and a bachelor’s degree in computer science from Rochester Institute of Technology. Edward is a Ph.D. student at NOVA Southeastern University.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, January 21st 2010====&lt;br /&gt;
&lt;br /&gt;
Time: 7:30&lt;br /&gt;
Location: We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus. The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020. Parking is $7 but feel free to park off campus and walk to the building. http://www.oit.uci.edu/computing/labs/training.html Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdfBD&lt;br /&gt;
&lt;br /&gt;
For those who would like to avoid paying for parking, you can park in the University Center and take the campus shuttle: http://www.shuttle.uci.edu/maincampus/index.php&lt;br /&gt;
&lt;br /&gt;
The shuttle runs until 10:45PM.  The shuttle costs $1 per ride, but fees are rarely collected ;)&lt;br /&gt;
&lt;br /&gt;
Title: Do VLANs allow for good application security? &lt;br /&gt;
 &lt;br /&gt;
Virtual Local Area Networks (VLANs) are not a new concept, and can help&lt;br /&gt;
any organization better control network access.  I will present some of&lt;br /&gt;
the previous issues identified, what was the root cause, and how these&lt;br /&gt;
have been fixed in current technology.  In addition we will talk about&lt;br /&gt;
how this can help to enhance security in your environment, and what&lt;br /&gt;
controls must be in place in order to implement such an environment.  We&lt;br /&gt;
will also touch on how this can complicate your application environment,&lt;br /&gt;
but improve overall security.&lt;br /&gt;
&lt;br /&gt;
I will touch on the controls that need to be reviewed and audited when&lt;br /&gt;
working with VMware, VLANs, and web applications, to ensure that these&lt;br /&gt;
networks are secure, and what to look for to potentially pass audit&lt;br /&gt;
criteria.  I will also talk about where and how these controls have been&lt;br /&gt;
implemented in order to protect thousands of users while accessing one&lt;br /&gt;
of the most hostile networks in the world.&lt;br /&gt;
&lt;br /&gt;
David M. N. Bryan &lt;br /&gt;
Senior Security Consultant &lt;br /&gt;
&lt;br /&gt;
David has over 9+ years of computer security experience including,&lt;br /&gt;
consulting, engineering and administration.  He has performed security&lt;br /&gt;
assessment projects for health care, nuclear, manufacturing,&lt;br /&gt;
pharmaceutical, banking and educational sectors.   As an active&lt;br /&gt;
participant in the information security community, he volunteers at&lt;br /&gt;
DEFCON where he designs and implements the Firewall and Network for what&lt;br /&gt;
is said to be the most hostile network environment in the world.  &lt;br /&gt;
&lt;br /&gt;
He is also an active participant in the local Minneapolis security&lt;br /&gt;
groups both as a board member of OWASP MSP and DC612.  His roots and&lt;br /&gt;
experience come from working for a large enterprise banks, designing and&lt;br /&gt;
managing enterprise security systems.  In the more recent years he has&lt;br /&gt;
been working as an Information Security Consultant to review the&lt;br /&gt;
security and architecture of information computing environments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday December 17th 2009====&lt;br /&gt;
&lt;br /&gt;
7:30 PM, UC Irvine Campus, Room AIRB 1020&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be meeting in the Anteater Instruction and Research Building on the UC Irvine campus.  The building itself is inside of the Anteater Parking Structure at the corner of E. Peltason Dr and Anteater Dr and is room number 1020.  Parking is $7 but feel free to park off campus and walk to the building.&lt;br /&gt;
http://www.oit.uci.edu/computing/labs/training.html&lt;br /&gt;
Buliding #653 in quadrant H9 on the campus map - http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf&lt;br /&gt;
&lt;br /&gt;
'''Abstract'''&lt;br /&gt;
&lt;br /&gt;
'''Title: Pulling the Plug: Security Risks in the Next Generation of Offline Web Applications'''&lt;br /&gt;
&lt;br /&gt;
As the line between desktop and web applications becomes increasingly blurry in a web 2.0 world, browser functionality is being pushed well beyond what it was originally intended for. Persistent client side storage has become a requirement for web applications if they are to be available both online and off. This need is being filled by a variety of technologies such as [http://webkit.org/blog/126/webkit-does-html5-client-side-database-storage Gears (formerly Google Gears) and the Database Storage]   functionality included in the emerging [http://dev.w3.org/html5/spec/Overview.html HTML 5 specification]. While all such technologies offer great promise, it is clear that the vast majority of developers simply do not understand their security implications.&lt;br /&gt;
&lt;br /&gt;
Researching a variety of currently deployed implementations of these technologies has revealed a broad scope of vulnerabilities with frightening implications. Now attackers can target victims not just once, but every time they visit a site as the victim now carries and stores the attack with them. Imagine a scenario whereby updated confidential information is forwarded to an attacker every time a victim interacts with a given we application. The attacker no longer needs to worry about timing their attacks to ensure that the victim is authenticated as the victim attacks himself! Limited storage? Cookies that expire? Not a problem when entire databases are accessible with virtually unlimited storage and an infinite lifespan. Think these attacks are theoretical? Think again. In this talk we dive into these technologies and break down the risk posed by them when not properly understood. We will then detail a variety of real-world vulnerabilities that have been uncovered, including a new class of cross-site scripting and client-side SQL injection.&lt;br /&gt;
&lt;br /&gt;
'''Bio'''&lt;br /&gt;
&lt;br /&gt;
'''Michael Sutton'''&lt;br /&gt;
'''Vice President, Security Research – Zscaler'''&lt;br /&gt;
&lt;br /&gt;
Michael Sutton has spent more than a decade in the security industry conducting leading-edge research, building teams of world-class researchers and educating others on a variety of security topics. As VP of Security Research, Michael heads Zscaler Labs, the research and development arm of the company. Zscaler Labs is responsible for researching emerging topics in web security and developing innovative security controls, which leverage the Zscaler in-the-cloud model. The team is comprised of researchers with a wealth of experience in the security industry.    &lt;br /&gt;
&lt;br /&gt;
Prior to joining Zscaler, Michael was the Security Evangelist for SPI Dynamics where, as an industry expert, he was responsible for researching, publishing and presenting on various security issues. In 2007, SPI Dynamics was acquired by Hewlett-Packard. Previously, Michael was a Research Director at iDefense where he led iDefense Labs, a team responsible for discovering and researching security vulnerabilities in a variety of technologies. iDefense was acquired by VeriSign in 2005. Michael is a frequent speaker at major information security conferences; he is regularly quoted by the media on various information security topics, has authored numerous articles and is the co-author of Fuzzing: Brute Force Vulnerability Discovery, an Addison-Wesley publication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Thursday, November 19th 2009====&lt;br /&gt;
&lt;br /&gt;
When: November 19th 2009, 7:30PM&lt;br /&gt;
Where: Gina's Pizza, Irvine&lt;br /&gt;
Topics: Facebook privacy, web application firewalls, penetration testing, the reluctance for hackers to execute attacks, and random new technology.  Announced OWASP OC/LAs intention to submit a proposal for AppSec 2010.&lt;br /&gt;
&lt;br /&gt;
====Wednesday, October 14th 2009====&lt;br /&gt;
&lt;br /&gt;
Separate meetings will be held for OWASP OC and OWASP@UCI (student group).&lt;br /&gt;
&lt;br /&gt;
When:  Wednesday 10/14  7:30PM&lt;br /&gt;
Where:  Steelhead Brewery&lt;br /&gt;
Topics:  News, Ideas, Chit-chat&lt;br /&gt;
&lt;br /&gt;
This is a restaurant/bar with plenty of seating, but room for a projector is out of the question so this would be an informal round table discussion.&lt;br /&gt;
&lt;br /&gt;
I have a presentation I'm working on regarding WAFs and Vulnerability Assessment Tools.  If it pleases the group, I'd love to go over the presentation and discuss everyone's experiences.  Also, it's a great way to get feedback :)&lt;br /&gt;
&lt;br /&gt;
Neil&lt;br /&gt;
&lt;br /&gt;
I'm open to suggestions of any kind: location, time, topics, etc&lt;br /&gt;
&lt;br /&gt;
====Thursday, September 17th, 2009 7:30PM ====&lt;br /&gt;
'''Location:''' UC Irvine &lt;br /&gt;
Building: Calit2 building,building number 325 in quadrant H8 on the [http://today.uci.edu/pdf/UCI_09_map_campus_core.pdf UC Irvine Map]&lt;br /&gt;
Room: 3008&lt;br /&gt;
&lt;br /&gt;
Parking will be $7.&lt;br /&gt;
Please park in the [http://maps.google.com/maps?li=d&amp;amp;hl=en&amp;amp;f=d&amp;amp;iwstate1=dir:to&amp;amp;daddr=Parking+Structure+for+CalIT2%4033.643082,+-117.837593&amp;amp;geocode=CSJ9b4xJxrzxFUpaAQId5_D5-A&amp;amp;iwloc=1&amp;amp;dq=calit2,+uc+irvine,+ca&amp;amp;cid=33643082,-117837593,16505793731713499531&amp;amp;ei=v3bvSabfO6LejAOR2pjgAQ Anteater Parking Structure]&lt;br /&gt;
&lt;br /&gt;
I can only unofficially say that if you park in the nearby shopping centers and walk, you may be able to park for free.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;The Rise of Threat Analysis and the Fall of Compliance, Policies, and Standards in mitigating Web Application Security Risks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Apr 30, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Our fourth OC OWASP meeting will be an informal, roundtable discussion of current application security issues. Feel free to bring some ideas, code, slides, etc to contribute to the discussion. Hope to see everyone there!&lt;br /&gt;
&lt;br /&gt;
====Feb 19, 2009 6:30PM-8:30PM====&lt;br /&gt;
Brooklyn Pizza Works, 1235 East Imperial Highway, Placentia, CA&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?q=1235+East+Imperial+Highway,+placentia,+ca&amp;amp;oe=utf-8&amp;amp;client=firefox-a&amp;amp;ie=UTF8&amp;amp;split=0&amp;amp;gl=us&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come talk application security at the third OWASP OC meeting. We'll discuss current application security topics and chapter issues over pizza. We have a room booked for 15-20 people so we'll be able to rant without disturbing the patrons :) See you there! [https://www.owasp.org/images/5/58/Cloud_Computing_Security.pdf Presentation Slides]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dec 17, 2008 6PM - 9PM====&lt;br /&gt;
Microsoft Campus&lt;br /&gt;
Room MPR1, 3 Park Plaza, Suite 1600, Irvine, CA, 92614&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=microsoft,+Irvine,+CA,+92614&amp;amp;sll=33.678479,-117.838368&amp;amp;sspn=0.009892,0.022745&amp;amp;g=3+Park+Plaza,+Irvine,+CA,+92614&amp;amp;ie=UTF8&amp;amp;ei=sCFJSfKPEo3UNc2ZmCc&amp;amp;cd=1&amp;amp;cid=33728042,-117783305,17507068988286890825&amp;amp;li=lmd&amp;amp;ll=33.731835,-117.78142&amp;amp;spn=0.039545,0.090981&amp;amp;z=14&amp;amp;iwloc=A Google Map]&lt;br /&gt;
&lt;br /&gt;
This meeting will be a roundtable discussion of application security news, plus a few OWASP-themed challenges with prizes. Pizza will be provided and we'll head to the Yard House after the meeting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Aug 27, 2008, 7 PM - 9 PM====&lt;br /&gt;
Penny Saver&lt;br /&gt;
&lt;br /&gt;
603 Valencia, Brea, CA 92822&lt;br /&gt;
&lt;br /&gt;
[http://maps.google.com/maps?f=q&amp;amp;hl=en&amp;amp;geocode=&amp;amp;q=603+valencia,+Brea,+CA+92822&amp;amp;sll=33.911348,-117.851629&amp;amp;sspn=0.009865,0.022745&amp;amp;ie=UTF8&amp;amp;ll=33.909478,-117.852917&amp;amp;spn=0.009866,0.022745&amp;amp;z=16&amp;amp;iwloc=addr Google Map]&lt;br /&gt;
&lt;br /&gt;
Come meet up with web security professionals, have some pizza, and offer your thoughts for the direction of the OC chapter at our inaugural meeting! We are looking for speakers and venue sponsors for the next meeting. If you are interested, please contact the chapter leaders. Everyone is welcome to join us at our chapter meetings.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Chapter]]&lt;br /&gt;
&lt;br /&gt;
= Orange County OWASP Board Members =&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; [mailto:neil@owasp.org Neil Matatall]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Shong Chong&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Co-President&amp;lt;/b&amp;gt; Rob LaViolette&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Treasurer:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Recording Secretary:&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member&amp;lt;/b&amp;gt; [mailto: TBD]&lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD] &lt;br /&gt;
*&amp;lt;b&amp;gt;Orange County Board Member:&amp;lt;/b&amp;gt; [mailto: TBD]  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:California]]&lt;/div&gt;</summary>
		<author><name>Nmatatal</name></author>	</entry>

	</feed>