HTTP Strict Transport Security (HSTS)
Key Parameters
| Directive | Recommended Value | Purpose |
|---|---|---|
| max-age | 31536000 (1 year) | How long browsers remember HTTPS-only |
| includeSubDomains | Include if all subdomains support HTTPS | Extends policy to subdomains |
| preload | Include after testing | Submit to browser preload list |
The Importance of HSTS
Without HSTS, even an HTTPS-enabled site is vulnerable to SSL stripping attacks. An attacker on the network (like a public Wi-Fi hotspot) can intercept the initial HTTP request before it is redirected to HTTPS and serve a plain HTTP version of the site. The user sees no security indicators because the connection never reaches HTTPS. HSTS prevents this by ensuring the browser never attempts an HTTP connection.
The HSTS preload list takes this further by hardcoding HSTS into the browser itself. Sites on the preload list are always accessed over HTTPS, even on the very first visit. Without preloading, the first visit is still vulnerable because the browser has not yet received the HSTS header.
HSTS has an important operational implication: if your SSL certificate expires while HSTS is active, browsers will refuse to connect at all - there is no way to click through the warning. This makes automated certificate renewal essential for HSTS-enabled sites.
How to Check
Run a security audit to check if your server sends the Strict-Transport-Security header. Verify the max-age is at least 31536000 (one year) and consider adding includeSubDomains and preload directives. Check the HSTS preload list to see if your domain is preloaded.