Notes
SSL stripping
The classic detour is SSL stripping. When you type a bare site name, the browser may try plain HTTP first, and the site answers with a redirect to HTTPS. An attacker in the middle swallows that redirect. They hold an encrypted connection to the real site and a plain one to you, relaying everything and reading all of it. There is no certificate warning, because no certificate is involved on your side. Only a missing padlock.
- you type shop.example: the browser tries http:// first
- the site would redirect to https:// the attacker in the middle swallows that redirect
- they talk HTTPS to the site and plain HTTP to you
- no warning: just no padlock
HSTS
The fix is HSTS, a response header that tells the browser: for the next year, never speak plain HTTP to this site. From then on the browser rewrites every request to HTTPS before it leaves the machine, so there is no first plain request to intercept. It also removes the option to click through certificate errors for that site. One header, set once at the edge, closes the stripping attack.
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload the browser remembers: for a year, turn every http:// into https:// before sending, and refuse to click through certificate errors
Preload
HSTS has one gap. The browser must see the header once before it applies, so the very first visit is still exposed. The answer is the preload list, a list of domains built into browsers themselves, so HTTPS is forced from the first connection ever. One warning before you turn it on: with include subdomains, any forgotten internal subdomain still on plain HTTP stops working, and removal from the list is slow. Check first.
- HSTS only works after the browser has seen the header
- the first visit ever is still exposed
- preload list: browsers ship with your domain built in careful: includeSubDomains breaks any subdomain still on HTTP
Downgrade attacks
The second detour is the downgrade. TLS begins with a negotiation, where both sides agree on a protocol version and a cipher. An attacker in the middle interferes so that they settle on the oldest, weakest option both still support. Several famous attacks worked exactly this way. The lesson is simple: a server is only as strong as the weakest version it still accepts. Disable the old ones, and there is nothing to downgrade to.
- TLS negotiates a version and a cipher both sides support
- an attacker interferes so they settle on an old, weak one named attacks: POODLE (SSL 3), FREAK, Logjam
- fix: do not support the old versions at all TLS 1.3 protects the negotiation itself
Server settings
A correct server accepts TLS one point two and 1.3 and nothing older. It prefers ciphers with forward secrecy, so a stolen key cannot decrypt recorded past traffic. It redirects plain HTTP to HTTPS and sends HSTS. You do not need to design this yourself. Mozilla publishes a configuration generator with tested settings for every common web server, and using a known-good template beats hand-picking ciphers every time.
- TLS 1.2 and 1.3 only off: SSL 3, TLS 1.0, TLS 1.1
- forward-secret ciphers (ECDHE), AEAD (GCM, ChaCha20)
- redirect port 80 to HTTPS
- HSTS on use a known-good template (Mozilla SSL config tool)
Certificate attacks
The third detour is impersonation. TLS proves who you are talking to only if the certificate check is real. An attacker can present a self-signed certificate and hope the user clicks through. A certificate authority can be tricked into issuing one for your domain. A rogue root certificate can be installed on a device. And far too much code simply switches validation off. Defend with CAA records and by monitoring certificate transparency logs.
- self-signed or wrong-name certificate: browser warns
- a certificate authority tricked or hacked into issuing one a rogue root CA installed on the device
- code that skips validation: verify=False
- defense: CAA, certificate transparency monitoring
In code
The most common TLS weakness is not on the server. It is in application code and scripts that turn certificate validation off to make an error go away: verify equals false, curl with minus k, a trust manager that accepts everything. That connection is encrypted to whoever answers, including an attacker. The correct fix is always the certificate or the trust store. Search your codebase for these patterns; static analysis tools flag them.
requests.get(url, verify=False) curl -k https://... rejectUnauthorized: false a TrustManager that accepts all it "fixes" the error by removing the protection fix the certificate or the trust store instead
Test yourself
All of this can be measured from the outside, on servers you own. Nmap's cipher script lists every protocol version and cipher a server accepts. A tool called testssl gives a full report with known weaknesses flagged, and public scanners grade a site from A to F. A one-line curl shows whether the HSTS header is present. Run these in your pipeline, so a config change that re-enables an old version is caught the same day.
# what does the server accept? nmap --script ssl-enum-ciphers \ -p 443 your.site # full report testssl.sh your.site # headers curl -sI https://your.site | grep -i strict-transport
Common mistakes
Mistakes. No HSTS header. Old TLS versions left on for one ancient client. Certificate validation disabled in code. Internal sites with broken certificates that train every employee to click past warnings. Certificates that expire because renewal is manual. Mixed content, where an HTTPS page loads a script over HTTP. And exempting internal services from all of it, as if attackers never get inside.
- no HSTS
- TLS 1.0 and 1.1 still on
- validation disabled in code
- users trained to click past warnings
- expired certificates
- mixed content: HTTP scripts on an HTTPS page
- internal services exempt
Say it like this
In the interview: SSL stripping is a man in the middle keeping the victim on plain HTTP by intercepting the redirect to HTTPS, while speaking HTTPS to the real site. HSTS prevents it by making the browser use HTTPS only, and preloading covers the first visit. Beyond that I allow only TLS one point two and 1.3, enforce certificate validation in all code, and scan my own configuration regularly.
- "A man in the middle keeps the victim on plain HTTP by eating
- the redirect to HTTPS. HSTS
- makes the browser use HTTPS
- only, and preload covers the first visit. I also allow only TLS 1.2 and 1.3, enforce
- certificate validation, and scan my own config."