Skip to content
AdminKit

HSTS and HSTS preload explained: downgrade protection, and its lock-in risk

AdminKit's HTTP security headers check reports HSTS, defined in RFC 6797: a header telling a browser to never load a site over plain HTTP again, closing off downgrade and cookie-hijacking attacks on an unencrypted first request. HSTS preload extends protection to a visitor's first connection by baking the policy into the browser, at the cost of a slow removal process.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • HSTS is one response header, Strict-Transport-Security, that tells a browser to use only HTTPS for your domain until max-age runs out.
  • It protects every visit after the first. Preloading puts your domain in the browser itself, so even the first visit uses HTTPS.
  • Browsers ignore the header when it arrives over plain HTTP. On a known HSTS host, a certificate error becomes a hard failure with no click-through.
  • Roll out in stages (5 minutes, 1 week, 1 month, then a year or more) and test every subdomain, internal ones included, before you add includeSubDomains.
  • Preloading is opt-in and slow to reverse. A removal may take 6–12 weeks to reach most Chrome users, and longer in other browsers.

What problem does HSTS solve?

Even a site that serves everything over HTTPS is vulnerable at one specific moment: the instant a user’s browser tries to connect before it knows the site requires encryption — a typed address without https://, an old HTTP link, or a bookmark saved years ago. An attacker positioned on that network path can intercept the plain HTTP request and either keep the session downgraded or read and inject cookies before any redirect to HTTPS completes. RFC 6797 (also on the IETF Datatracker) defines HSTS to close this window for every connection after the first: once a browser has received a valid Strict-Transport-Security header from a site, it rewrites every future request to that domain to HTTPS internally, before the request ever leaves the device, for as long as the header’s max-age specifies.

A redirect from HTTP to HTTPS on its own does not close this gap. The redirect is itself sent over plain HTTP, so an attacker in the path can strip it or answer in its place. HSTS moves the decision into the browser. After the first HTTPS visit, the browser stops asking.

What does the header look like, and what does each directive do?

The header has one required directive and two optional ones. A typical policy, as shown in MDN’s reference, looks like this:

Strict-Transport-Security: max-age=31536000; includeSubDomains
DirectiveRequired?What it doesSource
max-age=<seconds>YesHow long the browser remembers that the host is HTTPS-only. max-age=0 deletes the stored policy.RFC 6797 §6.1.1, §8.1
includeSubDomainsNoApplies the same policy to every subdomain of the host.RFC 6797 §6.1.2
preloadNoNot part of RFC 6797. A signal to hstspreload.org that you consent to being added to the browser preload list.hstspreload.org, MDN

Under RFC 6797 §8.2–8.3, once a policy applies, the browser rewrites the URL scheme to https. It also changes an explicit port 80 to 443 and leaves other ports as they are. The browser never sends the plain HTTP request at all, so an attacker on the path never sees one to intercept.

What does HSTS protect against, and what doesn’t it?

Strict-Transport-Security: max-age=63072000; includeSubDomains tells the browser to enforce HTTPS-only for two years, across every subdomain. This directly stops the two attacks described above, but only from the second connection onward — the header has to have been seen once already to take effect, which is precisely the gap preload addresses. This is a meaningfully different guarantee from a CA-issued certificate alone: a valid certificate makes an HTTPS connection trustworthy once it happens, while HSTS makes sure the HTTPS connection happens at all, for every visit after the first.

RFC 6797 adds two rules that are easy to miss:

  • The header only counts over HTTPS. A browser must ignore a Strict-Transport-Security header that arrives over insecure transport. MDN explains why: otherwise an attacker in the middle could make the policy expire early, or add it to a host that has no HTTPS. Sending the header on your port 80 response does nothing.
  • Certificate errors become fatal. When a browser connects to a known HSTS host and the secure transport has any error, RFC 6797 §8.4 and §12.1 say it must end the connection with no user recourse. The visitor cannot click past an expired or mismatched certificate. This is a strong protection, and it is also why a lapsed certificate on an HSTS site is a full outage.
SituationWithout HSTSWith HSTS (after one HTTPS visit)
User types example.comBrowser sends plain HTTP first, then follows a redirectBrowser goes straight to https://example.com/
Old http:// link or bookmarkPlain HTTP request leaves the deviceRewritten to HTTPS inside the browser
Attacker strips the redirectSession can stay on HTTPNo HTTP request to strip
Certificate errorWarning page, user may click throughConnection fails, no click-through
User’s very first visitExposedStill exposed, unless the domain is preloaded

How should you roll out HSTS without locking yourself out?

Increase max-age in stages, so a mistake costs minutes, not months. hstspreload.org suggests starting by examining every subdomain and nested subdomain of your site, including internal subdomains that are not publicly reachable. Then step up the policy:

StageHeader valueWait before the next stage
1max-age=300; includeSubDomainsThe full 5 minutes, while you watch for broken pages
2max-age=604800; includeSubDomainsThe full 1 week
3max-age=2592000; includeSubDomainsThe full 1 month
4max-age=31536000; includeSubDomains or longerStay here unless you choose to preload

Between stages, hstspreload.org says to monitor for problems and wait the full max-age of the current stage before you move on. The waiting matters: a browser that saw the stage-2 header keeps enforcing it for a week, even if you change the header later.

Two practical checks at each stage:

  • Every subdomain with a DNS record must answer over HTTPS with a valid certificate. includeSubDomains covers names you may have forgotten, such as an old intranet host or a printer’s web panel.
  • Any http:// URL that points at your own host, or at a covered subdomain, is now rewritten to HTTPS, and that includes images and scripts. A page that pulls assets from a subdomain without working HTTPS will lose those assets. Test pages that depend on legacy asset hosts.

If something breaks, send max-age=0. RFC 6797 §6.1.1 says a zero value makes the browser delete its stored policy, but only for browsers that load the site again and see the new header.

What does HSTS preload add?

Rather than depending on a prior visit, a site can request inclusion in Chrome’s HSTS preload list, a list of domains hardcoded directly into Chromium’s source code and shipped with the browser itself; Firefox, Safari and other major browsers maintain preload lists derived from Chrome’s, per hstspreload.org’s own documentation. A domain on the list is HTTPS-only for every user, from their very first connection, with no bootstrap request required at all. RFC 6797 §12.3 already describes this idea of a list built into the browser as a way to reduce first-visit exposure.

The submission requirements on hstspreload.org are strict for good reason:

  1. Serve a valid certificate.
  2. Redirect from HTTP to HTTPS on the same host, if you listen on port 80.
  3. Serve all subdomains over HTTPS, including www if a DNS record for it exists.
  4. Send an HSTS header on the base domain over HTTPS, with max-age of at least 31536000 seconds (one year), includeSubDomains and preload.
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload

hstspreload.org also notes that many browsers, Chrome and Safari among them, now try to upgrade HTTP navigations to HTTPS anyway, whatever the domain’s HSTS policy. In its words, preloading only adds value when those upgrades fail in the presence of an active attacker. That is a narrower benefit than many setup guides suggest.

Why is HSTS preload hard to undo?

The list ships inside the browser, so every change waits for a browser release. hstspreload.org says it takes months for a change to reach users with a Chrome update. Its removal page says a removal may take 6–12 weeks to reach most Chrome users, and may take longer for other browsers. During that time, any subdomain that cannot serve HTTPS is unreachable in browsers that use the list, and visitors have no way to click past it. A site preloaded before every subdomain was actually ready for HTTPS can end up with parts of its infrastructure unreachable for weeks or months, with no quick way to back out.

Removal follows a fixed process. The domain must be preloaded or pending through hstspreload.org, serve HTTPS with a valid certificate, and send a valid HSTS header without the preload directive:

# Request removal from the preload list, keep HSTS
Strict-Transport-Security: max-age=31536000; includeSubDomains

# Turn HSTS off entirely in browsers that see this response
Strict-Transport-Security: max-age=0

This is why hstspreload.org’s own guidance tells tools and setup wizards not to include the preload directive by default. It also states that, while the HSTS header itself is recommended, preloading specifically is not recommended for every site. Preload fits only domains that are certain HTTPS will remain universal across every current and future subdomain.

How do you check HSTS on your own site?

Confirm your HSTS header is actually present and correctly scoped before even considering preload — inspect it with any browser’s network devtools or with AdminKit’s HTTP security headers check, which shows the exact Strict-Transport-Security value a site sends alongside the other recommended response headers. For an https:// URL with no HSTS header, the check raises a medium-severity finding with the fix hint max-age=31536000; includeSubDomains. It shows the value you send but does not grade max-age or look up preload list status, so read the number yourself and use hstspreload.org’s status lookup for the list.

From a terminal, curl -sI prints the response headers. The output below is an illustrative example for the documentation domain example.com, not a capture from a real site:

$ curl -sI https://example.com/ | grep -i strict-transport-security
strict-transport-security: max-age=31536000; includeSubDomains

If every subdomain you control and plan to ever add supports HTTPS unconditionally, preload closes a real first-connection gap; if you’re not certain of that yet, the HSTS header alone — without the preload directive — already provides the main protection without the multi-month lock-in.

HSTS, Certificate Transparency and CAA records each protect a different stage of the same trust chain: see Certificate Transparency logs explained for how mis-issued certificates become visible after the fact, what CAA records do for limiting who can issue a certificate for your domain in the first place, and reading a TLS/SSL certificate check result for what to check once a connection is actually established. Because HSTS turns any certificate error into a hard failure, keeping the certificate itself valid matters more once the header is in place.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

What does the HSTS header actually do?

A site sends `Strict-Transport-Security: max-age=<seconds>` (optionally with `includeSubDomains`) over an HTTPS response, and RFC 6797 specifies that a compliant browser must then refuse to load that domain over plain HTTP for the stated duration — any `http://` link or typed address gets rewritten to `https://` internally before a request is even sent. This closes two concrete attacks: an on-path attacker rewriting a redirect from HTTP to HTTPS to keep the connection downgraded, and an attacker reading or injecting cookies during that same unencrypted first hop.

If HSTS only applies after the first visit, what protects the very first connection?

Nothing, by design — RFC 6797's mechanism can only take effect once a browser has already seen the header from a prior HTTPS visit, which leaves a real gap: if a user's first-ever connection to a domain happens to be over HTTP (an old bookmark, a typed address without 'https://', a link from an old search result), an on-path attacker gets one shot at intercepting that first request before HSTS has ever been recorded. This is often called the 'trust on first use' or 'bootstrap' problem, and it's the exact gap HSTS preload is built to close.

How does HSTS preload close that gap?

Instead of waiting for a browser to see the header once, a site can submit its domain to Chrome's HSTS preload list, maintained at hstspreload.org, which ships as a hardcoded list baked directly into the browser's source code; Firefox, Safari and other major browsers maintain their own lists based on Chrome's. Once a domain is on the list, a browser enforces HTTPS-only from the very first connection it ever makes to that domain, with no prior visit required — closing the bootstrap gap entirely, at the cost of every subdomain needing to support HTTPS, including internal ones that were never meant to be public.

Why is HSTS preload described as having a 'lock-in' risk?

Because reversing it is slow by design. hstspreload.org documents that the list is hardcoded into Chrome and that it takes months for a change to reach users with a Chrome update, and that a removal may take 6–12 weeks to reach most Chrome users and longer for other browsers — a site that preloaded before confirming every subdomain actually supports HTTPS can end up with subdomains unreachable in any preload-respecting browser for months, with no fast way to undo it. hstspreload.org's own guidance is explicit that tools and guides should make preloading opt-in, not a default, specifically because of how often site operators have been burned by this.

Should every site submit itself to the preload list?

Not automatically. hstspreload.org's own position is that the HSTS header itself is recommended, but preloading specifically is not recommended for every site — it's intended for sites that are certain every current and future subdomain will support HTTPS indefinitely. A site still gets strong protection from the HSTS header alone after a user's first HTTPS visit; preload only adds value for the narrow bootstrap-connection scenario, and that narrow benefit should be weighed against months of inflexibility if a subdomain ever needs to run HTTP again.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.