【问题标题】:Missing Subresource Integrity Protection缺少子资源完整性保护
【发布时间】:2016-02-22 13:29:19
【问题描述】:

我在 Heroku 上搭建了一个 django 博客应用程序,目前一切正常,但我有一个关于 Missing Subresource Integrity Protection 的小问题。

我对使用 heroku 插件还很陌生,但我已经设置了 tinfoil 以确保安全,在初始扫描后我遇到了 3 个漏洞。扫描结果显示我是Missing Subresource Integrity Protection,他们向我推荐了这个:

    > All externally loaded resources must have their content pinned using
    > the subresource integrity mechanisms provided by modern browsers. This
    > involves computing a hash of the contents of the resource, and
    > specifying this hash when loading that resource. In the case of a
    > script, this might look like the following:

        <script src="https://example.com/include.js"
                    integrity="sha256-Rj/9XDU7F6pNSX8yBddiCIIS+XKDTtdq0//No0MH0AE="
                    crossorigin="anonymous"></script>

SRI Hash is an option for computing the necessary hashes.

谁能解释一下这一切意味着什么,以便我可以从中学到一些东西,以及将来该怎么做才能避免这种情况?

【问题讨论】:

    标签: python ruby-on-rails django heroku subresource-integrity


    【解决方案1】:

    Subresource integrity 是一个规范,“定义了一种机制,用户代理可以通过该机制验证获取的资源是否已在没有意外操作的情况下交付。”它基本上是您资产的校验和,如果资源与指定的完整性值不匹配,兼容的浏览器将不会加载资源。

    这很容易在 Rails 中添加,只要您的 sprockets 版本是 3.x 或更高版本。您可以按照sprockets documentation 中的示例添加检查:

    javascript_include_tag :application, integrity: true
    # => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
    

    GitHub Engineering 有一个 interesting blog post,他们在那里详细讨论了该功能。

    【讨论】:

    猜你喜欢
    • 2016-02-15
    • 1970-01-01
    • 2016-07-05
    • 2016-11-02
    • 2017-12-22
    • 2018-07-23
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多