I don't care about HSTS for localhost
github.com
github.com
When developing locally I'll aim to run without HTTPS / HSTS etc - whilst I'm generally fairly passionate about narrowing the gap between local development and your deployed setup, using HTTPS locally often results in hours of yak shaving.
There. I said it.
edit: I only self sign localhost subdomains (app1.localhost, www.site1.localhost, etc.) and each project has its own self signed certificate (by the same CA) with needed domains (usually traefik.localhost, www.site.localhost, api.site.localhost, etc.). localhost becomes basically my presonnal tld.
[0] https://bugzilla.mozilla.org/show_bug.cgi?id=856060 [1] https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1....
I can't speak about your threat model, but "exfiltrating my private CA keys to phish my browser" isn't really something I worry about in practice.
For those still checking certificate validity, Firefox will warn you that the certificate used is not in the system database when you click the little lock in the address bar.
That said, I'd absolutely love a system where I could restrict my private CA to certain domains.
For a local CA with the CA only on one machine you're perhaps OK if you are careful, but once you share the server with a couple of collegues you are potentially into a world of hurt.
On OSX you can choose "Always Trust" or "Never Trust" for various purposes (code signing, SSL, EAP, etc).
Why can't I have "Ask first time", or "Trust only for specific domains"
Same with built in ones. That "Hong Kong Post" root CA raises some eyebrows with me, I'd love to set that to "Ask first time" on it.
I like Firefox with Tree Style Tabs and an adblocker for everyday browsing, and some Chrome derivative with no addons other than Xdebug for development. Lately I've been using the Responsively browser for dev, especially if I need to do anything mobile.
It just takes caddy, a domain you own so you can get certificates via DNS challenge and point those domains to 127.0.0.x in your hosts file. It is not a big challenge and it is worth it once you finish setting it up.
Why would you wait for your development cycle to slow down from seconds to minutes to catch problems that could be caught beforehand?
One such example is secure cookies.
There's a longer list here: https://web.dev/when-to-use-local-https/
Everything else on that list is you can't test https without https. How could you possibly test mixed content without using https? Http/2 is so tied to TLS that the insecure version that nobody has implemented isn't really the same thing. Etc
One may certainly decide that benefit is not worth jumping through too many hoops, but in any case the point of doing it is not the actual TLS.
At this point browsers have all sorts of behavioral differences between secure and insecure, so you’re kinda just choosing which poison to drink: “wow this setup is a pain” vs “why does this work locally but not in staging”
I've found this most useful for testing CORS and similar web features that depend on the origin, but I guess it could be helpful for HTTPS-related things too.
But no, it's in wherever path specified in /etc/apache2/sites-enabled/virtualhost12345.conf, which can be /etc/letsencrypt/whatever/subdirectory/hostname.pem or /usr/ssl/certs/dynamic_file_name.cer, and in many other cases it's whatever that `docker exec stout_kaltsit cat /ssl-cert-private.key` yields. No one even agrees on whether it sits in /etc or /usr or /var or somewhere mapped deep down.
The whole TLS is just a hindrance that throws error that needs to be hastily cleared when encountered because the Web server stack is bunch of afterthoughts and that's what is showing.
(I couldn’t find any layman’s docs that said it in so many words, nor did I want to test it locally. My guess comes from a reading of section 8.1.1 in the HSTS RFC[1].)
I’ve been using 127.0.0.1:4000 or 0.0.0.0:4000 for local web development for a while now and have not really been held back.
Maybe people who have fancier local development setups can’t use an IP address for some reason and instead have to use localhost? But it seems to me like the easiest workaround is not to load some formatted plist file into chrome but rather to rewrite the address bar slightly.
$ curl -sS -D- -o/dev/null https://1.1.1.1/ | grep -i strict-transport-security
strict-transport-security: max-age=31536000
but you won't find 1.1.1.1 in chrome://net-internals/#hsts, and you can still directly request http://1.1.1.1/, which returns a remote 301 response. Unlike for an HSTS domain, for which you get a local 307 response with a Non-Authoritative-Reason: HSTS header (in Chrome).The idea that they put it right in the specification that browsers were prohibited from allowing users to bypass it, even if they know what they're doing, fully moved browsers out of the "user agent" category.
Historically there have been several phrases used, with changes once every few years, and the weak argument is that people who go to the bother of learning each new phrase, plus the fact the phrase tells you it's a bad idea (one of them literally) would bypass this anyway, but well... would they?
Human psychology doesn't work that way. People get into the habit of typing whatever the magic phrase is and then they're astonished that it was a bad idea even though it just said so. You can't build effective security systems on such foundations.
Same with TLS errors. I have never once encountered a single instance of someone trying to intercept my connection but I’ve encountered hundreds of misconfigured but otherwise perfectly functional servers if you just ignore the errors.
You can’t really blame users when you hide literally all the details that would allow them to make an informed decision about whether they should hit “It’s Fine False Alarm” or “Oh Shit Got Em” and then be surprised when people hit the false alarm button without thinking when it’s always a damn false alarm.
We would do so much better if we had screens like, “Hey the cert the server sent is otherwise valid but expired 5 minutes ago, is that cool?” or “The server sent a certificate for bloop.domain” but you connected to “blorp.domain” with options like “Seems Sus”, “My b it was a typo” and “Damn, autocorrect gottem.”
Like we have absolutely zero reasonable sense of security and risk as anything other than perfectly secure and defcon 69.
Not sure how your security model will handle that.
1. Automatically redirect from http:// to https:// .
2. Make it difficult to bypass the certificate warning screen.
1 I think is very good. 2 is questionable.
The browser MUST allow the end user to override EVERYTHING (and assume that you know what you are doing, instead of trying to do things for you differently than what you did), and then it will be good.
They put that requirement in there because HSTS is pointless without it. The website is literally saying "we will always (w/ expiration) have valid TLS, if we don't that's a problem". Allowing users to bypass it allows criminals to go "oh we're having problems with the cert, just type 'badidea' and click yes to continue to be hacked".
And if that makes it pointless, then just remove it entirely. Believe it or not, I've never seen a cert error in the wild that wasn't an expiration of a valid cert or a misconfiguration.
The boogeyman of MITM attacks which PKI certs protect from is used to justify a lot of terrible changes to the web that aren't reflected by reality: In most cases they're just going to hack the real server and serve malicious content from your valid certificate anyways. Or they'll trick someone into giving their credentials to bonkofamerica.com because people are easy to fool. Why MITM Amazon when people will happily treat an order email sent from a Gmail account as legitimate?
I have. Usually caused by a captive portal.
> The boogeyman of MITM attacks which PKI certs protect from is used to justify a lot of terrible changes to the web that aren't reflected by reality.
The move to use HTTPS everywhere was started in response to packet sniffing tools like Firesheep. That’s not a boogeyman; it’s a proof of concept that works in realistic scenarios.
> Why MITM Amazon when people will happily treat an order email sent from a Gmail account as legitimate?
So what? How about solving both problems?
And invalidate every user's session whenever the server's certificate is renewed??
I never seen a captive portal using a valid certificate either. Not like I saw many captive portals (last time was like... 2018?) but still.
What's the definition of a fake certificate? Self signed? Signed by a real CA, but for a different domain (the captive portal operator's generally)?
Here's one example:
https://www.engadget.com/2018-04-25-hackers-dns-phishing-sca...
Are you using this as an example of how HSTS is helping users now? Because Chrome allows you to type 'thisisunsafe' and you'll get through the warning, regardless of HSTS.
No. If I click an http:// link, I want that link to be upgraded automatically to https:// if possible so that MITMs can't read or modify the request or response. I would still get that benefit if the browser made it easy to click through certificate warnings.
However, in general I think the browser preventing the user from doing something the user wants is a bit offputting. The browser is a "user agent". It should act on behalf of the user. If the user wants it to do something, it should do that. This case is tricky, because sometimes what the user really wants is not what the user is asking the user agent to do. It's an xy problem. I think Chrome's current behavior strikes a nice balance.
See https://stackoverflow.com/questions/58067499/runing-javascri..., and I think there is another flag you need to disable as well.
Why is that? I definitely get blocking file:// scripts from any other protocol, and even blocking file:// scripts outside of the webpage's directory. But if you can get a user to open a webpage on their local machine, in the same folder as sensitive data, you mine as well just get them to run an arbitrary program.
Web pages are assumed to be "safe" by users, like a pdf or a png.
Furthermore, PDF also runs JavaScript, their Kind of JavaScript, depending on where you downloaded it from.
https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=adobe+reade... shows 4 potentially exploitable vulnerabilities + 1 that lets the attacker check if a file exists.
I couldn't find any semi-recent ones affecting Firefox' PDF.js.
Which is something you probably shouldn't be doing in the first place.
Browsers aren't supposed to accept HSTS on self-signed certs so connecting to a self signed localhost shouldn't do this.
There's nothing against self signed certificates working with HSTS at all. It's perfectly fine for browsers to accept HSTS regardless of who signed it.
Actually, there is.
Section 8.1 of RFC 6797 opens with:
"If an HTTP response, received over a secure transport, includes an STS header field, conforming to the grammar specified in Section 6.1, and there are no underlying secure transport errors or warnings (see Section 8.4), [...]"
Section 8.4 then goes on to define "errors or warnings" as including any errors caused by UA certificate validity checks.
Additionally, section 14.3 opens with:
"The user agent processing model defined in Section 8 stipulates that a host is initially noted as a Known HSTS Host, or that updates are made to a Known HSTS Host's cached information, only if the UA receives the STS header field over a secure transport connection having no underlying secure transport errors or warnings."
(and then goes on to provide the rationale for this decision)
> It's perfectly fine for browsers to accept HSTS regardless of who signed it.
No, it isn't. This enables active attackers to cause a permanent denial of service even when you subsequently move out of their reach. That's the rationale.
Wait, Chrome is now requiring HSTS for localhost?
If you point it at https://localhost/ and the cert is valid (e.g. you installed a private CA and used it to sign a cert for localhost) and the site serves an HSTS header, yes. Like any other hostname.People who set up an HTTPS dev environment and have it send an HSTS header and then get annoyed when it behaves exactly as designed (and they know it) are rather out of touch, in my opinion. If you don't want the browser to force HTTPS, don't tell it to.
Chrome 78 is like 25 releases ago, so nothing new here, they’re not requiring HSTS for localhost now, or ever, hopefully. Whoever the hell decides to force an HTTPS connection to localhost with an HSTS header have themselves to blame. localhost is a secure context without HTTPS.
Its not like I care about a mitm attack on my own computer or what if I am on 192 or 10.0 ? Isn't that inherently a non-internet access so why don't these scary warnings ingnore local devices? I know I can set up a CA for my nginx test or apache but why? What benefit other than " inculcating a habit"?
I mean I run home assistant and grafana in my local network but android tells me often its "unsafe"
Actual localhost traffic that never leaves your machine.... yeah, I can't think of a case where that would ever matter. If something can intercept that you have bigger problems:)
Unless you run
ssh servera -L 8080:serverb:80
I sometimes do this if there's a firewalled serverb that I can't access that's running a webserver, and a non-firewalled servera that I have ssh access and can access serverb.
Then you can open http://localhost in your browser and talk to serverb. If you want HTTPS to work, then ideally you'll map serverb to 127.0.0.1 in your /etc/hosts so that its HTTPS certificate matches the host, or use --host-resolver-rules="MAP serverb 127.0.0.1" as a Chrome commandline flag. Of course then you're no longer using localhost in the host.
that data wont be leaving my subnet if at all anything more so whats the threat model for a local only service?
also, i am not talking about "critical infra"
If you configure your server to send a HSTS header, though, you're telling your browser to only trust HTTPS connections for that domain from then on. That's what's happening here, and that's something you just… shouldn't do, I guess? If I tell my browser to permanently redirect localhost to Google.com, there's no reason why I should be mad at my browser for listening to my perma redirect.
HTTP traffic is a bigger problem in huge, flat, corporate networks, running intranet services with routes spanning several locations. At any time a hacker could be listening in an exfiltrating company logins. Also think about the Snowden slides, where the NSA intercepted unencrypted traffic over Google's internal network. Local network encryption is essential in those use cases and relatively easy to set up.
That's not localhost. One threat model is some IoT device you have attached to your wifi gets hacked. Or your wifi has a weak password and it gets hacked. Or a guest that you let onto your wifi has a devices that's been hacked.
>So it's an unlikely threat model for most people, but it is real.
today, what kind of local network service can a person set up that people can intercept and snoop on? its not like i am talking about accessing payment gateways or anything, just local services. if there is something that "needs" security, dont you think the technically inclined would have it on that and leave the rest as is because its a bit more effort for what benefit?
Plus, what’s the benefit of encrypting on a loopback connection? Who’s intercepting?
for the non-specialists here is an overview of the topic https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security