混合内容,内容安​​全策略和哈希源

时间:2017-05-31 13:56:38

标签: content-security-policy mixed-content

我想在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'>

这会有用吗?有没有其他方法可以实现这一点。

note :没有upgrade-insecure-requests无效,因为该网页是导航请求,而且该框架必须从HTTP提供。

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

  

child-src列出了工作程序和嵌入式框架内容的URL。例如:child-src https://youtube.com将允许嵌入来自YouTube的视频,但不能嵌入其他来源的视频。代替不推荐使用的frame-src指令。

     

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

相关问题