content-security-policy

CSP error in a node.js application

江枫思渺然 提交于 2020-06-17 11:34:13
问题 I've a node.js application with a home page in angularjs. This page contains a 'search' box and has corresponding search.js script which runs and makes a server side query call. For security I added 'csp' in my node.js application with following csp configuration. const csp = require('helmet-csp'); app.use(helmet()); app.use(csp({ directives: { defaultSrc: ["'self'", 'https://my.domain.com'], scriptSrc: ["'self'", "'unsafe-inline'"], styleSrc: ["'self'"], imgSrc: ["'self'"], connectSrc: ["

CSP error in a node.js application

匆匆过客 提交于 2020-06-17 11:33:41
问题 I've a node.js application with a home page in angularjs. This page contains a 'search' box and has corresponding search.js script which runs and makes a server side query call. For security I added 'csp' in my node.js application with following csp configuration. const csp = require('helmet-csp'); app.use(helmet()); app.use(csp({ directives: { defaultSrc: ["'self'", 'https://my.domain.com'], scriptSrc: ["'self'", "'unsafe-inline'"], styleSrc: ["'self'"], imgSrc: ["'self'"], connectSrc: ["

Asp net core Content Security Policy implementation

本小妞迷上赌 提交于 2020-06-16 05:11:28
问题 I have implemented code to manage the Content Security Policy layer in my application. My implementation is based on an ActionFilterAttribute which was inspired from the code available here (I am including in the question for the sake of simplicity). public override void OnResultExecuting( ResultExecutingContext context ) { var result = context.Result; if ( result is ViewResult ) { if ( !context.HttpContext.Response.Headers.ContainsKey( "X-Content-Type-Options" ) ) { context.HttpContext

Content Security Policy “Refused to execute inline event handler” error

怎甘沉沦 提交于 2020-05-30 09:03:31
问题 I'm trying to mitigate XSS attacks by setting the Content-Security-Policy header but Chrome keeps throwing an error: Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-Njg3MGUxNzkyMjViNDZkN2I3YTM3MDAzY2M0MjUxZGEzZmFhNDU0OGZjNDExMWU5OTVmMmMwMTg4NTA3ZmY4OQ=='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. I tried setting the nonce in

Content Security Policy “Refused to execute inline event handler” error

天涯浪子 提交于 2020-05-30 09:02:30
问题 I'm trying to mitigate XSS attacks by setting the Content-Security-Policy header but Chrome keeps throwing an error: Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-Njg3MGUxNzkyMjViNDZkN2I3YTM3MDAzY2M0MjUxZGEzZmFhNDU0OGZjNDExMWU5OTVmMmMwMTg4NTA3ZmY4OQ=='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. I tried setting the nonce in

Content Security Policy “Refused to execute inline event handler” error

独自空忆成欢 提交于 2020-05-30 09:02:24
问题 I'm trying to mitigate XSS attacks by setting the Content-Security-Policy header but Chrome keeps throwing an error: Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-Njg3MGUxNzkyMjViNDZkN2I3YTM3MDAzY2M0MjUxZGEzZmFhNDU0OGZjNDExMWU5OTVmMmMwMTg4NTA3ZmY4OQ=='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. I tried setting the nonce in

Content Security Policy “Refused to execute inline event handler” error

本秂侑毒 提交于 2020-05-30 09:02:13
问题 I'm trying to mitigate XSS attacks by setting the Content-Security-Policy header but Chrome keeps throwing an error: Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-Njg3MGUxNzkyMjViNDZkN2I3YTM3MDAzY2M0MjUxZGEzZmFhNDU0OGZjNDExMWU5OTVmMmMwMTg4NTA3ZmY4OQ=='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. I tried setting the nonce in

Can CSP restrict the connections of dynamically loaded script?

半城伤御伤魂 提交于 2020-05-29 08:07:30
问题 My site is loading a third party library that loads all kinds of scripts to scrape the data from my site and send it to its own servers via XHR for analysis. I want to make a restriction such that my page can only talk to my servers and the one third party server, and no other connections would be made. Im wondering if CSP connect-src would do that? For example lets say my site is x.com and the third party is y.com If y.com loads a script that sends data to y.com it is okay but not if it

Does a *.example.com for a content security policy header also match example.com?

末鹿安然 提交于 2020-05-09 01:23:28
问题 Say I have this header set on mywebsite.com : Content-Security-Policy: script-src self https://*.example.com I know it will allow https://foo.example.com and https://bar.example.com , but will it allow https://example.com alone? Looking at the spec.... Hosts such as example.com (which matches any resource on the host, regardless of scheme) or *.example.com ( which matches any resource on the host or any of its subdomains (and any of its subdomains' subdomains, and so on)) ...it seems as it

Does a *.example.com for a content security policy header also match example.com?

故事扮演 提交于 2020-05-09 01:23:12
问题 Say I have this header set on mywebsite.com : Content-Security-Policy: script-src self https://*.example.com I know it will allow https://foo.example.com and https://bar.example.com , but will it allow https://example.com alone? Looking at the spec.... Hosts such as example.com (which matches any resource on the host, regardless of scheme) or *.example.com ( which matches any resource on the host or any of its subdomains (and any of its subdomains' subdomains, and so on)) ...it seems as it