Skip to content

access: match hosts allow/deny hostname tokens against IPv6 peers - #1140

Merged
steadytao merged 3 commits into
RsyncProject:masterfrom
scarabeusiv:access-getaddrinfo
Oct 26, 2026
Merged

steadytao merged 3 commits into
RsyncProject:masterfrom
scarabeusiv:access-getaddrinfo

Conversation

@scarabeusiv

Copy link
Copy Markdown
Contributor

match_hostname() forward-resolves hosts allow/hosts deny hostname tokens with gethostbyname(), 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: in hosts allow, a client whose address is the name's AAAA record is denied anyway (#563); in hosts 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 via inet_ntop, mirroring match_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-ip and daemon-deny-dns-failopen pass.

Spotted by rpmcrab's binary-or-shlib-calls-gethostbyname check (the Rust successor to rpmlint) while auditing the openSUSE rsync package.

Fixes #563.

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.
Comment thread access.c Outdated
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.
@scarabeusiv

Copy link
Copy Markdown
Contributor Author

Thanks — all three points addressed in 84c9292:

  1. The IPv6 matching now sits under #ifdef INET6.
  2. The peer address is parsed once with getaddrinfo(AI_NUMERICHOST) and compared in binary form by address family (memcmp over the family-matched sockaddr), mirroring match_address() — no inet_ntop string comparison remains in the hostname path.
  3. New regression: testsuite/daemon-access-hostname_test.py covers IPv4 and IPv6 hostname allow/deny, forward lookup = no (deny wins), and unresolvable tokens (deny fails closed, allow doesn't match). All cases run with reverse lookup = no so only the forward path can match.

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
steadytao merged commit 7472f8d into RsyncProject:master Oct 26, 2026
21 checks passed
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.

rsyncd.conf 'host allow' entries don't work properly for DNS entries with IPV6 addresses

2 participants