Repository navigation
fix: ignore unicast queries from off-link sources (RFC 6762 section 5.5) - #559
Merged
keepsimple1 merged 2 commits intoNov 30, 2026
Merged
keepsimple1 merged 2 commits into
keepsimple1 merged 2 commits into
Conversation
AlixANNERAUD
added a commit
to AlixANNERAUD/recto
that referenced
this pull request
Nov 23, 2026
mdns-sd 0.22 answers a query sent to the host's own address from any source address, with an answer about twenty times its size, so a spoofed query from the internet could make recto flood someone else (keepsimple1/mdns-sd#558). Build with the fix, keepsimple1/mdns-sd#559, pinned by commit from the owner's fork until a release includes it, and allow that git source in cargo-deny. The discovery guide, the security model and the configuration reference no longer describe the amplification, and still advise firewalling UDP 5353 and naming the LAN interface.
3 tasks
keepsimple1
reviewed
Nov 25, 2026
keepsimple1
left a comment
Owner
There was a problem hiding this comment.
Thanks for your PR! The changes look good.
One nit is: if possible, add another test to cover the actual path in handle_read, it will be great. That's not blocking.
Also, we actually have a pending PR #532 that overlaps with this one, waiting on the author. This is FYI, will not block this PR.
I should be able to approve once the conflict with the latest main branch is resolved.
A query sent to one of our unicast addresses can come from outside the local link, with any source address. Answering it sends our records, many times the size of the query, to that address. Drop such a query unless its source is on a subnet of the receiving interface or is an IPv6 link-local address. Queries sent to the mDNS group are on-link whatever their source (section 11) and are handled as before. Fixes keepsimple1#558.
AlixANNERAUD
force-pushed
the
fix/ignore-off-link-unicast-queries
branch
from
November 25, 2026 09:35
2628df0 to
706df56
Compare
Contributor
Author
|
Thanks for the review!
Thanks for the pointer to #532. I am happy to adjust this PR if you prefer to combine the two. |
The new test sends the same unicast query to the daemon on 127.0.0.1 from two sources. A datagram to 127.0.0.1 arrives on the loopback interface, so 127.0.0.1 is an on-link source and the address of another interface is an off-link source. The daemon must answer the first query and ignore the second. The test uses its own port: with SO_REUSEPORT, a unicast datagram reaches only one of the sockets that share a port. The test does not run on Windows, which refuses to send a datagram from a non-loopback address to 127.0.0.1.
AlixANNERAUD
force-pushed
the
fix/ignore-off-link-unicast-queries
branch
from
November 25, 2026 09:39
706df56 to
32151b2
Compare
keepsimple1
approved these changes
Nov 30, 2026
keepsimple1
left a comment
Owner
There was a problem hiding this comment.
LGTM, thanks! I will handle PR #532 separately.
This was referenced Dec 2, 2026
keepsimple1
added a commit
that referenced
this pull request
Dec 2, 2026
`handle_query` decides whether and what to answer, so the RFC 6762 section 5.5 source check belongs there. It now takes the destination address of the query and runs is_off_link_unicast (from #559) before anything else, including probe tiebreaking. Queries sent to the mDNS group are still answered whatever their source. --------- Co-authored-by: roy <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #558.
A query sent to one of the daemon's unicast addresses can come from outside the local link, with any source address. The daemon answers it (by unicast to a legacy querier), so a small spoofed query sends PTR, SRV, TXT and address records, many times its size, to whatever address it claims.
RFC 6762 section 5.5 asks responders to check that the source of a unicast query is on the local subnet (for IPv6, has an on-link prefix) and to silently ignore it otherwise. Avahi does the same (
avahi-core/server.c, "Received non-local unicast query").Change
handle_readnow drops a query when:224.0.0.251orff02::fb): packets sent to the group are on-link whatever their source (section 11), so nothing changes for them;valid_ip_on_intf, assend_responsealready uses to pick a source address) and is not an IPv6 link-local address.Responses are not touched by this change.
Tests
test_off_link_unicast_queries_are_ignoredcovers on-link and off-link IPv4 and IPv6 sources, IPv6 link-local sources, and queries sent to the group from off-link sources.test_handle_read_ignores_off_link_unicast_queriescovers the path inhandle_read: it sends the same unicast query to the daemon on 127.0.0.1 from 127.0.0.1 (answered) and from the address of another interface (ignored, since the datagram arrives on the loopback interface). It fails when the check inhandle_readis removed. It does not run on Windows, which refuses to send from a non-loopback address to 127.0.0.1. Clippy (all features and none) and rustdoc are clean. On my machine the network tests that need multicast (such astest_legacy_unicast_response) fail with and without this change, so CI is the check for those.