Repository navigation
Description
Version: 0.22.0 (the same code is on main at 8af4679)
What happens
When a query arrives with a source port other than 5353, send_response (service_daemon.rs, is_legacy_querier) answers by unicast to the query's source address and port. It does not check that the source address is on the local link: matched_source already looks for an interface address whose subnet contains the querier, but a None there still sends the answer. That path also skips the once-per-second multicast rate limit, which is expected for legacy unicast but leaves nothing to limit it.
A query for a registered service type gets PTR, SRV, TXT and A/AAAA records back. With a TXT record of a few hundred bytes (IPP Everywhere and eSCL records are about 500 bytes), the answer is many times the size of the query.
Why it matters
The socket listens on port 5353 of every address of the interfaces it uses, so a unicast query sent to the host's address works as well as a multicast one. On a host where one of those interfaces is reachable from outside the link (a public address, a VPN, a routed network), anyone can send a small query with a forged source address and have the daemon send the larger answer to that address, repeatedly. The interface filter does not help when the reachable interface is one the daemon is meant to announce on.
What RFC 6762 says
Section 5.5 (Direct Unicast Queries to Port 5353):
Since it is possible for a unicast query to be received from a machine outside the local link, responders SHOULD check that the source address in the query packet matches the local subnet for that link (or, in the case of IPv6, the source address has an on-link prefix) and silently ignore the packet if not.
Section 11 adds that "a responder SHOULD avoid generating responses that it can reasonably predict will be ignored", and queriers discard unicast responses from outside their subnet.
Suggested fix
- When the query was received on a unicast destination address, or is answered by unicast (legacy querier or QU question), drop it if the source address is not in a subnet of the receiving interface (
valid_ip_on_intf, asmatched_sourcealready does) and, for IPv6, not link-local. - Optionally, an option to allow answering off-link queriers for the specialized setups section 5.5 mentions.
Workaround
Firewall UDP 5353 from outside the local network, and limit the daemon to the LAN interface with disable_interface/enable_interface.
Activity
fix(server): ignore mDNS queries from off-link sources
fix: ignore unicast queries from off-link sources (RFC 6762 section 5.5)