We are trying to implement Content security policy in our web application. Our application stack is MERN.Using helmet package we are trying to implement Content security policy in node js .
Currently We have enabled reportOnly mode in production for testing purpose and facing this error only in our production not in development or staging environments. Effective-attribute is script-src-elem and user agent is Window 10 chrome user-agent. We are confused how to proceed with this error as it impacting on our own script and some other valid sources randomly.We are confused whether to enforce CSP in production or not?
I'm facing a issue. script-src-elem is blocked although defined in script-src. I am using node js . Using helmet package,we have configured csp.my csp list for reference is -
app.use(
helmet.contentSecurityPolicy({
reportOnly: true,
setAllHeaders: false,
directives: {
defaultSrc: ['*', 'data:', 'ws:'],
imgSrc: [
'*.sample.com',
'https:',
'blob:',
'data:' ],
styleSrc: [
"'self'",
"'unsafe-inline'",
'assets.sample.com',
'https://fonts.googleapis.com',
'https://accounts.google.com',
'data:',
'blob:',
],
scriptSrc: [
"'self'",
"'unsafe-inline'",
"'unsafe-eval'",
'data:',
'blob:',
'https://*.sample.com',
'https://*.google-analytics.com',
'https://*.facebook.net',
'https://*.google.com',
],
],
frameAncestors: ["'self'"],
workerSrc: ["'self'", 'blob:'],
objectSrc: ["'none'"],
reportUri: '/violation',
},
}),
);
I'm facing csp violation under script-src-elem for url https://assets.sample.com/build/resultpage.9cff494c01ced7b4.chunk.js , https://connect.facebook.net. I am not aware what mistake has been commited in the configuration. Can somenone help us out!!! Thanks in advance.