【问题标题】:what is max-age property in HSTS security header?HSTS 安全标头中的 max-age 属性是什么?
【发布时间】:2018-01-29 09:12:08
【问题描述】:

HSTS 中 max-age 的目的是什么?如:

Strict-Transport-Security: max-age=100

如果值超过100,会发生什么?

有没有设置 max-age 的最佳实践?

谢谢!

【问题讨论】:

    标签: http security https


    【解决方案1】:

    RFC 6797 中定义了发送 HSTS 标头的语义不同的方法:

    Strict-Transport-Security: max-age=31536000
    

    HSTS 策略仅适用于发布它的 HSTS 主机的域,并且有效期为一年。

    Strict-Transport-Security: max-age=31536000; includeSubDomains
    

    HSTS 政策适用于发布主机的域及其子域,有效期为一年。

    Strict-Transport-Security: max-age=0
    

    指示浏览器删除整个 HSTS 策略。

    HSTS 最佳做法

    HSTS 有一些简单的最佳实践:

    1. 最强的保护是确保所有请求的资源仅使用具有格式良好的 HSTS 标头的 TLS。 Qualys 建议在目标域中的所有 HTTPS 资源上提供 HSTS 标头。
    2. 建议将 max-age 指令的值分配为大于 10368000 秒(120 天),理想情况下为 31536000(一年)。网站应旨在提高 max-age 值,以确保在很长一段时间内提高当前域和/或子域的安全性。
    3. RFC 6797,第 14.4 节提倡 Web 应用程序必须尽可能在策略定义中添加 includeSubDomain 指令。该指令的存在确保 HSTS 策略适用于发布主机的域及其所有子域,例如example.comwww.example.com
    4. 应用程序不应通过明文 HTTP 标头发送 HSTS 标头,因为这样做会使连接容易受到 SSL 剥离攻击。
    5. 不建议通过元标记的 http-equiv 属性提供 HSTS 策略。根据 HSTS RFC 6797,用户代理不会注意接收到的内容中元素的 http-equiv="Strict-Transport-Security" 属性。

    这个cheat sheet from OWASP 将来也可能对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2022-08-24
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      • 2023-03-12
      • 2020-08-11
      • 1970-01-01
      • 2013-03-12
      • 1970-01-01
      相关资源
      最近更新 更多