|
Message-ID: <20240308225445.GR4163@brightrain.aerifal.cx> Date: Fri, 8 Mar 2024 17:54:45 -0500 From: Rich Felker <dalias@...c.org> To: David Schinazi <dschinazi.ietf@...il.com> Cc: musl@...ts.openwall.com Subject: Re: mDNS in musl On Fri, Mar 08, 2024 at 01:55:18PM -0800, David Schinazi wrote: > On Fri, Mar 8, 2024 at 12:31 PM Rich Felker <dalias@...c.org> wrote: > > > On Fri, Mar 08, 2024 at 11:15:52AM -0800, David Schinazi wrote: > > > On Fri, Mar 8, 2024 at 5:30 AM Rich Felker <dalias@...c.org> wrote: > > > > > > > On Thu, Mar 07, 2024 at 08:47:20PM -0800, David Schinazi wrote: > > > > > Thanks. How would you feel about the following potential > > configuration > > > > > design? > > > > > * Add a new configuration option "send_mdns_unicast" > > > > > * When true, use the current behavior > > > > > * When false, send the query on all non-loopback non-p2p interfaces > > > > > * Have send_mdns_unicast default to false > > > > > > > > > > I was thinking through how to pick interfaces, looked up what other > > mDNS > > > > > libraries do, and pretty much all of them don't allow configuring > > > > > interfaces, whereas Avahi exposes allow-interfaces and > > deny-interfaces. > > > > I'm > > > > > leaning towards not making this configurable to reduce complexity. I > > > > think > > > > > that anyone interested in that level of config is probably using > > Avahi > > > > > anyway. > > > > > > > > > > Additionally this design has two nice properties: the default > > behavior is > > > > > RFC-compliant, and it means that for my use-case I don't need to > > change > > > > the > > > > > config file, which was a big part of my motivation for doing this > > inside > > > > of > > > > > musl in the first place :-) > > > > > > > > As discussed in this thread, I don't think so. The biggest problems I > > > > initially brought up were increased information leakage in the default > > > > configuration and inability to control where the traffic goes when you > > > > do want it on. The above proposal just reverts to the initial, except > > > > for providing a way to opt-out. > > > > > > > > For the most part, mDNS is very much a "home user, personal device on > > > > trusted network" thing. Not only do you not want it to default on > > > > because a lot of systems will be network servers on networks where > > > > it's not meaningful (and can be a weakness that aids attackers in > > > > lateral movement), but you also don't want it on when connected to > > > > public wifi. For example if you have an open browser tab to > > > > http://mything.local, and migrate to an untrusted network (with your > > > > laptop, tablet, phone, whatever), now your browser will be leaking > > > > private data (likely at least session auth tokens, maybe more) to > > > > whoever answers the mDNS query for mything.local. > > > > > > That's not quite right. The security properties of mDNS and DNS are the > > > same. DNS is inherently insecure, regardless of unicast vs multicast. If > > > I'm on a coffee shop Wi-Fi, all my DNS queries are sent in the clear to > > > whatever IP address the DHCP server gave me. > > > > That's not the case. Connections to non-mDNS hosts are authenticated > > by TLS with certificates issued on the basis of ownership of the > > domain name. That's not possible with mDNS hostnames, so they'll > > either be no-TLS or self-signed certs. That's why the above attack is > > possible. It was also possible with normal DNS in the bad old days of > > http://, but that time is long gone. > > Apologies for being pedantic, but that's not true. The ability to get TLS > certificates for a domain name that you own is a property of the WebPKI, > not a property of TLS. What you wrote is true, but only in the context of a > Web browser with an unmodified root certificate store. The features I > mentioned above don't use the WebPKI, they have a separate root of trust. > For example, some of those Apple features exchange TLS certificates via an > out-of-band mechanism such as Apple trusted servers. Another example is the > Apple Watch: when you first pair a new Apple Watch with an iPhone, they > exchange ed25519 public keys. Then any time the watch wants to transfer a > large file to/from the phone, it'll connect to Wi-Fi, use mDNS to find the > phone, and set up an IKEv2/IPsec tunnel that then protects the exchange. > It's resilient to any attacks at the mDNS level. > > You're absolutely right that the security of Web requests using local > connectivity is completely broken by the lack of WebPKI certificates for > those. But sending the DNS query over multicast as opposed to unencrypted > unicast to an untrusted DNS server doesn't change the security properties. > In your example above, the open tab to http://mything.local will send that > query to the recursive resolver - and if that's the one received by DHCP > then that server can reply with its own address and receive your auth > tokens. One potential fix here is to configure your resolv.conf to > localhost and then apply policy in that local resolver. But in practice, > application developers don't rely on security at that layer, they assume > that DNS is unsafe and implement encryption in userspace with some out of > band trust mechanism. My specific example was http://mything.local in a web browser, which is the way you access lots of mDNS-enabled things in the absence of a specific software ecosystem like Apple's. Since we're talking about musl which would be running on Linux or a Linux-syscall-compatible environment, without Apple apps, I think that's the main way anyone would be using hypothetical mDNS support. And indeed this is the way you access many printers, 3D printers, IP cameras, etc. Maybe at some point we'll have a good framework for authenticating this kind of usage with certificates (probably certificate pinning on first use, with good UX, is the only easy solution), but at present, mDNS devices on the .local zone get accessed with plain http:// all the time, and this means it's unsafe to do mDNS on public/untrusted/hostile networks. > > So the stack has to deal with > > > the fact that any DNS response can be spoofed. > > > > That's also not possible with DNSSEC, but only helps if you're > > validating it. > > > > > The most widely used > > > solution is TLS: a successful DNS hijack can prevent you from accessing a > > > TLS service, but can't impersonate it. That's true of both mDNS and > > regular > > > unicast DNS. As an example, all Apple devices have mDNS enabled on all > > > interfaces, with no security impact - the features that rely on it > > > (AirDrop, AirPlay, contact sharing, etc) all use mTLS to ensure they're > > > talking to the right device regardless of the correctness of DNS. > > (Printing > > > remains completely insecure, but that's also independent of DNS - your > > > coffee shop Wi-Fi access point can attack you at the IP layer too). One > > > might think that DNSSEC could save us here, but it doesn't. DNSSEC was > > > unfortunately built with a fundamental design flaw: it requires you to > > > trust all resolvers on the path, including recursive resolvers. So even > > if > > > you ask for DNSSEC validation of the DNS records for www.example.com, > > your > > > coffee shop DNS recursive resolver can tell you "I checked, and > > example.com > > > does not support DNSSEC, here's the IP address for www.example.com > > though" > > > and you have to accept it. > > > > This is a completely false but somehow persistent myth about DNSSEC. > > You cannot lie that a zone does not support DNSSEC. The only way to > > claim a zone does not support DNSSEC is with a signature chain from > > the DNS root proving the nonexistence of the DS records for the > > delegation. Without that, the reply is BOGUS and will be ignored as if > > there was no reply at all. > > I was talking about the case where the recursive resolver does the > validation, which is what's deployed in practice today. What you wrote is > only true if the client does the DNSSEC validation itself. Most clients > don't do that today, because too many domains are just misconfigured and > broken. Eric Rescorla (the editor of the TLS RFCs) wrote a great blog post > about this: The consensus of folks in the stub resolver space (at least glibc+musl and I would assume the BSDs as well) is that the way you do DNSSEC validation is by having a validating caching proxy or full recursive resolver on localhost. Doing validation in the stub resolver is not viable because it may be static-linked, where it would not be able to be updated with new algorithms, root-of-trust, etc. This is one of the reasons our go-to response for new functionality wanted in the stub resolver is "do it in a nameserver on localhost" -- because you already need that to do DNSSEC. It really did not sound like you were talking about trusting the recursive, though. You called it a "fundamental design flaw", which it is not, and said it requires you to "trust all resolvers on the path", which it does not. It only requires you to trust the immediate resolver you are interacting with (and not even that if you put the validation in the stub resolver, but there are good reasons not to do that, as above). A pure-proxying server that relies on upstream recursives can do full DNSSEC validation. Dnsmasq is a canonical example. I believe systemd-resolvd also does it. > > > Regarding untrusted networks, one thing I hadn't considered yet is > > > > that a network configurator probably needs a way to setup resolv.conf > > > > such that .local queries temp-fail rather than perma-fail (as they > > > > would if you just sent the query to public dns) to use during certain > > > > race windows while switching networks. IOW "send .local queries to > > > > configured nameservers" and "treat .local specially but with an empty > > > > list of interfaces to send to" should be distinct configurations. > > > > > > Yeah, caching negative results in DNS has been a tricky thing from the > > > start. You probably could hack something by installing a fake SOA record > > > for .local. in your recursive resolver running on localhost. But the > > > RFC-compliant answer is for stub resolvers to treat it specially and know > > > that those often never get an answer (musl doesn't cache DNS results so > > in > > > a way we're avoiding this problem altogether at the stub resolver). > > > > The problem here is not about caching, just about clients using a > > response. You want a task (like a browser with open tabs) trying to > > contact the site to get a tempfail rather than NxDomain which might > > make it stop trying. But you probably want NxDomain if mDNS has been > > disabled entirely, so that every .local lookup doesn't hang 5 seconds > > or whatever before saying "inconclusive". > > I'm assuming that by tempfail you mean EAI_AGAIN. The two browsers that > I've written code in don't use that (Chrome just treats it the same as a > resolution failure and will automatically refresh the tab on a network > change; Safari doesn't use getaddrinfo and instead relies on an > asynchronous DNS API that adds results as they come in - I wrote that > algorithm up in RFC 8305). All that said, synchronous blocking APIs like > getaddrinfo need to eventually return even if no one replies, so EAI_AGAIN > makes sense in that case - whereas if .local is blocked by policy then > immediately returning EAI_NONAME is best. Right. Even if applications don't currently distinguish them well, returning EAI_AGAIN vs EAI_NONAME is meaningful and enables them to do the right thing. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.