3 ms·
The part about man in the middle attacks is as far as I can tell dangerously misleading. Defaulting to HTTPS is not enough to prevent cookie theft by man in th
by hannob 8y ago
The part about man in the middle attacks is as far as I can tell dangerously misleading.
Defaulting to HTTPS is not enough to prevent cookie theft by man in the middle attacks, because a browser will still happily do HTTP connections. (They'll get redirected to HTTPS if you configure the server for HTTPS only, but that's only happening after the Cookie is already transmitted without encryption.)
Traditionally there is a "secure" flag for cookies. (I know little go, but from reading the docs it seems it can be set in http.Cookie with Secure = true, similarly to the httponly flag he's describing.)
However these days there's a better solution: Use HSTS, which enforces HTTPS connections after the first connection has been made. Even better is HSTS preloading, where your domain is added to a whitelist of HSTS domains within common browsers.
- buildme 8y agoCaveat: only do this if you're absolutely certain you never want to make a plain HTTP request ever again, because once you're on each browser's HSTS preload list, it takes months to get removed and have the updated list propagated out to browsers. [1] [1] https://www.troyhunt.com/understanding-http-strict-transport/ https://www.troyhunt.com/understanding-http-strict-transport...
- joncalhoun 8y agoHuh... I was thinking I touched on the Secure field of the http.Cookie when I wrote this article, but I guess I did not. I'll try to find time to update the article with both the Secure field and more info on HSTS.