brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Strict-Transport-Security max-age=0 is the off switch for HSTS

Security
~/tips/tip-hsts-max-age-zero-turn-off

Strict-Transport-Security: max-age=0

Explains how a site turns HSTS off again and why that only works over HTTPS.

Switching on HSTS takes one header. Switching it off again is where people get stuck, because you can’t do it the way you did it, over plain HTTP.

Strict-Transport-Security: max-age=0

MDN’s page on the header says that is how you disable HSTS. Every time a browser sees the header, it sets the host’s expiry time to now plus max-age. With 0, the entry is gone at once. But it only takes effect once the browser makes a secure request and gets that header back. Browsers ignore the header over plain HTTP, so a man in the middle can’t use it to expire a rule early. That also means you cannot turn HSTS off over insecure HTTP, so your HTTPS has to keep working until every visitor has seen the new header.

Check what a site sends now with:

curl -sI https://example.com/ | grep -i strict-transport-security

Two more details from MDN. With max-age=0, includeSubDomains has no effect and does not delete the separate policies that subdomains may have. And the preload form needs max-age of at least 31536000 and includeSubDomains, as in the example max-age=63072000; includeSubDomains; preload.

Caveat: MDN says the preload list is not part of the HSTS specification and should not be treated as official. I’d test with a short max-age first, say a few minutes, and only raise it when everything on that domain and its subdomains really works over HTTPS.

Further reading: Strict-Transport-Security on MDN

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Referrer-Policy: strict-origin-when-cross-origin wp super-admin list getent group sudo adm docker lxd All Security tips (79) All topics

Link