What is HSTS?
HTTP Strict Transport Security (HSTS)HTTP Strict Transport Security (HSTS) is a powerful web security policy mechanism that helps protect websites against man-in-the-middle attacks such as protocol downgrade attacks and cookie hijacking. It allows web servers to declare that web browsers (or other complying user agents) should only interact with it using secure HTTPS connections, and never via the insecure HTTP protocol.
Once a browser receives and accepts an HSTS policy, it will automatically upgrade all subsequent HTTP requests to HTTPS, fundamentally securing the communication channel before any data is transmitted over the network.
The SSL stripping attack that HSTS prevents
Before HSTS, a critical vulnerability existed during the initial connection to a website. Often, users simply type example.com into their browser, which defaults to an insecure HTTP request. The server then responds with a 301 Redirect to the HTTPS version of the site.
This initial HTTP request provides a brief window of opportunity for an attacker positioned on the network (e.g., on public Wi-Fi). In an SSL Stripping attack, the attacker intercepts the HTTP request, establishes a secure HTTPS connection to the real server themselves, but proxies an insecure HTTP version back to the victim. The user sees the expected content but lacks the padlock icon, and all their subsequent traffic—including passwords and session cookies—is transmitted in plaintext to the attacker.
HSTS neutralizes this attack entirely. If the browser has previously received an HSTS header, it will never make that initial HTTP request. It will internally upgrade the connection to HTTPS before the request even hits the network, completely closing the window for SSL stripping.
HSTS header syntax with all parameters explained
The HSTS policy is conveyed via an HTTP response header, which is remarkably straightforward but structurally rigid.
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
The header requires one mandatory parameter (max-age) and supports two highly impactful optional parameters (includeSubDomains and preload).
max-age: how long browsers remember HSTS
The max-age directive dictates the duration, in seconds, that the browser should cache and enforce the HSTS policy for the domain.
- Recommended Value:
31536000(1 year). - Impact: A long
max-ageis crucial for meaningful protection. If set too short, the policy might expire between user visits, re-exposing them to the initial downgrade vulnerability.
includeSubDomains: protection and risk for mail subdomains
The includeSubDomains directive is a boolean flag that extends the HSTS policy to cover the domain itself and all of its subdomains (e.g., blog.example.com, admin.example.com, and even nested subdomains like internal.api.example.com).
- Protection: This is vital for comprehensive security. An attacker might try to force a downgrade attack on an insecure subdomain and steal cookies that were broadly scoped to the parent domain.
- Risk: Applying this directive requires extreme caution. If any internal service, legacy application, or even third-party hosted platform (like certain helpdesk or email marketing tools hosted on a subdomain) does not fully support HTTPS,
includeSubDomainswill render them completely inaccessible to users whose browsers have cached the policy.
Preload: what it means and how to submit
While HSTS is highly effective, it suffers from a "Trust on First Use" (TOFU) vulnerability. The very first time a user visits a site, before the browser has received the HSTS header, they are still vulnerable to SSL stripping.
HSTS Preloading solves this final gap. preload is an unofficial, but universally supported, directive indicating the domain owner's consent to be hardcoded into the browser's source code as an HTTPS-only site.
- The Process: Domain owners submit their domain to the Chromium HSTS Preload list at
hstspreload.org. This list is synchronized across all major browsers (Chrome, Firefox, Safari, Edge). - Requirements: To be accepted, the domain must serve a valid certificate, redirect HTTP to HTTPS, serve all subdomains over HTTPS, and broadcast an HSTS header with a
max-ageof at least 31536000,includeSubDomains, and thepreloadtoken.
Callout: preload is permanent
Important
Preload is a near-permanent commitment. Once your domain is hardcoded into browser source code, reverting it is extremely difficult and slow. Test thoroughly before submitting to hstspreload.org.
Server configuration: Nginx, Apache, Cloudflare examples
Deploying the header is typically handled at the edge or reverse proxy tier.
Nginx:
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
Apache:
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
Cloudflare: Cloudflare users can enable HSTS natively through the dashboard (SSL/TLS -> Edge Certificates -> Enable HSTS), which is often safer as it validates the configuration before deployment.
HSTS and certificates: what happens if cert expires
HSTS drastically alters the browser's error handling for certificate issues. Without HSTS, if a site presents an expired or invalid TLS certificate, the browser displays a warning but often provides an "Advanced -> Proceed anyway" option.
With HSTS active, this bypass option is explicitly removed. The browser assumes the invalid certificate indicates a severe MITM attack and enforces a hard fail. The site becomes completely inaccessible until a valid certificate is provisioned.
HSTS with multiple domains and CDNs
Managing HSTS across complex architectures requires centralized configuration management. When utilizing multiple CDNs or distinct application clusters for different subdomains, ensure the HSTS policy is consistently applied at all edge nodes. Discrepancies can lead to unpredictable caching behavior and potential coverage gaps, particularly when includeSubDomains is utilized.
Removing from preload list: the process and timeline
If a catastrophic issue requires rolling back HSTS Preload, domain owners must submit a removal request via hstspreload.org.
However, the timeline is not immediate. The removal request must be verified, merged into the Chromium source tree, and then propagated to users through regular browser update cycles. This process routinely takes several months, during which the domain remains hard-failed for users who have not yet updated their browsers.
How CyberFurl Helps
Automated monitoring. Zero manual work.
CyberFurl checks HSTS headers across all your domains and subdomains — verifying that max-age meets preload requirements, that includeSubDomains is set, and that no HTTP fallback exists that could enable SSL-strip attacks. The platform also monitors your HSTS preload submission status and alerts if a domain is removed from browser preload lists, a change that would silently re-expose users to downgrade attacks.
