<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>xss &#8211; Accidents Happen</title>
	<atom:link href="https://ah.thameera.com/tag/xss/feed/" rel="self" type="application/rss+xml" />
	<link>https://ah.thameera.com</link>
	<description>In the dark</description>
	<lastBuildDate>Fri, 17 Nov 2017 15:19:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">56521109</site>	<item>
		<title>Hashes and Nonces in CSP</title>
		<link>https://ah.thameera.com/hashes-and-nonces-in-csp/</link>
					<comments>https://ah.thameera.com/hashes-and-nonces-in-csp/#respond</comments>
		
		<dc:creator><![CDATA[thameera]]></dc:creator>
		<pubDate>Fri, 17 Nov 2017 15:19:26 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[csp]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[xss]]></category>
		<guid isPermaLink="false">http://ah.thameera.com/?p=632</guid>

					<description><![CDATA[Troy Hunt has a nice article about inline-scripts and CSP with some practical examples. By default the following CSP directive will block all inline scripts: Content-Security-Policy: default-src 'self' The most straight-forward way to remove the restriction is to add unsafe-inline but it disables all the defenses against inline scripts and XSS. Thankfully you have two [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Troy Hunt has <a href="https://www.troyhunt.com/locking-down-your-website-scripts-with-csp-hashes-nonces-and-report-uri">a nice article</a> about inline-scripts and CSP with some practical examples.</p>
<p>By default the following CSP directive will block all inline scripts:</p>
<p><code></p>
<blockquote><p>Content-Security-Policy: default-src 'self'</p></blockquote>
<p></code></p>
<p>The most straight-forward way to remove the restriction is to add <code>unsafe-inline</code> but it disables all the defenses against inline scripts and XSS. Thankfully you have two alternatives: using a hash or a nonce. (TIL!)</p>
<p>If the script is static (the content does not change), you can add a SHA-256 hash of the script to the CSP directive, so the script will be whitelisted.</p>
<p><code></p>
<blockquote><p>Content-Security-Policy: default-src 'self'; script-src 'sha256-blLDIhKaPEZDhc4WD45BC7pZxW4WBRp7E5Ne1wC/vdw='</p></blockquote>
<p></code></p>
<p> However, if the script is prone to change, you have the option of adding a base64-encoded nonce (random value) to both the CSP directive and the script tag.</p>
<p><code></p>
<blockquote><p>Content-Security-Policy: default-src 'self'; script-src 'nonce-4AEemGb0xJptoIGFP3Nd'<br />
&lt;script type="text/javascript" nonce="4AEemGb0xJptoIGFP3Nd"&gt;
</p></blockquote>
<p></code></p>
]]></content:encoded>
					
					<wfw:commentRss>https://ah.thameera.com/hashes-and-nonces-in-csp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">632</post-id>	</item>
	</channel>
</rss>
