Skip to content

fix: check for off-link query sources in handle_query - #563

Merged
keepsimple1 merged 3 commits into
mainfrom
fix/off-link-check-in-handle-query
Dec 2, 2026
Merged

keepsimple1 merged 3 commits into
mainfrom
fix/off-link-check-in-handle-query

Conversation

@keepsimple1

@keepsimple1 keepsimple1 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

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 in handle_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) calls handle_query directly: 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 needs 127.0.0.2, so it runs on every platform. It fails when the check is disabled.
  • test_link_local_sources_are_on_link is dropped with is_on_link. test_off_link_unicast_queries_are_ignored covers the fe80::/10 case.
  • test_handle_read_ignores_off_link_unicast_queries from fix: ignore unicast queries from off-link sources (RFC 6762 section 5.5) #559 is unchanged and still covers the full path through handle_read.

cargo fmt, clippy (all features and none), cargo doc and cargo +1.71.0 check --all-features are clean.

Closes #532.

aazf and others added 3 commits October 25, 2026 03:11
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.
@keepsimple1
keepsimple1 marked this pull request as ready for review December 2, 2026 05:40
@keepsimple1
keepsimple1 merged commit 97192af into main Dec 2, 2026
6 checks passed
@keepsimple1
keepsimple1 deleted the fix/off-link-check-in-handle-query branch December 2, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants