Repository navigation
fix: check for off-link query sources in handle_query - #563
Merged
Merged
Conversation
RFC 6762 section 11 (Source Address Check) says a responder should not answer a query whose source is not on the local link. Multicast queries cannot cross a router, so such a query was sent to this host's unicast address from elsewhere; answering it, in particular with a legacy unicast response to an arbitrary address and port, makes the host a reflector for spoofed queries when it has a routed address. handle_query now drops a query unless its source lies in a subnet of one of the receiving interface's addresses, or is a link-local address (169.254.0.0/16, fe80::/10), which is on-link by definition.
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. This replaces is_on_link and its 169.254/16 exemption: RFC 6762 section 11 defines the IPv4 check as the subnet comparison only. test_query_from_off_link_source_is_not_answered now calls handle_query directly with each source and destination, so it needs no 127.0.0.2 and runs on every platform. The fe80::/10 case is covered by test_off_link_unicast_queries_are_ignored.
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.
Builds on #532 by @aazf, which keeps its original commit here. A maintainer can't push to #532's branch because it lives in a fork owned by an organization, so this PR carries it forward.
#559 added the RFC 6762 section 5.5 check for unicast queries from off-link sources in
handle_read. #532 checked inhandle_query, which is where the daemon decides whether and what to answer. This PR moves the check from #559 to the place #532 chose.Tests
test_query_from_off_link_source_is_not_answered(from Ignore queries from sources that are not on the link #532, rewritten) callshandle_querydirectly: an on-link source to our unicast address is answered, an off-link source is ignored, and an off-link source to the mDNS group is answered. It counts deferred answers, so nothing is sent, and it no longer needs127.0.0.2, so it runs on every platform. It fails when the check is disabled.test_link_local_sources_are_on_linkis dropped withis_on_link.test_off_link_unicast_queries_are_ignoredcovers thefe80::/10case.test_handle_read_ignores_off_link_unicast_queriesfrom fix: ignore unicast queries from off-link sources (RFC 6762 section 5.5) #559 is unchanged and still covers the full path throughhandle_read.cargo fmt, clippy (all features and none),cargo docandcargo +1.71.0 check --all-featuresare clean.Closes #532.