【问题标题】:Mixed Content , Content-Security-Policy and hash-source混合内容、内容安全策略和散列源
【发布时间】:2017-05-31 13:56:38
【问题描述】:

我想在 HTTPS 页面中打开一个 HTTP Iframe。当然这通常是不可能的,因为它会触发“混合内容”违规。

有没有办法使用“Content-Security-Policy”和哈希源绕过混合内容块?

例子:

  • http://mysite/my-frame.html 的 sha-256 哈希值为 sha256-xxxyyy....zzz
  • https://mysite/index.html 将与以下 Content-Security-Policy 标头一起提供(或内联等效的 <meta> 标记),只要 CORS 标头:

    • Content-Security-Policy: frame-src sha256-xxxxyyyy....zzz
  • https://mysite/index.html 包括一个<iframe src='http://mysite/my-frame.html'>

这行得通吗?有没有其他方法可以做到这一点。

注意:否 upgrade-insecure-requests 将不起作用,因为该页面是一个导航请求并且框架必须从 HTTP 提供。

【问题讨论】:

    标签: content-security-policy mixed-content


    【解决方案1】:

    不,没有办法绕过现代浏览器上的安全阻止(从 Firefox 23、Chrome 14、IE9 开始)

    谢天谢地,大多数现代浏览器都会阻止此类危险内容 默认情况下

    参考:https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content#mixed-content-types--security-threats-associated

    【讨论】:

      【解决方案2】:

      如果服务器将 csp child-src 设置为 http://mysite/my-frame.html 会怎样?当我阅读定义时,它应该可以工作。

      child-src 列出了 worker 和嵌入框架内容的 URL。例如:child-src https://youtube.com 将启用嵌入来自 YouTube 但不来自其他来源的视频。使用它代替已弃用的 frame-src 指令。

      https://www.html5rocks.com/en/tutorials/security/content-security-policy/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-11-08
        • 1970-01-01
        • 2021-10-13
        • 1970-01-01
        • 1970-01-01
        • 2017-09-07
        • 2021-01-11
        相关资源
        最近更新 更多