What is hsts

Last updated: April 1, 2026

Quick Answer: HSTS (HTTP Strict Transport Security) is a web security protocol that forces web browsers to communicate with websites only through encrypted HTTPS connections. It prevents downgrade attacks and man-in-the-middle security threats.

Key Facts

Overview

HTTP Strict Transport Security (HSTS) is a web security mechanism that forces browsers to establish secure, encrypted connections with websites using HTTPS. Implemented through an HTTP response header, HSTS eliminates the opportunity for attackers to intercept communications by downgrading connections to unencrypted HTTP. This security measure protects against man-in-the-middle attacks, session hijacking, and other attacks that exploit unencrypted connections.

How HSTS Works

When a website sends the HSTS header in its HTTP response, the browser caches this instruction for the specified duration. During this period, the browser automatically converts any HTTP requests to that domain into HTTPS requests before sending them to the server. This occurs at the browser level, before any data travels across the network, preventing attackers from intercepting or downgrading the connection. Different domains and subdomains can have separate HSTS policies.

HSTS Header Structure

The HSTS header follows the format: Strict-Transport-Security: max-age=[seconds]; includeSubDomains; preload. The max-age parameter specifies how long the browser enforces the policy in seconds. The includeSubDomains directive extends the policy to all subdomains. The preload directive indicates the site's inclusion in browser preload lists, enabling HSTS enforcement even on initial visits before receiving the header.

Benefits and Implementation

HSTS provides critical protection against protocol downgrade attacks where attackers force users from HTTPS to HTTP. It eliminates user behavior risks, such as typing http:// instead of https:// in the address bar. For sensitive websites handling authentication, financial transactions, or personal data, HSTS is essential security infrastructure. Implementation requires a valid SSL/TLS certificate and careful configuration to avoid locking users out of sites with certificate issues.

HSTS Preload and Best Practices

Websites can submit their domain to HSTS preload lists maintained by Chromium, Firefox, and other browsers. Inclusion ensures HSTS enforcement from the first visit, providing maximum security. Best practices include starting with conservative max-age values before increasing duration, testing thoroughly before implementation, and maintaining valid SSL/TLS certificates. Removal from preload lists requires formal requests and can take considerable time.

Related Questions

What is the difference between HSTS and HTTPS?

HTTPS encrypts data during transmission, while HSTS enforces the use of HTTPS. HTTPS is the underlying protocol; HSTS is a mechanism ensuring browsers always use it, preventing downgrade attacks.

Can I remove a website from the HSTS preload list?

Yes, websites can request removal from HSTS preload lists through official removal portals. However, removal takes time as the updated list must propagate to all browsers, potentially taking months.

What happens if my SSL certificate expires with HSTS enabled?

Users will receive certificate error warnings and cannot bypass them like they could without HSTS. This makes maintaining valid certificates critical. Prepare certificate renewals well in advance to prevent service disruptions.

Sources

  1. MDN - HTTP Strict Transport Security CC-BY-SA-2.5
  2. RFC 6797 - HTTP Strict Transport Security Public Domain