Repository navigation
access: match hosts allow/deny hostname tokens against IPv6 peers - #1140
Merged
Merged
Conversation
match_hostname() resolved hostname tokens with gethostbyname(), which only returns IPv4 addresses, so a hostname token never matched an IPv6 peer: allow entries locked such clients out and deny entries silently failed open. Resolve with getaddrinfo(PF_UNSPEC) instead, mirroring match_address() in the same file. Fixes RsyncProject#563.
steadytao
requested changes
Oct 26, 2026
Address review feedback on the getaddrinfo conversion: parse the peer address once and compare each resolved address against it byte-wise within the same family, as match_address() does, instead of comparing inet_ntop() strings; keep the IPv6 cases under #ifdef INET6 so a --disable-ipv6 build compiles the IPv4 path only. Add daemon-access-hostname regressions: hostname-token allow and deny over IPv4 and IPv6 (with reverse lookup off, so only the forward path can match), forward lookup disabled, and unresolvable allow/deny tokens.
Contributor
Author
|
Thanks — all three points addressed in 84c9292:
Verified: warning-free builds with and without INET6 (--disable-ipv6); the new test plus daemon-access-ip, daemon-access-idn, daemon and daemon-config pass; the new test fails on pre-PR master (at the IPv6 allow case), pinning the defect. One caveat: on loopback the string and binary forms render identically, so the test can't distinguish point 2's comparison form — that change follows the requested idiom rather than a test-visible behaviour difference. |
steadytao
approved these changes
Oct 26, 2026
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.
match_hostname()forward-resolveshosts allow/hosts denyhostname tokens withgethostbyname(), which only returns IPv4 addresses, and string-compares them against the peer's numeric address. For an IPv6 peer the comparison can never succeed, so a hostname token is dead in both lists: inhosts allow, a client whose address is the name's AAAA record is denied anyway (#563); inhosts deny, the same client is admitted — the deny rule silently fails open for IPv6, the failure class CVE-2026-70452 closed for unresolvable tokens.Resolve the token with
getaddrinfo()(PF_UNSPEC) instead and compare each result viainet_ntop, mirroringmatch_address()in the same file. IPv4 behaviour is unchanged; the only semantics change is that AAAA results now take part in the match. Failure to resolve keeps the existing behaviour (deny tokens fail closed, allow tokens fail as a non-match).Verified with a loopback daemon (
hosts allow/hosts deny=localhost, clients over 127.0.0.1 and ::1): before, IPv6 was denied by the allow rule and admitted past the deny rule; after, both rules apply to both families.daemon-access,daemon-access-ipanddaemon-deny-dns-failopenpass.Spotted by rpmcrab's
binary-or-shlib-calls-gethostbynamecheck (the Rust successor to rpmlint) while auditing the openSUSE rsync package.Fixes #563.