Is it possible to configure the Content-Security-Policy to not block anything at all? I'm running a computer security class, and our web hacking project is running into issues on newer versions of Chrome because without any CSP headers, it's automatically blocking certain XSS attacks.
Asked
Active
Viewed 6.8k times
4 Answers
63
For people who still want an even more permissive posts, because the other answers were just not permissive enough, and they must work with google chrome for which * is just not enough:
default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' 'unsafe-dynamic';
script-src * data: blob: 'unsafe-inline' 'unsafe-eval';
connect-src * data: blob: 'unsafe-inline';
img-src * data: blob: 'unsafe-inline';
frame-src * data: blob: ;
style-src * data: blob: 'unsafe-inline';
font-src * data: blob: 'unsafe-inline';
frame-ancestors * data: blob: 'unsafe-inline';
Rainb
- 1,520
- 8
- 28
-
1For a policy that allows inline, but not from any host, the wildcards ( * ) could be changed to "self". – Rob Breidecker Jan 15 '20 at 00:01
-
3Chrome now says it doesn't know and will ignore `'unsafe-dynamic'` – Anatol Bivol Apr 15 '21 at 14:16
-
@AnatoliiBivol interesting, I guess you can remove it to avoid warnings, if chrome is the only thing you care about – Rainb Apr 15 '21 at 18:33
-
1I also needed to add frame-ancestors https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors – Jonathan Parker Apr 18 '21 at 12:19
-
As if a directive is not found a fallback will be applied to the 'default-src' directive, why don't you consider something like that: default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' – Ahmed El-Atab Dec 22 '21 at 15:32
-
1@AhmedEl-Atab at the time of writing, chrome required defining each entry explicitly. – Rainb Dec 28 '21 at 17:56
-
New version on 2022: default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline'; frame-ancestors * data: blob:; – Kevin .NET May 02 '22 at 20:11
35
It's not secure at all, but as staring point the real allow all policy is:
default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';
See: https://content-security-policy.com/ and this CSP migration guide.
Eli Grey
- 34,148
- 13
- 72
- 93
zerologiko
- 1,825
- 1
- 18
- 21
-
Blob and data missed, example: default-src * data: blob: 'unsafe-inline' 'unsafe-eval'; – basil Jul 15 '19 at 09:06
-
2
-
12
The best way would be not applying any policy.
But to answer your question, an "allow all policy" would probably be:
default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;
Note: untested
oreoshake
- 4,309
- 1
- 30
- 38
-
Unfortunately without any policy in place, Chrome proactively adds some XSS protections of its own, so having nothing is actually worse. But thanks! – joshlf Mar 14 '16 at 20:36
7
Here's the htaccess code to allow everything in CSP
Header add Content-Security-Policy "default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' 'unsafe-dynamic'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';"
Manik Malhotra
- 514
- 5
- 9