【问题标题】:Content-Security-Policy-Report-Only - Empty or incorrect report dataContent-Security-Policy-Report-Only - 空的或不正确的报告数据
【发布时间】:2022-01-21 22:42:09
【问题描述】:

我对 CSP 报告数据有疑问(Content-Security-Policy-Report-Only)。

  1. 在报告中,我只获得了根域 https://******.com。但我期待完整的路径。

  2. Referrer 始终为空,但我需要获取此数据。

例如:<iframe src="https://*******.com/en/login" width="800" height="800" title="Test Frame"></iframe>

有人可以帮我解决这个问题吗?

Header: 'Content-Security-Policy-Report-Only: frame-ancestors 'self';报告-uri https://******.com/api/security-report'

{
  "csp-report": {
    "document-uri": "https://******.com/",
    "referrer": "",
    "violated-directive": "frame-ancestors",
    "effective-directive": "frame-ancestors",
    "original-policy": "frame-ancestors 'self'; report-uri https://******.com/api/security-report",
    "disposition": "report",
    "blocked-uri": "https://******.com/",
    "status-code": 200,
    "script-sample": ""
  }
}

【问题讨论】:

  • 您是将 CSP 标头放入 iframe 还是页面本身,还是两者都放入?
  • 所有主流浏览器都会出现这种情况吗?

标签: php http http-headers content-security-policy


【解决方案1】:

根据this 文章:

规范进一步指出,如果违规 URI 与 document-uri 来自同一来源,则 URI 片段可以保留。如果不是,则只应报告 URI 来源。只有 Firefox 做错了。对于 Firefox 5.0 - 41.0,它总是报告每个阻塞 uri 值的完整 URI,包括片段。报告阻塞 uri 的所有其他浏览器(一些较旧的浏览器没有)在正确的情况下正确报告了带有和不带片段的 URI。

您获得的阻塞 uri 可能会根据违规发生的来源、您使用的浏览器 - 您的 csp 版本等而有所不同。您可以更改其中任何一个以再次测试您的要求。

关于推荐人,您没有任何推荐人触发 CSP 报告,因为违规资源都不是由推荐人引起的。

【讨论】:

    猜你喜欢
    • 2018-05-04
    • 1970-01-01
    • 2013-05-03
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 1970-01-01
    • 2015-09-05
    相关资源
    最近更新 更多