Skip to content

fix: address GHSA-rjfm-3w2m-jf4f hostname ACL bypass during chroot - #5524

Merged
oferchen merged 1 commit into
masterfrom
fix/uts-22b-daemon-chroot-acl-ghsa
Jun 10, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/uts-22b-daemon-chroot-acl-ghsa

Conversation

@oferchen

@oferchen oferchen commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the hostname-based ACL bypass tracked as GHSA-rjfm-3w2m-jf4f / CVE-2026-43617. A peer connecting to a daemon configured with daemon chroot and a hostname-based hosts deny rule was silently admitted whenever post-chroot reverse DNS failed - the chroot typically lacks /etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts, and the NSS shared objects, so lookup_addr() returned None, the Hostname(_) matcher could not prove the peer matched the pattern, and the deny check fell through. An attacker who controls their PTR record (or simply blackholes reverse DNS) could connect from a hostname the operator explicitly intended to block.

Upstream patch

Upstream rsync 3.4.3 (commit c38f20c5) moves the reverse DNS lookup to before chroot/setuid in the per-connection start_daemon(), relying on client_name()'s internal cache so the post-chroot ACL evaluation uses the cached value.

oc-rsync parity fix

oc-rsync uses a thread-per-connection model where daemon chroot is applied process-wide at startup (accept_loop.rs::serve_connections), before any peer connects. Worker threads inherit the chroot, so there is no per-connection moment "before this connection's chroot" in which to resolve a specific peer.

Rather than re-architect the accept loop, this PR tightens the ACL matcher itself:

// crates/daemon/src/daemon/module_state/definition.rs
if hostname.is_none()
    && self
        .hosts_deny
        .iter()
        .any(|pattern| pattern.requires_hostname())
{
    return false;
}

When reverse DNS returns None and any hosts deny rule is hostname-based, permits() fails closed. The hostname-pattern presumes a working resolver; if it is missing, the safe-by-default posture is to refuse the connection rather than admit it. The change has zero effect on:

  • IP-only deny rules (CIDR/exact-address) - the deny check still runs on the IP unchanged.
  • hosts allow rules - already fail-closed when no allow pattern matches.
  • Resolvable peers - the existing matcher runs unmodified.

The session- and module-level reverse DNS calls in session_runtime.rs / module_access::request.rs / module_access::listing.rs still run before per-module use chroot, mirroring upstream's "resolve before chroot" intent for the per-module path; the new guard catches the residual daemon chroot global-directive path where pre-resolution is architecturally impossible.

Regression tests

  • module_hostname_deny_fails_closed_when_dns_unresolved mirrors Scenario A of upstream's testsuite/daemon-chroot-acl.test: configure hosts deny = *.bad.example, simulate the post-chroot DNS failure via the test override, and assert permits() rejects the peer.
  • module_ip_deny_unaffected_by_dns_failure pins the scope of the fail-closed guard: a module with an IP-only deny rule (192.0.2.0/24) must continue to admit peers outside the denied range even when their reverse DNS fails, and must continue to deny peers inside the range.

SECURITY.md

Updated the CVE-2026-43617 row from "Not vulnerable" to Fixed, documents the daemon chroot global-directive path that the previous assessment missed, and cross-references the new regression tests.

Test plan

  • cargo nextest run -p daemon --all-features -E 'test(module_hostname_deny_fails_closed_when_dns_unresolved) | test(module_ip_deny_unaffected_by_dns_failure) | test(module_peer_hostname_resolution_before_chroot_denies_unknown) | test(module_definition_hostname_deny_takes_precedence) | test(module_definition_mixed_ip_and_hostname_acl)' - CI verifies.
  • CI: fmt+clippy, nextest (stable), Windows (stable), macOS (stable), Linux musl (stable).

Constraints respected

  • No changes to crates/branding/.
  • No changes to wire protocol or oc-rsync-specific features (parallel-receive-delta, io_uring, IOCP, flat-flist, daemon-tls, DirSandbox, SEND_ZC, flat arena flist).
  • Daemon-only scope.
  • No new unsafe code; daemon crate retains #![deny(unsafe_code)].
  • No #[allow(clippy::...)] waivers.

Hostname-based `hosts deny` rules silently fail-OPEN when the daemon
runs under `daemon chroot` and the chroot lacks NSS configuration
(/etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts, NSS shared
objects). Per-connection reverse DNS runs inside the chroot, returns
nothing, and the matcher cannot prove the peer's name matches the
deny pattern, so the connection is admitted. An attacker who
controls their PTR record (or simply blackholes reverse DNS) can
bypass a hostname-pattern deny rule.

Upstream rsync 3.4.3 (commit c38f20c5) closes the bug by moving the
reverse DNS lookup to before chroot/setuid in the per-connection
`start_daemon()`, relying on `client_name()`'s internal cache so the
post-chroot ACL evaluation uses the cached value. oc-rsync uses a
thread-per-connection model where the `daemon chroot` directive is
applied process-wide at startup, before any peer connects, so the
upstream "resolve before the chroot in this connection" sequence is
not available - by the time a worker thread sees a new peer, the
process is already chrooted.

Fix: tighten `ModuleDefinition::permits` to fail closed when reverse
DNS returns `None` and any `hosts deny` rule is hostname-based.
Hostname-pattern deny rules already presume the resolver works; if
it does not, the safe-by-default posture is to refuse the connection
rather than admit it. IP-only deny rules and pure allow rules are
unaffected.

Regression tests:
- `module_hostname_deny_fails_closed_when_dns_unresolved` mirrors
  Scenario A of upstream's testsuite/daemon-chroot-acl.test.
- `module_ip_deny_unaffected_by_dns_failure` pins down that the
  fail-closed guard activates only for hostname-pattern deny rules.

SECURITY.md updated to mark CVE-2026-43617 / GHSA-rjfm-3w2m-jf4f as
Fixed and describe the daemon-chroot path that the previous "Not
vulnerable" assessment missed.
@github-actions github-actions Bot added the bug Something isn't working label Jun 9, 2026
@oferchen
oferchen merged commit 50f389f into master Jun 10, 2026
77 checks passed
@oferchen
oferchen deleted the fix/uts-22b-daemon-chroot-acl-ghsa branch June 10, 2026 05:07
oferchen added a commit that referenced this pull request Jun 11, 2026
oferchen added a commit that referenced this pull request Aug 24, 2026
…5524)

Hostname-based `hosts deny` rules silently fail-OPEN when the daemon
runs under `daemon chroot` and the chroot lacks NSS configuration
(/etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts, NSS shared
objects). Per-connection reverse DNS runs inside the chroot, returns
nothing, and the matcher cannot prove the peer's name matches the
deny pattern, so the connection is admitted. An attacker who
controls their PTR record (or simply blackholes reverse DNS) can
bypass a hostname-pattern deny rule.

Upstream rsync 3.4.3 (commit c38f20c5) closes the bug by moving the
reverse DNS lookup to before chroot/setuid in the per-connection
`start_daemon()`, relying on `client_name()`'s internal cache so the
post-chroot ACL evaluation uses the cached value. oc-rsync uses a
thread-per-connection model where the `daemon chroot` directive is
applied process-wide at startup, before any peer connects, so the
upstream "resolve before the chroot in this connection" sequence is
not available - by the time a worker thread sees a new peer, the
process is already chrooted.

Fix: tighten `ModuleDefinition::permits` to fail closed when reverse
DNS returns `None` and any `hosts deny` rule is hostname-based.
Hostname-pattern deny rules already presume the resolver works; if
it does not, the safe-by-default posture is to refuse the connection
rather than admit it. IP-only deny rules and pure allow rules are
unaffected.

Regression tests:
- `module_hostname_deny_fails_closed_when_dns_unresolved` mirrors
  Scenario A of upstream's testsuite/daemon-chroot-acl.test.
- `module_ip_deny_unaffected_by_dns_failure` pins down that the
  fail-closed guard activates only for hostname-pattern deny rules.

SECURITY.md updated to mark CVE-2026-43617 / GHSA-rjfm-3w2m-jf4f as
Fixed and describe the daemon-chroot path that the previous "Not
vulnerable" assessment missed.
oferchen added a commit that referenced this pull request Aug 24, 2026
Audit confirms commit 23f97c7 (PR #5524) closes the daemon-chroot
hostname ACL bypass with fail-closed semantics in
ModuleDefinition::permits, three regression tests, and a SECURITY.md
status update. No follow-up sub-task required under UTS-22.b; parent
UTS-22 stays open on UTS-22.a.
oferchen added a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant