为什么我会在block-uri为空字符串时收到CSP警告?

mik*_*ana 4 content-security-policy

我一直在我的localhost服务器上使用CSP,以及普通的CSP消息,已经看到了:

{
  "csp-report": {
    "document-uri": "https://localhost:3000/",
    "referrer": "",
    "violated-directive": "script-src 'self' 'unsafe-eval' cdn.mxpnl.com js.stripe.com platform.twitter.com syndication.twitter.com use.typekit.net",
    "effective-directive": "script-src",
    "original-policy": veryLongPOlicyGoesHere,
    "blocked-uri": "",
    "source-file": "https://platform.twitter.com",
    "line-number": 2,
    "column-number": 28911,
    "status-code": 0
  }
}
Run Code Online (Sandbox Code Playgroud)

为什么blocked-uri" ""?导致此CSP警告的原因是什么?

ore*_*ake 8

虽然解析起来可能并不容易,但您可以在我运行一段时间的CSP"指纹"项目中找到有关该类报告的信息:https://gist.github.com/oreoshake/29edbf9aae8125f05b66

blocked-uris表示内联脚本/样式冲突,eval调用或内联事件处理程序/ javascript:href.但你violated-directive允许eval.

如果您可以在Firefox浏览器中触发相同的错误,则可以检查该script-sample字段.它可能包含内联脚本的内容,或者它可能提到触发的事件处理程序,或者它将在消息中包含"eval".

这种格式的大量意外报告来自浏览器扩展,即lastpass.

  • 感谢您的最后一句话。浏览器扩展确实会引发意外的“评估”冲突。 (2认同)