Desktop Chrome is less strict about CSP than mobile
Reported by
lmannin...@gmail.com,
Nov 7 2017
|
|||||
Issue description
I recently delved into the wonderful world of securing websites. I'm using letsencrypt to generate my certificates and also adding some headers in my nginx config. The issue I've noticed has to do with inline SVGs, or more specifically, images defined in CSS with a "data" scheme.
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink…%23f7f7f7' /><rect y='40' width='50' height='10' fill='%23f7f7f7' /></svg>");
With no CSP set, this loads completely fine. When I have CSP set to the following, it loads fine in desktop Chrome but fails to load in mobile Chrome and mobile Firefox:
add_header Content-Security-Policy "default-src https:";
I have to switch my policy to the following for it to work universally:
add_header Content-Security-Policy "default-src https: 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:";
So I am wondering if there is a reason for the discrepancy between desktop browsers and mobile browsers when dealing with CSP? I would expect that the policy would be adhered to on all browsers, not ignored or only loosely adhered to by some.
,
Nov 10 2017
,
Nov 10 2017
,
Jan 22 2018
Apologies for the slow response: Are you, per chance, on iOS? If so, that would explain the distinction: Chrome on iOS's support for CSP is limited by our use of WebKit on that platform. Firefox's behavior would be equally affected.
,
Jan 22 2018
I was having this issue on Android.
,
Jan 22 2018
Interesting. `default-src https:` should block `data:` on both desktop and mobile, while `default-src https:; img-src 'self' data:` should allow on both. Indeed, we don't distinguish between platforms in Blink; it's all the same code. Is there a page we could poke at? A quick demo at https://output.jsbin.com/foxufem shows the same behavior on both Linux desktop (63.0.3239.132) and Android (65.0.3325.0).
,
Feb 18 2018
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by dtapu...@chromium.org
, Nov 8 2017