Content Security Policy failing on line 1 (Firefox 57.0)

我怕爱的太早我们不能终老 提交于 2019-12-11 03:27:01

问题


I am using the following Content Security Policy in Report-Only mode:

Content-Security-Policy-Report-Only "default-src 'self'; report-uri /log_violations"

When I go to a URL on the server with an HTML page containing the following:

<!DOCTYPE html>
<head>
  <title>
    Test document
  </title>
</head>
<html>
  <body>
    Hello
  </body>
</html>

I am seeing the following error message in Firefox 57.0 on line 1:

Content Security Policy: The page’s settings observed the loading of a 
resource at self (“default-src http://www3.thestar.com”). A CSP report
is being sent. Source: ;!function(){var t=0,e=function(t,e){ret...

In other browsers, like Edge, Chrome, I haven't seen these errors.

Any thoughts on whether this is a Firefox quirk or something I've set up incorrectly? I'm stumped as to why the policy is rejecting line 1 of every page.


回答1:


You probably have an extension installed and enabled that is injecting content into the page. Try opening the page in a new Firefox profile without any extensions to see if you see the CSP violation reported.

Firefox is planning to exclude content injected by extensions in CSP checks starting Firefox 58 so this should reduce the noise from extensions doing stuff on a page.

From the Mozilla blog,

Starting with Firefox 58, the CSP of a web page does not apply to content inserted by an extension. This allows, for example, the extension to load its own resources into a page.



来源:https://stackoverflow.com/questions/47519661/content-security-policy-failing-on-line-1-firefox-57-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!