Repository navigation
fix: daemon-access module sub-path and access-rule edge cases - #5526
Merged
Merged
Conversation
upstream rsync's `access.c::allow_access()` short-circuits on the first
allow-list match and returns 1 unconditionally - "If we match an allow-
list item, we always allow access." The deny list is consulted only when
the allow list is absent or did not match. oc-rsync's
`ModuleDefinition::permits` instead evaluated allow then deny in series,
so a peer that matched both an allow and a deny pattern was refused.
That divergence breaks any daemon config that uses an inclusive
`hosts allow = *` together with surgical hostname-pattern deny rules,
and silently rejects connections the upstream testsuite expects to be
accepted.
Reorder `permits` to match `access.c:264` exactly:
1. allow-list non-empty + peer matches any allow pattern -> permit
(deny list is never consulted)
2. allow-list non-empty + no match + empty deny list -> refuse
3. otherwise fall through to the deny check; deny match -> refuse,
no match -> permit
The GHSA-rjfm-3w2m-jf4f fail-closed guard stays on the deny path. The
guard refuses peers with unresolved hostnames only when at least one
deny rule is hostname-based; a peer that has already won the allow
short-circuit is admitted regardless of DNS state, which matches
upstream's behaviour and avoids false rejection of perfectly-allowed
peers in chroot configurations.
Tests:
- `module_definition_allow_match_short_circuits_deny` and
`module_definition_deny_applies_when_allow_does_not_match` replace the
bogus `deny_takes_precedence_over_allow` expectation in the
module_state unit tests.
- `module_definition_allow_short_circuit_skips_dns_fail_closed_guard`
pins the interaction with the GHSA-rjfm-3w2m-jf4f guard.
- `module_definition_matches_upstream_rsync_fns_allow_list` reproduces
the upstream testsuite's standard `hosts allow = localhost
127.0.0.0/24 192.168.0.0/16 10.0.0.0/8 $hostname` configuration from
`testsuite/rsync.fns:381` and pins CIDR matching against it.
- Updates `module_definition_ipv4_allow_deny_precedence`,
`module_definition_hostname_deny_takes_precedence`, and
`module_definition_mixed_ip_and_hostname_acl` chunks to express the
upstream semantics they previously contradicted.
- Existing GHSA fail-closed regressions
(`module_hostname_deny_fails_closed_when_dns_unresolved`,
`module_ip_deny_unaffected_by_dns_failure`) remain green because the
guard still fires on the deny path when the allow list does not match.
The regression test expected refusal when a peer matches neither allow nor deny lists, but upstream access.c:281-291 only refuses non-matching peers when no deny list is configured; with a deny list present, fall through allows unmatched peers (access.c:290-291).
2 tasks
The chunk-file copy of module_definition_ipv4_allow_short_circuits_deny in tests/chunks/ still encoded the pre-upstream 'allow-list non-match refuses' assertion that the module_state unit tests already corrected. With both an allow list and a deny list set, upstream allow_access (access.c:287-291) refuses only on a positive deny-list match and otherwise falls through to 'Allow all other access'. A peer outside both subnets is therefore admitted, not refused. Flip the third assertion to permits(...) and reference the upstream line range. Brings the chunk into sync with module_state/tests.rs and the new permits() implementation so Windows feature-flag combinations and Linux musl (beta) stop tripping the assertion.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
* fix: align hosts allow/deny with upstream allow_access semantics
upstream rsync's `access.c::allow_access()` short-circuits on the first
allow-list match and returns 1 unconditionally - "If we match an allow-
list item, we always allow access." The deny list is consulted only when
the allow list is absent or did not match. oc-rsync's
`ModuleDefinition::permits` instead evaluated allow then deny in series,
so a peer that matched both an allow and a deny pattern was refused.
That divergence breaks any daemon config that uses an inclusive
`hosts allow = *` together with surgical hostname-pattern deny rules,
and silently rejects connections the upstream testsuite expects to be
accepted.
Reorder `permits` to match `access.c:264` exactly:
1. allow-list non-empty + peer matches any allow pattern -> permit
(deny list is never consulted)
2. allow-list non-empty + no match + empty deny list -> refuse
3. otherwise fall through to the deny check; deny match -> refuse,
no match -> permit
The GHSA-rjfm-3w2m-jf4f fail-closed guard stays on the deny path. The
guard refuses peers with unresolved hostnames only when at least one
deny rule is hostname-based; a peer that has already won the allow
short-circuit is admitted regardless of DNS state, which matches
upstream's behaviour and avoids false rejection of perfectly-allowed
peers in chroot configurations.
Tests:
- `module_definition_allow_match_short_circuits_deny` and
`module_definition_deny_applies_when_allow_does_not_match` replace the
bogus `deny_takes_precedence_over_allow` expectation in the
module_state unit tests.
- `module_definition_allow_short_circuit_skips_dns_fail_closed_guard`
pins the interaction with the GHSA-rjfm-3w2m-jf4f guard.
- `module_definition_matches_upstream_rsync_fns_allow_list` reproduces
the upstream testsuite's standard `hosts allow = localhost
127.0.0.0/24 192.168.0.0/16 10.0.0.0/8 $hostname` configuration from
`testsuite/rsync.fns:381` and pins CIDR matching against it.
- Updates `module_definition_ipv4_allow_deny_precedence`,
`module_definition_hostname_deny_takes_precedence`, and
`module_definition_mixed_ip_and_hostname_acl` chunks to express the
upstream semantics they previously contradicted.
- Existing GHSA fail-closed regressions
(`module_hostname_deny_fails_closed_when_dns_unresolved`,
`module_ip_deny_unaffected_by_dns_failure`) remain green because the
guard still fires on the deny path when the allow list does not match.
* test: align deny-fallthrough test with upstream access.c semantics
The regression test expected refusal when a peer matches neither allow nor deny lists, but upstream access.c:281-291 only refuses non-matching peers when no deny list is configured; with a deny list present, fall through allows unmatched peers (access.c:290-291).
* test: align ipv4 allow/deny chunk test with upstream access.c
The chunk-file copy of module_definition_ipv4_allow_short_circuits_deny
in tests/chunks/ still encoded the pre-upstream 'allow-list non-match
refuses' assertion that the module_state unit tests already corrected.
With both an allow list and a deny list set, upstream allow_access
(access.c:287-291) refuses only on a positive deny-list match and
otherwise falls through to 'Allow all other access'. A peer outside
both subnets is therefore admitted, not refused.
Flip the third assertion to permits(...) and reference the upstream
line range. Brings the chunk into sync with module_state/tests.rs and
the new permits() implementation so Windows feature-flag combinations
and Linux musl (beta) stop tripping the assertion.
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.
Summary
ModuleDefinition::permits(thehosts allow/hosts denymatcher usedon every daemon connection) diverged from upstream rsync's
access.c::allow_access(). Upstream short-circuits on the first allow-list match - "If we match an allow-list item, we always allow access."
not match. oc-rsync instead evaluated allow and then deny in series, so
a peer matching both lists was refused. Any daemon config that pairs an
inclusive
hosts allow = *with surgical hostname-pattern deny rulessilently rejected connections the upstream testsuite expects to be
accepted (
testsuite/rsync.fns:381ships exactly this idiom for theshared
hosts allow = localhost 127.0.0.0/24 192.168.0.0/16 10.0.0.0/8 $hostnameconfiguration).What the fix does
Reorder
permitsto mirroraccess.c:264exactly:hosts allownon-empty and the peer matches any pattern -> permit(deny list never consulted).
hosts allownon-empty, no match, no deny list -> refuse.The GHSA-rjfm-3w2m-jf4f fail-closed guard (PR #5524) stays on the deny
path and is unchanged for its existing use cases. After the reorder it
no longer punishes peers who already cleared the allow short-circuit -
a peer admitted by
hosts allowis admitted regardless of reverse-DNSstate, which is what upstream does and what operators expect.
Upstream reference
target/interop/upstream-src/rsync-3.4.3/access.c:264-292definesallow_access. The comment on line 276 reads "If we match an allow-listitem, we always allow access."
testsuite/rsync.fns:352-411is theshared daemon configuration the testsuite assembles for every
daemon-related test (
daemon.test,daemon-refuse-compress.test,daemon-gzip-{upload,download}.test), and line 381 declares thehosts allowdirective that pins the matcher behaviour this PRrestores.
Regression tests
In
crates/daemon/src/daemon/module_state/tests.rs:module_definition_allow_match_short_circuits_deny- replaces thebogus
deny_takes_precedence_over_allowexpectation.module_definition_deny_applies_when_allow_does_not_match- exercisesthe fall-through path (allow miss + deny list present -> deny check
runs).
module_definition_allow_short_circuit_skips_dns_fail_closed_guard-pins the interaction with the GHSA-rjfm-3w2m-jf4f guard: a peer that
wins the allow short-circuit is admitted even when a hostname-pattern
deny rule cannot evaluate.
module_definition_matches_upstream_rsync_fns_allow_list- reproducesupstream's
testsuite/rsync.fns:381allow list and asserts every IPv4inside the CIDRs is admitted and every IPv4 outside is refused.
In
crates/daemon/src/tests/chunks/:module_definition_ipv4_allow_deny_precedence.rs,module_definition_hostname_deny_takes_precedence.rs,module_definition_mixed_ip_and_hostname_acl.rs- the chunks whoseassertions previously codified the bug have been updated to the
upstream semantics. The hostname chunk now carries both the wildcard-
allow short-circuit case and a no-allow-list deny case so the matcher
is pinned in both directions.
Existing GHSA fail-closed regressions
(
module_hostname_deny_fails_closed_when_dns_unresolved,module_ip_deny_unaffected_by_dns_failure) remain green: the guardstill fires on the deny path when the allow list does not match.
Scope
crates/branding/changes.daemon-tls, DirSandbox, SEND_ZC, or flat arena flist.
#![deny(unsafe_code)]preserved; no clippy waivers.Test plan
tests still passing