Skip to content
uencoder

HSTS

HSTS (HTTP Strict Transport Security) declares via an HTTP header that a site is reachable only over HTTPS, preventing SSL stripping and downgrade attacks.

Purpose

It forces browsers to always use HTTPS for the site, even when the user types HTTP.

Mechanism

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload. Once the browser records it, every HTTP request is automatically upgraded to HTTPS for the max-age period. The preload directive qualifies the site for the browser's built-in HSTS Preload List.

Use cases

  • SSL stripping defense
  • Enforced HTTPS upgrades
  • Subdomain protection
  • The preload list

Examples

  • Input
    max-age=31536000; preload
    Output
    HTTPS enforced for one year

    With preload

Common errors

Without HSTS, the first HTTP visit is exposed to man-in-the-middle attackers
Set HSTS and join the preload list

Related terms

References