HSTS (HTTP Strict Transport Security)
What is HSTS (HTTP Strict Transport Security)?
HSTS (HTTP Strict Transport Security, RFC 6797) is a response header that tells a browser to reach a host only over HTTPS for a set number of seconds and to refuse certificate-error click-throughs. AdminKit's HTTP security headers check fetches a URL live and shows whether Strict-Transport-Security is sent, with its value.
By AdminKit team, Netbase JSC · Updated
HSTS is defined in RFC 6797. A site opts in by sending the Strict-Transport-Security response header over HTTPS. The browser then treats the host as a “Known HSTS Host” for the number of seconds in the required max-age directive. During that time it rewrites any http:// link or typed address for the host to https:// before sending a request. If the TLS connection fails, for example because of an invalid certificate, the browser shows an error with no way to click through. A typical header looks like this:
Strict-Transport-Security: max-age=31536000; includeSubDomains
MDN’s Strict-Transport-Security reference adds the practical details. The policy covers every port of the host, an http:// URL on port 80 is changed to port 443, and an IP address can never be an HSTS host. The header is ignored when it arrives over plain HTTP, so a server should redirect HTTP requests to HTTPS and send the header only on the HTTPS response.
What does HSTS protect against?
The OWASP HTTP Strict Transport Security Cheat Sheet lists three threats: a user who types or bookmarks an http:// address and meets a man-in-the-middle, a site that is meant to be HTTPS-only but still has some plain HTTP links, and an attacker who presents an invalid certificate and hopes the user accepts it. The same cheat sheet suggests a short max-age such as one day during the first rollout, so a mistake does not lock visitors out for a year.
How is HSTS different from the HSTS preload list?
The header only protects a browser after it has seen the header once over HTTPS, while the HSTS preload list is built into browsers so a listed domain is HTTPS-only from the first request. Preloading is a separate step with stricter rules and a slow removal process; AdminKit’s guide to HSTS and HSTS preload explains why it is not right for every site. HSTS is one of several policies a site sends as headers, alongside a Content-Security-Policy and a Referrer-Policy.
AdminKit’s HTTP security headers check fetches a URL live and shows whether Strict-Transport-Security is present, with the exact value sent, and raises a medium finding when an HTTPS URL sends no HSTS header. It reports that the header is present; it does not grade whether the max-age is long enough. HSTS is part of AdminKit’s machine protocols cluster; the full AdminKit glossary lists other related terms.
Frequently asked questions
Does an HSTS header sent over plain HTTP do anything?
No. RFC 6797 says an HSTS host must not send the header over a non-secure connection, and browsers ignore it there, so an attacker on the path cannot add or shorten the policy. The header only counts when it arrives over HTTPS with no certificate errors.
How do I turn HSTS off for a site?
Send the header with max-age=0 over HTTPS. RFC 6797 says that value tells the browser to stop treating the host as a Known HSTS Host, including any includeSubDomains setting. Browsers that never come back to receive the new header keep the old policy until its max-age runs out.
What does includeSubDomains change?
It applies the same HTTPS-only rule to every subdomain of the host. RFC 6797 warns this breaks anything still served over plain HTTP under that name, such as a certificate authority's CRL or OCSP service, and the OWASP cheat sheet notes that leaving it out allows cookie attacks from subdomains.
Is HSTS the same as the HSTS preload list?
No. HSTS is the header a site sends; the browser only learns it after one successful HTTPS visit. The preload list is built into browsers, so a listed domain gets HTTPS even on the very first visit.