Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are multiple layers of protection against HTTPS-to-HTTP downgrade attacks.

① An HSTS policy will protect people that have visited your site within max-age seconds, typically “within the last year”.

② An HSTS policy with preload will protect everyone.

③ HTTPS-only cookies will prevent them being sent over plain HTTP.

⑤ You could depend on various newer functionality that is only available in secure contexts <https://developer.mozilla.org/en-US/docs/Web/Security/Secure...>. For example, the Web Authentication API. (This also raises a good point about using the Web Authentication API for security: authentication is tied to the origin, so http://example.com, https://example.com and https://example.com.evil.example are all different origins and no one will be able to log in over the wrong origin.)

⑥ Any JavaScript code can check the origin and rebel if it’s not what you expect—in fact, I’d say that it’s very common to do this quite incidentally. This protects against a drive-by downgrade attack, increasing the effort required by the attacker who must now reverse-engineer a bit of your code.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: