content-security-policy

Add nonce attribute to auto-generated WebForms script

巧了我就是萌 提交于 2019-12-07 13:44:53
问题 While implementing the CSP header on my website, I am facing problems with the automatically generated postback JavaScript that webforms adds to the page: <script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(

Content Security Policy does not work in Internet Explorer 11

喜夏-厌秋 提交于 2019-12-07 04:11:41
问题 In my asp.net core application for each response i'm adding content security policy header. I understand that for IE, the header name is X-Content-Security-Policy and for other browsers like chrome its Content-Security-Policy The header value looks something like below where nonce is different for each response. default-src 'none'; script-src 'self' 'nonce-somerandomvalue-differnt-foreach-reasone' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; object

Injecting remote iframe with Chrome extension

巧了我就是萌 提交于 2019-12-06 23:07:00
问题 For the life of me, I cannot get my Chrome extension to display an iframe with a remote URL. I see the following message in the console - Refused to frame 'https://www.example.com/' because it violates the following Content Security Policy directive: "child-src 'self'". Note that 'frame-src' was not explicitly set, so 'child-src' is used as a fallback. I found a solution on here (Injecting iframe into page with restrictive Content Security Policy), which requires injecting a local iframe

How to let script to use setAttribute 'style' without breaking CSP

孤者浪人 提交于 2019-12-06 14:30:34
Im am trying to keep my CSP policy as strict as possible. I need to include 3d party component in my bundle. But it uses element.setAttribute('style'...) method which breaks CSP. Is there a way to allow this particular script to inline styles in that manner? 2018-10-06 update The original answer here is still correct for now — because with CSP as currently implemented in browsers at least, there’s still no way to have dynamically injected styles at all without specifying unsafe-inline , and specifying unsafe-inline basically negates the whole purpose of CSP. However , CSP3 adds a new unsafe

GWT Chrome Extension with manifest_version: 2

北城余情 提交于 2019-12-06 04:29:54
Has any one been able to make a Chrome extension using GWT and manifest_version 2? I have sandboxed all the GWT generated files also (as suggested here ) but it still does not work. manifest.json { "name": "Hello World!", "description": "My first packaged app.", "manifest_version": 2, "version": "0.1", "app": { "background": { "scripts": ["background.js"] } }, "permissions": ["experimental", "appWindow"], "icons": { "16": "calculator-16.png", "128": "calculator-128.png" } } background.js chrome.experimental.app.onLaunched.addListener(function() { chrome.appWindow.create('LocalWebApp.html', {

Firebase + Chrome content security policy settings?

笑着哭i 提交于 2019-12-06 04:14:35
问题 I'm trying to use Firebase in a Chrome extension background page, but it looks like it's executing inline-scripts, which isn't allowed because of security concerns. I've currently set the CSP to: {"content_security_policy": "script-src 'self' https://cdn.firebase.com https://<my-subdomain>.firebaseio.com; object-src 'self'"} I'm able to load the initial Firebase script, but upon calling new Firebase('my-firebase-url'), I get the following error: Refused to execute inline script because it

What are the risks associated with using inline styles?

五迷三道 提交于 2019-12-06 01:24:26
问题 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

content security policy issue with chrome extension

时光怂恿深爱的人放手 提交于 2019-12-05 22:48:57
Trying to load different contents(can be pdf, swf etc.) in an 'iframe' through javascript in an chrome extension application. The content is loaded using the data URL scheme as : // this javascript is registered in the html file and the LoadFunction is registered inside the DOMContentLoaded event on the click of a button. void LoadFunction() { window.parent.document.getElementById("page_data").src = 'data:application/pdf;base64,' + 'base64 encoded data'; (base64 data is received from a c++ class) } but as soon as above function is called, a content security policy error is raised as : Refused

Add nonce attribute to auto-generated WebForms script

僤鯓⒐⒋嵵緔 提交于 2019-12-05 21:48:58
While implementing the CSP header on my website, I am facing problems with the automatically generated postback JavaScript that webforms adds to the page: <script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script> To support some other script tags inline I have successfully added the nonce

Content Security Policy allow inline style without unsafe-inline

∥☆過路亽.° 提交于 2019-12-05 16:26:24
Using content security policy without style-src 'unsafe-inline' how do you allow styles like this? <span style="font-size: 16px;">Hello</span> I've tried adding a nonce to them and adding that nonce to the CSP header but that doesn't seem to work <span style="font-size: 16px;" nonce="0611873de7e2db5985c289fdfa946caee2ae1860">Hello</span> "style-src 'nonce-0611873de7e2db5985c289fdfa946caee2ae1860' 'self'" Is there any way to do this without adding the 'unsafe-inline' directive?? According to https://bugzilla.mozilla.org/show_bug.cgi?id=855326#c35 nonces for style attributes isn't supported a