LoginSignup
3
4

More than 5 years have passed since last update.

HTTP Strict-Transport-Security (HSTS)

Last updated at Posted at 2017-05-13

概要

ブラウザに次回のアクセス以降(指定した期間内であれば)ではHTTPSを使ってアクセスさせる

Strict-Transport-Security: max-age=<expire-time>
Strict-Transport-Security: max-age=<expire-time>; includeSubDomains
Strict-Transport-Security: max-age=<expire-time>; preload

max-age

  • HTTPSでのアクセスを強制させる期間

includeSubDomains

  • このオプションが指定された場合は全てのサブドメインに適用される

preload

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
https://hstspreload.org/
https://tools.ietf.org/html/rfc6797

HSTS 事前リスト

  • HSTSをあらかじめ有効にするサイト一覧
  • 事前リストに含めてもらうにはここで申請が必要 (一見怪しいサイトにみえるが、証明書を見る限りgoogleが管理してるっぽい)

その他

HSTSが有効なサイトはユーザが証明書エラーを無視することができなくなる(UAがそのケースはコネクションを切断してしまうため)

8.4. Errors in Secure Transport Establishment

When connecting to a Known HSTS Host, the UA MUST terminate the
connection (see also Section 12 ("User Agent Implementation Advice"))
if there are any errors, whether "warning" or "fatal" or any other
error level, with the underlying secure transport. For example, this
includes any errors found in certificate validity checking that UAs
employ, such as via Certificate Revocation Lists (CRLs) [RFC5280], or
via the Online Certificate Status Protocol (OCSP) [RFC2560], as well
as via TLS server identity checking [RFC6125].

防げる問題

  • httpアクセスをMITMで攻撃するケース
  • httpsサイトにhttpのリンクやコンテンツを意図せず含めてしまったケース
  • 不正な証明書をユーザが無視するようなケースを狙った攻撃

実際のレスポンスの例

$ curl -s -D - 'https://www.facebook.com/' -o /dev/null | grep Strict-Transport-Security
Strict-Transport-Security: max-age=15552000; preload
3
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4