Re:HTTP headers for the responsible developer
by amelius on Wednesday May 08, 2019 @07:36AM
(#19857850)
How can HSTS prevent a man in the middle attack if the server has not even been contacted yet?
Re:HTTP headers for the responsible developer
by LeonM on Wednesday May 08, 2019 @09:07AM
(#19858453)
It can't, that is what preloading is for. Your browsers comes preloaded with a list of all sites that have requested HSTS preload, so your browser will use HTTPS even on the first visit. This is why preloading on all subdomains is potentially dangerous to use, it could break your site if you don't have HTTPS everywhere.
But even without preloading HSTS will improve security. Yes, the first visit will be susceptible to MITM, but every visit after that is not. This makes it a lot more difficult for an attacker as they must intercept the very first visit for the attack to work.
HSTS preload list is compiled into browser binary:
https://chromium.googlesource.com/chromium/src/net/+/master/...
https://dxr.mozilla.org/mozilla-central/source/security/mana...
Re:HTTP headers for the responsible developer
by heinrich5991 on Wednesday May 08, 2019 @07:43AM
(#19857887)
It can only do that if you add it to the preload lists of browsers (which is mentioned in the article).
But even if it is not, it's still helpful for people connecting to your site again.
Re:HTTP headers for the responsible developer
by tialaramex on Wednesday May 08, 2019 @08:17AM
(#19858087)
And because the preload list is hierarchical whole swathes of the Web can be covered with a single entry. .dev is the biggest example, but they can protect all the stack exchanges, all the default blogspot blogs, that sort of thing.
HSTS is designed to prevent this.