TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Content Security Policy

43 pointsby xPawabout 12 years ago

6 comments

dmethvinabout 12 years ago
Its great to see a large site like GitHub start work on deploying CSP. I don't know how many times I've had to argue with people about bad practices like inline event handlers. With CSP there's a way for a site to prevent them from being used.
pfrazeabout 12 years ago
You can also specify a CSP using a document's meta tags:<p><pre><code> &#60;meta http-equiv="Content-Security-Policy" content="default-src *; script-src https://assets.example.com; style-src https://assets.example.com"&#62;&#60;/meta&#62; </code></pre> I'm not sure if that introduces any additional attack vectors (other than somebody modifying the document in an unencrypted connection) but it's useful for when hosting statically.<p>EDIT: updated to mimic example in post
评论 #5577252 未加载
mh-about 12 years ago
This entire post is like a "why CSP is broken in the real world", yet they're going ahead with deploying it?
评论 #5577550 未加载
评论 #5577042 未加载
rachelbythebayabout 12 years ago
CSP is great stuff. I'm using it to view RSS/Atom posts without having to go through the usual hoop-jumping to sanitize content. Why sanitize content when it's unable to do anything evil in the context of a page?<p>I would recommend using some kind of test in your scripting to see if it's actually working. I purposely attempt to inject a &#60;script&#62; tag to fiddle with a variable. If it works, I know CSP isn't functional in the browser and avoid the dangerous stuff (rendering user-generated content). Otherwise, it's full speed ahead, detailed here: <a href="http://rachelbythebay.com/w/2011/10/31/csp/" rel="nofollow">http://rachelbythebay.com/w/2011/10/31/csp/</a>
byrootabout 12 years ago
This change broke our chrome extension a few weeks ago. We were able to workaround it using a trick inspired by this blog post: <a href="http://brianmayer.com/2012/12/defeating-chromes-content-security-policy-header-via-a-chrome-extension/" rel="nofollow">http://brianmayer.com/2012/12/defeating-chromes-content-secu...</a><p>Hope it help someone.
评论 #5580987 未加载
lone-starabout 12 years ago
Here is an easy way to bypass it when you have a Chrome extension: <a href="https://www.planbox.com/blog/development/coding/bypassing-githubs-content-security-policy-chrome-extension.html" rel="nofollow">https://www.planbox.com/blog/development/coding/bypassing-gi...</a>