Content security policy blocking remote CSS background image -


a background image loaded remote server being blocked csp message

content security policy: page's settings blocked loading of resource @ self ("default-src * https://xxxxx.com"). source: background-image: url('https://xxxxx....

here's csp:

<meta http-equiv="content-security-policy" content="default-src * https://xxxxx.com; script-src * 'unsafe-eval' 'unsafe-inline'; img-src 'self' data:"> 

...where xxxxx domain.

i assume doesn't url(..., csp spec doesn't seem consider url() scheme can't see this. know?

[update]

following @sideshowbarker's comment, should have pointed out call coming inline style attribute (not tag).

that csp violation message indicates have inline css style content, must either move css content separate file (and use link element reference it) or else must specify 'unsafe-inline'—for example, adding style-src directive policy:

<meta http-equiv="content-security-policy"   content="default-src * https://xxxxx.com;   script-src * 'unsafe-eval' 'unsafe-inline';   style-src 'self' 'unsafe-inline';   img-src 'self' https://xxxxx.com data:"> 

the reason is, csp violation message cited in question isn’t saying image in css style content specific problem—it’s saying have inline style content, period.

and far csp concerned, doesn’t matter inline style content is—it’s existing csp policy doesn’t allow inline style content all; existing policy allows inline scripts, because script-src directive have 'unsafe-inline' specified for.

so if you’re going keep inline style content, need use 'unsafe-inline' allow it.

update: based on comments below, seems once 'unsafe-inline' added style-src in case, it’s necessary add https://xxxxx.com img-src.


all said, though, once you’ve ended specifying 'unsafe-inline' both style content , scripts, seems might @ point need start considering whether want specify csp policy @ all—because allowing inline kind of defeats purpose of having csp policy @ begin with.

if goal reduce xss risks, seems should consider moving inline style , script content separate files, , using <script src> , link reference those…


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -