content-security-policy

What are the risks associated with using inline styles?

筅森魡賤 提交于 2019-12-04 05:39:15
A Content Security Policy with a default-src or style-src directive will prevent inline styles from being applied to <style> elements or style attributes. To allow the use of inline styles, a value of unsafe-inline must be applied to a CSP fetch directive. This seems to indicate that inline styles are unsafe. While inline Javascript is an obvious attack vector for XSS attacks (CSP is pretty much useless with script-src 'unsafe-inline' ), Google Web Fundamentals considers inline-styles to be a relatively equivalent threat , providing one example of a clever data exfiltration method from a 2009

Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy)

本秂侑毒 提交于 2019-12-04 05:23:45
问题 I'm trying to relax Chrome's CSP while running a test using proctractor (webdriver, chromedriver). So the solution can be either a flag like "--disable-csp" which dose not exist according to my search results. a setting for webdriver/protractor to do so. I could not find any solution but to setup a proxy that filters the header. any ideas? 回答1: currently there are no native option but you can disable CSP using extension. Step: Download extension Disable Content-Security-Policy Save it as .zip

JavaScript click() method only works once in Chrome extension

五迷三道 提交于 2019-12-04 05:14:05
I'm trying to download multiple files in a Chrome extension. The following code creates a dummy link to a file, then triggers the .click() event which downloads the file. The problem is that only the first .click() event triggers a download. Subsequent .click() events are ignored. Here the manifest.json : { "name": "Simple File Downloader", "version": "0.1", "permissions": ["contextMenus", "http://*/"], "background": { "persistent": false, "scripts": ["sample.js"] }, "content_security_policy": "script-src 'self'; object-src 'self'", "manifest_version": 2 } Here the sample.js : function

Custom HTTP headers with Google Cloud CDN and Bucket backend

萝らか妹 提交于 2019-12-04 04:58:23
How can I send custom HTTP headers with a bucket backend for Cloud CDN without the x-goog-meta- prefix? In particular, I'm trying to send a Content-Security-Policy header, which turns into x-goog-meta-Content-Security-Policy and thus is ignored by the browser. Screenshot: Google Storage/ Bucket Meta data UI Screenshot: Response headers 来源: https://stackoverflow.com/questions/43853564/custom-http-headers-with-google-cloud-cdn-and-bucket-backend

What CSP child iframe inherits from its parent?

老子叫甜甜 提交于 2019-12-04 02:37:04
I have a webpage (say origin=A) that has an iframe embedded in it which loads from a different domain (say B). B loads bunch scripts from different domains (various CDNs). My webpage A sets pretty strict CSP like: default-src 'none'; script-src 'self'; frame-src B B doesn't set any CSP headers. Now I would expect the child frame, B, to inherit the CSP rules of A and trying to access various CDNs should be a violation of its CSP because of script-src 'self' but to my surprise, it works smoothly. So my question is: How CSP is inherited by child iframes ? Does it depend on its parent frame's CSP

POST request on Facebook.com in Chrome Extension fails

房东的猫 提交于 2019-12-04 02:35:20
问题 I have a Chrome Extension that sends AJAX POST with some data on every page. The problem is that, Facebook block the AJAX request resulting this: Refused to connect to 'URL_HERE' because it violates the following Content Security Policy directive: "connect-src https:// .facebook.com http:// .facebook.com https:// .fbcdn.net http:// .fbcdn.net *.facebook.net .spotilocal.com: https:// .akamaihd.net ws:// .facebook.com:* http://*.akamaihd.net". How to send AJAX call to my server on that page

Content-Security-Policy (CSP) workaround for internet explorer

左心房为你撑大大i 提交于 2019-12-04 01:28:31
问题 We are building a ASP.NET website and want to allow only some domains who can iFrame our website. CSP is not supported in internet explorer. I am setting something like Response.AddHeader("Content-Security-Policy", "frame-ancestors mydomain1.com mydomain2.com") . How is everyone handling for internet explorer. I read IE supports X-Content-Security-Policy but it doesn't has frame-ancestors . Also I am removing the default X-Frame-Options header added by IIS by doing Response.Headers.Remove("X

Javascript Template Engines that work with Chrome's Content Security Policy

社会主义新天地 提交于 2019-12-04 00:33:17
The Chrome API's Manifest version 2 has removed the ability to do unsafe-eval. This means using the eval function or in general dynamically creating a function from text. It seems like most if not all Javascript Templating Engines do this. I was using Jaml, but I tried several others like backbone.js (which really uses underscore.js's templating engine) with no luck. This comment on the Chromium project seems to indicate that there are a great many libraries that suffer from this. I think Angular.js has a CSP-safe mode, but Angular.js is really too big for what we need. We just need a fairly

Iframe in Chrome error: Failed to read 'localStorage' from 'Window': Access denied for this document

北战南征 提交于 2019-12-03 22:19:16
I have a web app which uses localStorage. Now we want to embed this web app on other (third-party) sites via iframe. We want to provide an iframe embed similar to youtube so that other websites can embed our web app in an iframe. Functionally it is the same as if it wouldn't be embedded. But it does not work. Chrome prints the error message: Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. I just do the following check (in the iframe): if (typeof window.localStorage !== 'undefined') { // SETUP SESSION, AUHT, LOCALE, SETTINGS

How to implement content security policy?

放肆的年华 提交于 2019-12-03 21:19:31
问题 There's good articles explaining the options for CSP like this one: http://www.html5rocks.com/en/tutorials/security/content-security-policy/ Perhaps it's completely obvious because I can't find any good examples but how do you actually implement CSP in practise? In PHP you can set the header on a page you serve, but what if you just have a HTML file? Do you have to do it through your webserver, apache or similar? That doesn't seem an easy approach. What's the best practise here? Every