Protect Against HTTPS Downgrade Attacks
A downgrade attack tricks a visitor into using an unencrypted or weaker connection than the site supports. The best-known form is SSL stripping: an attacker on the same network sits between the visitor and your site, and keeps the visitor on plain HTTP while talking HTTPS to you. The visitor sees a normal page, and everything they type is readable by the attacker.
Where HTTPS downgrade attacks happen
| Weak point | What the attacker does | Defence |
|---|---|---|
| First HTTP request | Intercepts it and never forwards the redirect | HSTS and preload |
| Cookies | Reads cookies sent over HTTP | Secure and HttpOnly flags |
| Old TLS versions | Forces a weak protocol or cipher | TLS 1.2 and 1.3 only |
| Mixed content | Alters scripts loaded over HTTP | Fix links, add CSP |
| Subdomains | Uses an insecure sibling host | includeSubDomains on HSTS |
Step 1: Redirect HTTP to HTTPS
Redirects are the basic step and the first thing to confirm. Use a single 301 from HTTP to HTTPS. Verify it with the HTTPS redirect checker. A redirect alone is not enough, because the first request is still unprotected.
Step 2: add HSTS against HTTPS downgrade attacks
HTTP Strict Transport Security tells the browser to use HTTPS only for your domain for a set time. After the first secure visit, browsers upgrade HTTP requests themselves, so there is nothing for an attacker to strip.
# Nginx
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# Apache
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Roll it out carefully. Start with a short max-age such as 300 seconds, test every subdomain, and then raise it. A long max-age on a site with a broken certificate locks visitors out until the certificate is fixed.
Step 3: Consider preloading
HSTS only helps after a first visit. Preloading adds your domain to a list shipped inside browsers, so even the first visit is protected. It requires a max-age of at least one year, includeSubDomains, and the preload directive. Removal is slow, so only preload when you are certain every subdomain will support HTTPS for the long term.
Step 4: Secure cookies
Set-Cookie: session=abc123; Secure; HttpOnly; SameSite=Lax; Path=/
The Secure flag keeps the cookie off HTTP requests, even if a visitor is tricked into one.
Step 5: Limit TLS versions
ssl_protocols TLSv1.2 TLSv1.3;
Disabling TLS 1.0 and 1.1 removes protocol downgrade options. See our TLS version checker guide for tests.
Step 6: Verify the result
- Run the security headers checker and look for the Strict-Transport-Security header.
- Scan the certificate and chain with the Live SSL Checker.
- Test HTTP requests with curl and confirm the redirect and header.
curl -sI https://example.com | grep -i strict-transport-security
Related reading: enabling HSTS, the TLS version checker, HTTPS best practices for technical SEO and perfect forward secrecy.
Frequently Asked Questions
Does a valid certificate stop SSL stripping?
No. The attacker never lets the visitor reach the HTTPS version. HSTS is the fix.
Can I undo HSTS?
Set max-age to 0 over HTTPS, but browsers that cached the old value keep it until they see the update.
Does HSTS affect search ranking?
Not directly. It supports a clean HTTPS setup.
Do I need a certificate first?
Yes. Issue a free one with TryFreeSSL before enabling any of this.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.