For years I’ve used /etc/hosts to adjust IP address. Sometimes it’s for prototyping, or adding an address for development purposes that isn’t ready to go into public DNS. And sometimes I block certain domains that I don’t want to visit by redirecting them to incorrect IP addresses. Some are invasive tracking websites, e.g., connect.facebook.net. Others I keep blocked as an anti-procrastination measures, for example news sites such as politico.com which I might otherwise spend all day reading when I meant to be working.
But now on macOS 11 Big Sur, I notice that some /etc/hosts entries are ignored by Safari. DNS lookups with gethostbyname() correctly show the block/override address, but Safari displays the public site anyway.
What on earth is going on? What’s changed with /etc/hosts and can I keep using it to override DNS entries when doing development work?
macOS 11 added support for what is officially called “Service binding and parameter specification via the DNS (DNS SVCB and HTTPSSV)”.
Now, when you visit a website, it’s not just the typical DNS
Ahost-to-ip-address record that’s consulted, but a brand-newHTTPSDNS record is checked too. It’s not just a name entry; it’s a brand-new record type (#65), to go along with the more familiarAandCNAMEandMX.These new
HTTPSDNS records can indicate that the site supports HTTPS, including protocol versions and IP addresses. That way, typing in a bare domain name gives thehttps://version of the site right away, maybe even on HTTP/2 or HTTP/3, skipping the old-fashioned HTTP redirect. There’s even a draft option for domain operators to tell your computer to bypass any local DNS settings and use a specific server for all future DNS queries involving their domain.There are many pro-performance intentions here, and some pro-privacy ones too.
But there is a fatal privacy and security flaw in both the specification and implementation: it removes the ability for users to override domain name lookups in
/etc/hosts, even when faced with actively malicious domain name operators.To see how this is working in action:
The version of
digthat comes with macOS doesn’t directly support these new records, but you can see whether they exist withI don’t know how to parse that, but wireshark does if I packet-capture it
So that’s what’s happening:
/etc/hosts, because it gets their IP addresses from these newHTTPSrecordsFor now, you can keep using
/etc/hostsfor domain names that you fully control.In the meantime, for other domains, you have some options:
/etc/hostsChrome has run some trials for this but does not appear to have implemented it yet. Firefox has started implementing it but doesn’t seem to have gotten too far.