Skip to content

fix(daemon): match upstream's peer-host naming and ACL evaluation - #7314

Merged
oferchen merged 6 commits into
masterfrom
fix/daemon-log-host
Aug 14, 2026
Merged

oferchen merged 6 commits into
masterfrom
fix/daemon-log-host

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Stacked on #7303 - the first two commits are that PR's and this one should merge after it. The four commits here are all daemon peer-host naming and ACL evaluation, and the last two are security fixes. Each commit carries its own upstream citation, measurement table and non-vacuity note.

1. fix(daemon): render the peer host like upstream, not three ways

Upstream keeps one never-empty host string and hands the same value to %h, RSYNC_HOST_NAME and allow_access() (clientserver.c:769-773), using two sentinels: UNDETERMINED when reverse lookup is off (clientserver.c:126) and UNKNOWN when the lookup failed (clientname.c:34). oc named the peer three different ways depending on the consumer.

2. fix(daemon): match the host sentinels in hosts allow, as upstream does

Upstream documents UNKNOWN as a value an operator may put in a hosts allow line (clientname.c:91-94); match_hostname refuses only a NULL or empty name (access.c:37-38), so a sentinel matches like any other name. Measured with reverse lookup = no against a loopback peer, hosts allow = UNDETERMINED was ALLOWED on 3.5.0 and DENIED on oc.

Two defects, and fixing the filed one alone was inert - the end-to-end measurement still showed DENIED on every row. The sentinel never reached the matcher and HostnamePattern::matches compared case-sensitively against a pattern lowercased at parse time. That held only while every host arrived pre-lowercased from DNS. Upstream lowercases the list (strlower, access.c:251) and matches with the case-insensitive iwildmatch (access.c:46).

3. refactor(daemon): make the fail-closed deny guard compiler-enforced

The guard that refuses a peer when a hostname-based hosts deny rule cannot be evaluated asked !host.is_resolved(). Correct today, but resting on an unenforced biconditional over the two current PeerHost variants - a third variant would default a state nobody considered into "allowed", at the one site where being wrong is a security regression rather than a parity one. The guard now matches the enum exhaustively and is_resolved() is deleted, so adding a variant is E0004 at the guard instead of an inherited default. Verified by adding a probe variant: two E0004s, at the guard and at as_str(). Behaviour unchanged.

4. fix(daemon): hosts deny fails CLOSED on an unresolvable token

CVE-2026-70452's sibling. Upstream returns the caller's deny flag when the forward lookup of a configured token fails (access.c:57-63). oc returned "no match" for both lists, so hosts deny = host.example admitted every peer whenever that name would not resolve - a fail-open on a deny rule, reachable by making the operator's DNS unavailable.

Measured with reverse lookup = yes against a loopback peer:

config 3.5.0 oc before
hosts deny = unresolvable.example.com DENIED ALLOWED
hosts deny = 203.0.113.9 (control) ALLOWED ALLOWED
hosts deny = 127.0.0.1 (control) DENIED DENIED

Enumerated rather than generalised. Upstream has ONE decision site and threads a per-call flag to it - access_match(allow_list, .., 0) (access.c:284), access_match(deny_list, .., 1) (:293), and allow_proxy_protocol_peer (:305), which is allow-shaped. So deny is a parameter, not module state.

The fix needed a distinction oc did not have: upstream separates a failed lookup (NULL from gethostbyname -> return deny) from a successful one whose records exclude the peer (falls out of the loop -> return 0). forward_resolve collapsed both into an empty Vec, and that collapse is precisely what made the deny side fail open. It now returns Option<Vec<IpAddr>>.

One existing test encoded the fail-open - it asserted a second peer was admitted while the deny token was unresolvable. Corrected by giving the token a resolution, which is what that test actually meant to isolate.

Verification

Measured on this branch (cce83d5ae, on top of #7303's d6bc4bab5):

  • cargo fmt --all -- --check - clean
  • cargo clippy --locked --workspace --all-targets --all-features --no-deps -- -D warnings - exit 0
  • cargo nextest run -p daemon --all-features - 1768 passed, 6 skipped (2 passed on retry)
  • daemon_hosts_allow_sentinel + daemon_log_host_rendering - 5 passed

Both new integration tables assert against oc and against the real upstream 3.5.0 binary in the same cell. Each table carries controls that a blanket "refuse everything" or "admit everything" build would fail, and the deny fix additionally pins the allow-side asymmetry: the identical unresolvable token on the allow side must still not admit, so a change returning true unconditionally passes the first assertion and fails this one.

@github-actions github-actions Bot added the bug Something isn't working label Aug 14, 2026
@oferchen
oferchen force-pushed the fix/daemon-log-host branch from cce83d5 to 0285c81 Compare August 14, 2026 04:56
The daemon named the peer three different ways for the same missing
hostname: a lowercase `unknown` in the `log format` `%h` escape, the bare
peer address in the `rsync allowed access` / `denied` / `connect from`
lines, and an empty string in `RSYNC_HOST_NAME`. A single session could
therefore log

    rsync allowed access on module m from 127.0.0.1 (127.0.0.1)
    ... h=[unknown] a=[127.0.0.1]

Upstream keeps ONE host string per connection and renders it at every one
of those sites (clientserver.c:1524-1526, :770-771, log.c:583-593), and
that string is never empty or an address. It distinguishes two cases the
`Option<&str>` collapsed:

  UNDETERMINED  reverse lookup is off, so no name was ever sought
                (clientserver.c:126)
  UNKNOWN       a lookup ran and produced nothing - the 0.0.0.0 sentinel,
                a failed reverse lookup, or a rejected forward
                confirmation (clientname.c:34, :112)

`peer_host_display()` is that one rule; the ad-hoc fallbacks at the nine
log helpers, the `%h` renderer and the exec environment are gone, and
`format_host()` (the address-substituting one) is deleted.

Measured against the real rsync 3.5.0 daemon serving the same config:

  case                        upstream %h / %a       oc before      oc after
  TCP, reverse lookup = yes   localhost/127.0.0.1    match          match
  TCP, reverse lookup = no    UNDETERMINED/127.0.0.1 unknown/...    match
  rsh, no peer env            UNKNOWN/0.0.0.0        unknown/...    match
  rsh, REMOTE_HOST set        UNKNOWN/192.0.2.55     unknown/...    match

`%a` needed no change - it already rendered the resolved peer address.

Scope: this is the display, log and environment rule only. Upstream also
feeds these sentinels to `allow_access()`, and clientname.c:93-95
documents `UNKNOWN` as usable in a `hosts allow` line; adopting that
would widen oc's ACL matching, so access control keeps consuming the
`Option<&str>` unchanged and the question is filed separately.

Two existing tests pinned the pre-fix behaviour and are corrected: the
`RSYNC_HOST_NAME` assertion expected an empty string, and `format_host`
had three tests asserting the address substitution.
Upstream documents `UNKNOWN` as a value an operator may put in a
`hosts allow` line (clientname.c:91-94), and hands `allow_access()` the
same never-empty host string its log lines print (clientserver.c:769-773).
`match_hostname` refuses only a NULL or empty name (access.c:37-38), so a
sentinel is matched like any other name.

oc modelled the host as `Option<&str>` and passed `None`, so both
sentinels were unmatchable. Measured on 3.5.0 and oc, `reverse lookup =
no`, loopback peer:

  hosts allow = UNDETERMINED    upstream ALLOWED   oc DENIED
  hosts allow = other.example   upstream DENIED    oc DENIED   (control)
  hosts allow = 127.0.0.1       upstream ALLOWED   oc ALLOWED  (control)

TWO defects, and fixing the first alone was INERT - the end-to-end
measurement still showed DENIED on every row:

1. The sentinel never reached the matcher. `permits()` now takes a
   `PeerHost`, built by the same rule the display path uses, so the string
   an ACL matches is the string the log line prints.

2. `HostnamePattern::matches` compared case-SENSITIVELY against a pattern
   lowercased at parse time. That held only because every host until now
   arrived pre-lowercased from DNS via `normalize_hostname_owned`.
   Upstream lowercases the LIST (`strlower`, access.c:251) and matches
   with `iwildmatch`, the case-INSENSITIVE form (access.c:46) - so
   `unknown` matches `UNKNOWN` there. The host is now folded at the match
   site, which fixes the exact, suffix and wildcard arms together.

The `Resolved`/`Sentinel` distinction is kept because oc has one rule
upstream does not: a hostname-based DENY rule fails closed when no name
was resolved (GHSA-rjfm-3w2m-jf4f). Upstream can rely on reverse DNS
being cached from before `daemon chroot`; oc resolves per connection
after a process-wide chroot, where a chroot without NSS silently yields
no name. That guard is re-keyed from `hostname.is_none()` to
`!host.is_resolved()` - the SAME predicate, since `PeerHost::new` returns
`Sentinel` exactly when the resolved name is absent - so the allow-side
sentinels match without disarming it.

Tests: a 6-row table asserting the outcome of a real loopback
connection, run against oc AND the real 3.5.0 binary. It carries both
sentinel spellings and the wildcard arm, two controls (an unrelated
hostname rule still refuses; an address rule still admits, proving the
directive is live rather than ignored), and the discriminator - with
`reverse lookup = yes` a resolved peer must NOT match `UNDETERMINED`, so
a build that matched the sentinel unconditionally fails exactly one row.
Non-vacuity measured per half: reverting either the pass-through or the
case fold reddens the oc cell alone and leaves the upstream oracle green.

The harness pins the daemon's stdin to /dev/null. Without it the daemon
takes its single-connection path, never listens, and every row reports
"connection refused" - identical output for rows that must differ, which
is a broken instrument rather than a result. That is how the first
measurement of this defect went wrong.
The guard that refuses a peer when a hostname-based `hosts deny` rule
cannot be evaluated (GHSA-rjfm-3w2m-jf4f) asked `!host.is_resolved()`.
That is correct today, but it rests on a biconditional over the two
current `PeerHost` variants - sentinel iff no name was resolved - and the
biconditional is not enforced anywhere. A third variant, say a
resolved-but-empty name, would make `is_resolved()` answer for a state
nobody considered and would default it into "allowed", silently, at the
one site in the module where being wrong is a security regression rather
than a parity one.

The guard now matches the enum exhaustively and `is_resolved()` is
deleted rather than left available. Adding a variant is a compile error
instead of an inherited default, so the property is checked by the
compiler rather than argued in a comment or trusted from a review.

Non-vacuity measured: adding a probe variant produces

  error[E0004]: non-exhaustive patterns: `PeerHost::ResolvedButEmpty` not
  covered --> crates/daemon/src/daemon/module_state/definition.rs:281:39

at the guard, and a second E0004 at `as_str()` - the other site a new
state must be reasoned about. Behaviour is unchanged: 599 access-control
tests and the sentinel parity table pass before and after.

Same technique as enumerating the drains by deleting the ambiguous API,
applied prospectively rather than to find today's callers.
CVE-2026-70452's sibling. Upstream returns the caller's `deny` flag when
the forward lookup of a configured token fails (access.c:57-63):

    if (!(hp = gethostbyname(tok))) {
        /* A deny-list hostname token we cannot resolve must fail CLOSED:
         * we can't prove the peer isn't the denied host ... */
        return deny;
    }

oc returned "no match" for both lists, so `hosts deny = host.example`
admitted every peer whenever that name would not resolve - a fail-OPEN on
a deny rule, reachable by making the operator's DNS unavailable.

Measured on 3.5.0 and oc, `reverse lookup = yes`, loopback peer:

  hosts deny = unresolvable.example.com   upstream DENIED   oc ALLOWED
  hosts deny = 203.0.113.9   (control)    upstream ALLOWED  oc ALLOWED
  hosts deny = 127.0.0.1     (control)    upstream DENIED   oc DENIED

All three now agree.

ENUMERATED rather than generalised. Upstream has ONE decision site and
threads a per-call flag to it - `access_match(allow_list, .., 0)`
(access.c:284), `access_match(deny_list, .., 1)` (:293), and
`allow_proxy_protocol_peer` (:305) which is allow-shaped. So `deny` is a
parameter here too, not module state: one rule read differently per call.
Both earlier gates return 0 regardless of the flag (access.c:49-53), and
that is preserved.

The fix needed a second distinction oc did not have. Upstream separates a
FAILED lookup (NULL `gethostbyname` -> return deny) from a SUCCESSFUL one
whose records do not include the peer (falls out of the loop -> return 0).
`forward_resolve` collapsed both into an empty `Vec`, which is precisely
what made the deny side fail open, so it now returns `Option<Vec<IpAddr>>`
- `None` is a failed lookup. The reverse-name confirmation path keeps its
existing fail-closed reading of `None` (clientname.c:437-441).

Tests: the new table asserts the fix, the ASYMMETRY (the identical
unresolvable token on the allow side must still NOT admit - a fix
returning true unconditionally would pass the first assertion and fail
this one), and two controls - a deny token resolving elsewhere leaves the
peer permitted, and one resolving to the peer still blocks. Without the
first control a build that refuses everything satisfies the table, which
is the failure mode a fail-closed change invites.

Non-vacuity measured: restoring `None => false` reddens exactly the new
test. Task 648's sentinel table was re-run end-to-end and is unaffected.

One existing test encoded the fail-open - it asserted a second peer was
admitted while the deny token was unresolvable, which upstream refuses.
Corrected by giving the token a resolution, which is what that test
actually meant to isolate.
The pinned upstream source moved from 3.4.4 to 3.5.0 in #7305, which
changed `PINNED_SOURCE_DIR` and the line manifest the citation gate
resolves against. This branch was written before that landed, so its
`clientserver.c:1559` citation named the 3.4.4 line:

    3.4.4  1559:  return start_daemon(STDIN_FILENO, STDIN_FILENO);
    3.5.0  1738:  return start_daemon(STDIN_FILENO, STDIN_FILENO);

Both occurrences now name 1738. Measured with
`tools/ci/citation_drift_audit.py --ratchet`: daemon goes 3 -> 2, its
baseline value, so no baseline edit is needed.

The two remaining ratchet failures (`core` 3 -> 4 and `protocol` 0 -> 1)
reproduce byte-identically on pristine origin/master and are not from
this branch.
@oferchen
oferchen force-pushed the fix/daemon-log-host branch from 0285c81 to a43068d Compare August 14, 2026 04:57
oferchen added a commit that referenced this pull request Aug 14, 2026
… 3.5.0

#7305 moved the pinned upstream source from 3.4.4 to 3.5.0. Ten PRs
authored before that flip merged after it, so their citations name 3.4.4
line numbers in a tree the gate resolves against 3.5.0. This clears the
`core` ratchet, which five open PRs currently inherit:

    FAIL: core suspected-drift rose 3 -> 4     (before)
    core: suspected-drift=0                    (after)

Every target was verified against BOTH tarballs. Only the first is a
mechanical retarget; the rest needed the enclosing construct because the
anchor the audit extracts is not unique in its file.

1. flags.rs  generator.c:298 -> :304
   `io_error & IOERR_GENERAL` is unique; surrounding context is
   byte-identical.

2. daemon_transfer/connection/mod.rs  clientserver.c:382 -> :425
   `rprintf(FERROR, "` occurs many times. The site is the `@ERROR`
   handler, located by `strncmp(line, "@error", 6)` (3.4.4:381 ->
   3.5.0:424) and confirmed by byte-identical context.

3. flags.rs  options.c:2852-2857 -> :3018-3023
4. invocation/tests.rs  options.c:2850-2851 -> :3016-3017  (two sites)
   Both were already correct 3.4.4 RANGES; the audit flagged them only
   because it anchors on the range's prose (`if (am_sender)`), which
   occurs three times in options.c and is not on the cited line. The
   blocks are byte-identical at a constant +166. The comments are
   re-anchored on `args[ac++] = "--super"` and
   `args[ac++] = "--only-write-batch=X"`, each unique in options.c, so
   the audit can resolve them instead of guessing.

5. invocation/tests.rs  main.c:1839 -> :1919, sender.c:217 -> :501
   ⚠ Neither was reported by the ratchet - it only inspects lines
   containing the word `upstream`, and these sit mid-sentence in a doc
   comment. Both were stale. `sender.c` moved by +284 where options.c
   moved by +166, so an offset applied in bulk would have been wrong;
   each was located by its construct (`if (write_batch < 0) dry_run = 1`
   and `f_xfer = write_batch < 0 ? batch_fd : f_out`).

`core` drops 4 -> 0, so its baseline goes 3 -> 0 in the same commit, as
the baseline file requires - leaving it at 3 would keep accepting drift
that no longer exists and hide the next regression under that headroom.

Deliberately out of scope:
- `protocol` (`flist.c:758`) - the identical fix is already in #7318.
- `daemon` (`clientserver.c:1559`) - same cohort, fixed on #7314.

Measured on ce8c63d: `tools/ci/citation_drift_audit.py --ratchet`
reports core=0; `cargo xtask citations` passes (7826 citations);
`cargo fmt --all -- --check` clean.
@oferchen
oferchen enabled auto-merge (squash) August 14, 2026 06:00
oferchen added a commit that referenced this pull request Aug 14, 2026
… 3.5.0 (#7321)

#7305 moved the pinned upstream source from 3.4.4 to 3.5.0. Ten PRs
authored before that flip merged after it, so their citations name 3.4.4
line numbers in a tree the gate resolves against 3.5.0. This clears the
`core` ratchet, which five open PRs currently inherit:

    FAIL: core suspected-drift rose 3 -> 4     (before)
    core: suspected-drift=0                    (after)

Every target was verified against BOTH tarballs. Only the first is a
mechanical retarget; the rest needed the enclosing construct because the
anchor the audit extracts is not unique in its file.

1. flags.rs  generator.c:298 -> :304
   `io_error & IOERR_GENERAL` is unique; surrounding context is
   byte-identical.

2. daemon_transfer/connection/mod.rs  clientserver.c:382 -> :425
   `rprintf(FERROR, "` occurs many times. The site is the `@ERROR`
   handler, located by `strncmp(line, "@error", 6)` (3.4.4:381 ->
   3.5.0:424) and confirmed by byte-identical context.

3. flags.rs  options.c:2852-2857 -> :3018-3023
4. invocation/tests.rs  options.c:2850-2851 -> :3016-3017  (two sites)
   Both were already correct 3.4.4 RANGES; the audit flagged them only
   because it anchors on the range's prose (`if (am_sender)`), which
   occurs three times in options.c and is not on the cited line. The
   blocks are byte-identical at a constant +166. The comments are
   re-anchored on `args[ac++] = "--super"` and
   `args[ac++] = "--only-write-batch=X"`, each unique in options.c, so
   the audit can resolve them instead of guessing.

5. invocation/tests.rs  main.c:1839 -> :1919, sender.c:217 -> :501
   ⚠ Neither was reported by the ratchet - it only inspects lines
   containing the word `upstream`, and these sit mid-sentence in a doc
   comment. Both were stale. `sender.c` moved by +284 where options.c
   moved by +166, so an offset applied in bulk would have been wrong;
   each was located by its construct (`if (write_batch < 0) dry_run = 1`
   and `f_xfer = write_batch < 0 ? batch_fd : f_out`).

`core` drops 4 -> 0, so its baseline goes 3 -> 0 in the same commit, as
the baseline file requires - leaving it at 3 would keep accepting drift
that no longer exists and hide the next regression under that headroom.

Deliberately out of scope:
- `protocol` (`flist.c:758`) - the identical fix is already in #7318.
- `daemon` (`clientserver.c:1559`) - same cohort, fixed on #7314.

Measured on ce8c63d: `tools/ci/citation_drift_audit.py --ratchet`
reports core=0; `cargo xtask citations` passes (7826 citations);
`cargo fmt --all -- --check` clean.
@oferchen
oferchen merged commit ccf251b into master Aug 14, 2026
66 of 68 checks passed
@oferchen
oferchen deleted the fix/daemon-log-host branch August 14, 2026 09:55
oferchen added a commit that referenced this pull request Aug 21, 2026
…te (#7423)

The changelog had not been touched since 2026-08-13 (#7279) while ~140 PRs
merged, and several factual claims in README/SECURITY had drifted far enough
to mislead an operator. Each correction below was verified against the tree,
not inferred.

CHANGELOG: fill in Unreleased for everything merged since #7279, grouped by
Security / Added / Changed / Fixed / Testing and CI / Documentation.

SECURITY:
- The 3.5.0 divergence figure said 133. The committed expect manifests say
  43 + 62 on the two full-corpus legs (64 distinct) and 89 across all four.
  Replaced the estimate with the per-leg table and the manifest mechanism.
- The CI paragraph described the 3.5.0 suite as a separate nightly job. It
  is now the required gate, four legs, on every pull request.
- CVE-2026-53791: the placeholder-peer-address prerequisite is fixed
  (#7303), not pending. CVE-2026-70452, -70463 and -70453 are fixed
  (#7314, #7345, #7293) and were still listed as under audit.
- The new-defensive-surface paragraph listed all eight 3.5.0 additions as
  being adopted; four have shipped and two directives have not.
- The fuzz list named 24 targets including "rsyncd_conf", which does not
  exist in fuzz/fuzz_targets. There are 26; added the three real ones that
  were missing.
- The buffer-pool hardening note claimed recycle_buffer guards buf_id with
  a debug assertion and warned against exposing io_uring to untrusted
  input. The check is a real release-mode bound returning
  BufferIdOutOfRange before any state is mutated, so the warning was false.

README:
- Status and interop sections listed 3.5.0 as built-and-cached ahead of
  gating; run_interop.sh has it in the gating version list, and the
  protocol table row still said "not yet gating".
- Added the current 3.5.0 testsuite outcomes rather than only describing
  the mechanism, so the 64 open divergences are stated plainly.
- The CVE line stopped at the 2024 batch; the 3.4.3 batch is closed and
  3.5.0 is partially closed and tracked.
- The spill CLI flags were described as planned for STN-11; both exist.
- The OC_RSYNC_BUFFER_POOL variables were attributed to the io_uring
  registered pool. All three live in crates/engine/src/local_copy/
  buffer_pool/ and tune the engine pool; the io_uring pool is a
  different, static one.
- The bgid note advised monitoring for exhaustion that measurement shows
  does not occur.
- Fixed a broken link: compressed_token/zstd_codec is a directory.
- Listed the shipped 3.5.0 option surface in the feature table.
oferchen added a commit that referenced this pull request Aug 24, 2026
… 3.5.0 (#7321)

#7305 moved the pinned upstream source from 3.4.4 to 3.5.0. Ten PRs
authored before that flip merged after it, so their citations name 3.4.4
line numbers in a tree the gate resolves against 3.5.0. This clears the
`core` ratchet, which five open PRs currently inherit:

    FAIL: core suspected-drift rose 3 -> 4     (before)
    core: suspected-drift=0                    (after)

Every target was verified against BOTH tarballs. Only the first is a
mechanical retarget; the rest needed the enclosing construct because the
anchor the audit extracts is not unique in its file.

1. flags.rs  generator.c:298 -> :304
   `io_error & IOERR_GENERAL` is unique; surrounding context is
   byte-identical.

2. daemon_transfer/connection/mod.rs  clientserver.c:382 -> :425
   `rprintf(FERROR, "` occurs many times. The site is the `@ERROR`
   handler, located by `strncmp(line, "@error", 6)` (3.4.4:381 ->
   3.5.0:424) and confirmed by byte-identical context.

3. flags.rs  options.c:2852-2857 -> :3018-3023
4. invocation/tests.rs  options.c:2850-2851 -> :3016-3017  (two sites)
   Both were already correct 3.4.4 RANGES; the audit flagged them only
   because it anchors on the range's prose (`if (am_sender)`), which
   occurs three times in options.c and is not on the cited line. The
   blocks are byte-identical at a constant +166. The comments are
   re-anchored on `args[ac++] = "--super"` and
   `args[ac++] = "--only-write-batch=X"`, each unique in options.c, so
   the audit can resolve them instead of guessing.

5. invocation/tests.rs  main.c:1839 -> :1919, sender.c:217 -> :501
   ⚠ Neither was reported by the ratchet - it only inspects lines
   containing the word `upstream`, and these sit mid-sentence in a doc
   comment. Both were stale. `sender.c` moved by +284 where options.c
   moved by +166, so an offset applied in bulk would have been wrong;
   each was located by its construct (`if (write_batch < 0) dry_run = 1`
   and `f_xfer = write_batch < 0 ? batch_fd : f_out`).

`core` drops 4 -> 0, so its baseline goes 3 -> 0 in the same commit, as
the baseline file requires - leaving it at 3 would keep accepting drift
that no longer exists and hide the next regression under that headroom.

Deliberately out of scope:
- `protocol` (`flist.c:758`) - the identical fix is already in #7318.
- `daemon` (`clientserver.c:1559`) - same cohort, fixed on #7314.

Measured on 30b95b7: `tools/ci/citation_drift_audit.py --ratchet`
reports core=0; `cargo xtask citations` passes (7826 citations);
`cargo fmt --all -- --check` clean.
oferchen added a commit that referenced this pull request Aug 24, 2026
)

* fix(daemon): render the peer host like upstream, not three ways

The daemon named the peer three different ways for the same missing
hostname: a lowercase `unknown` in the `log format` `%h` escape, the bare
peer address in the `rsync allowed access` / `denied` / `connect from`
lines, and an empty string in `RSYNC_HOST_NAME`. A single session could
therefore log

    rsync allowed access on module m from 127.0.0.1 (127.0.0.1)
    ... h=[unknown] a=[127.0.0.1]

Upstream keeps ONE host string per connection and renders it at every one
of those sites (clientserver.c:1524-1526, :770-771, log.c:583-593), and
that string is never empty or an address. It distinguishes two cases the
`Option<&str>` collapsed:

  UNDETERMINED  reverse lookup is off, so no name was ever sought
                (clientserver.c:126)
  UNKNOWN       a lookup ran and produced nothing - the 0.0.0.0 sentinel,
                a failed reverse lookup, or a rejected forward
                confirmation (clientname.c:34, :112)

`peer_host_display()` is that one rule; the ad-hoc fallbacks at the nine
log helpers, the `%h` renderer and the exec environment are gone, and
`format_host()` (the address-substituting one) is deleted.

Measured against the real rsync 3.5.0 daemon serving the same config:

  case                        upstream %h / %a       oc before      oc after
  TCP, reverse lookup = yes   localhost/127.0.0.1    match          match
  TCP, reverse lookup = no    UNDETERMINED/127.0.0.1 unknown/...    match
  rsh, no peer env            UNKNOWN/0.0.0.0        unknown/...    match
  rsh, REMOTE_HOST set        UNKNOWN/192.0.2.55     unknown/...    match

`%a` needed no change - it already rendered the resolved peer address.

Scope: this is the display, log and environment rule only. Upstream also
feeds these sentinels to `allow_access()`, and clientname.c:93-95
documents `UNKNOWN` as usable in a `hosts allow` line; adopting that
would widen oc's ACL matching, so access control keeps consuming the
`Option<&str>` unchanged and the question is filed separately.

Two existing tests pinned the pre-fix behaviour and are corrected: the
`RSYNC_HOST_NAME` assertion expected an empty string, and `format_host`
had three tests asserting the address substitution.

* fix(daemon): match the host sentinels in hosts allow, as upstream does

Upstream documents `UNKNOWN` as a value an operator may put in a
`hosts allow` line (clientname.c:91-94), and hands `allow_access()` the
same never-empty host string its log lines print (clientserver.c:769-773).
`match_hostname` refuses only a NULL or empty name (access.c:37-38), so a
sentinel is matched like any other name.

oc modelled the host as `Option<&str>` and passed `None`, so both
sentinels were unmatchable. Measured on 3.5.0 and oc, `reverse lookup =
no`, loopback peer:

  hosts allow = UNDETERMINED    upstream ALLOWED   oc DENIED
  hosts allow = other.example   upstream DENIED    oc DENIED   (control)
  hosts allow = 127.0.0.1       upstream ALLOWED   oc ALLOWED  (control)

TWO defects, and fixing the first alone was INERT - the end-to-end
measurement still showed DENIED on every row:

1. The sentinel never reached the matcher. `permits()` now takes a
   `PeerHost`, built by the same rule the display path uses, so the string
   an ACL matches is the string the log line prints.

2. `HostnamePattern::matches` compared case-SENSITIVELY against a pattern
   lowercased at parse time. That held only because every host until now
   arrived pre-lowercased from DNS via `normalize_hostname_owned`.
   Upstream lowercases the LIST (`strlower`, access.c:251) and matches
   with `iwildmatch`, the case-INSENSITIVE form (access.c:46) - so
   `unknown` matches `UNKNOWN` there. The host is now folded at the match
   site, which fixes the exact, suffix and wildcard arms together.

The `Resolved`/`Sentinel` distinction is kept because oc has one rule
upstream does not: a hostname-based DENY rule fails closed when no name
was resolved (GHSA-rjfm-3w2m-jf4f). Upstream can rely on reverse DNS
being cached from before `daemon chroot`; oc resolves per connection
after a process-wide chroot, where a chroot without NSS silently yields
no name. That guard is re-keyed from `hostname.is_none()` to
`!host.is_resolved()` - the SAME predicate, since `PeerHost::new` returns
`Sentinel` exactly when the resolved name is absent - so the allow-side
sentinels match without disarming it.

Tests: a 6-row table asserting the outcome of a real loopback
connection, run against oc AND the real 3.5.0 binary. It carries both
sentinel spellings and the wildcard arm, two controls (an unrelated
hostname rule still refuses; an address rule still admits, proving the
directive is live rather than ignored), and the discriminator - with
`reverse lookup = yes` a resolved peer must NOT match `UNDETERMINED`, so
a build that matched the sentinel unconditionally fails exactly one row.
Non-vacuity measured per half: reverting either the pass-through or the
case fold reddens the oc cell alone and leaves the upstream oracle green.

The harness pins the daemon's stdin to /dev/null. Without it the daemon
takes its single-connection path, never listens, and every row reports
"connection refused" - identical output for rows that must differ, which
is a broken instrument rather than a result. That is how the first
measurement of this defect went wrong.

* refactor(daemon): make the fail-closed deny guard compiler-enforced

The guard that refuses a peer when a hostname-based `hosts deny` rule
cannot be evaluated (GHSA-rjfm-3w2m-jf4f) asked `!host.is_resolved()`.
That is correct today, but it rests on a biconditional over the two
current `PeerHost` variants - sentinel iff no name was resolved - and the
biconditional is not enforced anywhere. A third variant, say a
resolved-but-empty name, would make `is_resolved()` answer for a state
nobody considered and would default it into "allowed", silently, at the
one site in the module where being wrong is a security regression rather
than a parity one.

The guard now matches the enum exhaustively and `is_resolved()` is
deleted rather than left available. Adding a variant is a compile error
instead of an inherited default, so the property is checked by the
compiler rather than argued in a comment or trusted from a review.

Non-vacuity measured: adding a probe variant produces

  error[E0004]: non-exhaustive patterns: `PeerHost::ResolvedButEmpty` not
  covered --> crates/daemon/src/daemon/module_state/definition.rs:281:39

at the guard, and a second E0004 at `as_str()` - the other site a new
state must be reasoned about. Behaviour is unchanged: 599 access-control
tests and the sentinel parity table pass before and after.

Same technique as enumerating the drains by deleting the ambiguous API,
applied prospectively rather than to find today's callers.

* fix(daemon): hosts deny fails CLOSED on an unresolvable token

CVE-2026-70452's sibling. Upstream returns the caller's `deny` flag when
the forward lookup of a configured token fails (access.c:57-63):

    if (!(hp = gethostbyname(tok))) {
        /* A deny-list hostname token we cannot resolve must fail CLOSED:
         * we can't prove the peer isn't the denied host ... */
        return deny;
    }

oc returned "no match" for both lists, so `hosts deny = host.example`
admitted every peer whenever that name would not resolve - a fail-OPEN on
a deny rule, reachable by making the operator's DNS unavailable.

Measured on 3.5.0 and oc, `reverse lookup = yes`, loopback peer:

  hosts deny = unresolvable.example.com   upstream DENIED   oc ALLOWED
  hosts deny = 203.0.113.9   (control)    upstream ALLOWED  oc ALLOWED
  hosts deny = 127.0.0.1     (control)    upstream DENIED   oc DENIED

All three now agree.

ENUMERATED rather than generalised. Upstream has ONE decision site and
threads a per-call flag to it - `access_match(allow_list, .., 0)`
(access.c:284), `access_match(deny_list, .., 1)` (:293), and
`allow_proxy_protocol_peer` (:305) which is allow-shaped. So `deny` is a
parameter here too, not module state: one rule read differently per call.
Both earlier gates return 0 regardless of the flag (access.c:49-53), and
that is preserved.

The fix needed a second distinction oc did not have. Upstream separates a
FAILED lookup (NULL `gethostbyname` -> return deny) from a SUCCESSFUL one
whose records do not include the peer (falls out of the loop -> return 0).
`forward_resolve` collapsed both into an empty `Vec`, which is precisely
what made the deny side fail open, so it now returns `Option<Vec<IpAddr>>`
- `None` is a failed lookup. The reverse-name confirmation path keeps its
existing fail-closed reading of `None` (clientname.c:437-441).

Tests: the new table asserts the fix, the ASYMMETRY (the identical
unresolvable token on the allow side must still NOT admit - a fix
returning true unconditionally would pass the first assertion and fail
this one), and two controls - a deny token resolving elsewhere leaves the
peer permitted, and one resolving to the peer still blocks. Without the
first control a build that refuses everything satisfies the table, which
is the failure mode a fail-closed change invites.

Non-vacuity measured: restoring `None => false` reddens exactly the new
test. Task 648's sentinel table was re-run end-to-end and is unaffected.

One existing test encoded the fail-open - it asserted a second peer was
admitted while the deny token was unresolvable, which upstream refuses.
Corrected by giving the token a resolution, which is what that test
actually meant to isolate.

* fix(daemon): retarget the inetd start_daemon citation at rsync 3.5.0

The pinned upstream source moved from 3.4.4 to 3.5.0 in #7305, which
changed `PINNED_SOURCE_DIR` and the line manifest the citation gate
resolves against. This branch was written before that landed, so its
`clientserver.c:1559` citation named the 3.4.4 line:

    3.4.4  1559:  return start_daemon(STDIN_FILENO, STDIN_FILENO);
    3.5.0  1738:  return start_daemon(STDIN_FILENO, STDIN_FILENO);

Both occurrences now name 1738. Measured with
`tools/ci/citation_drift_audit.py --ratchet`: daemon goes 3 -> 2, its
baseline value, so no baseline edit is needed.

The two remaining ratchet failures (`core` 3 -> 4 and `protocol` 0 -> 1)
reproduce byte-identically on pristine origin/master and are not from
this branch.
oferchen added a commit that referenced this pull request Aug 24, 2026
…te (#7423)

The changelog had not been touched since 2026-08-13 (#7279) while ~140 PRs
merged, and several factual claims in README/SECURITY had drifted far enough
to mislead an operator. Each correction below was verified against the tree,
not inferred.

CHANGELOG: fill in Unreleased for everything merged since #7279, grouped by
Security / Added / Changed / Fixed / Testing and CI / Documentation.

SECURITY:
- The 3.5.0 divergence figure said 133. The committed expect manifests say
  43 + 62 on the two full-corpus legs (64 distinct) and 89 across all four.
  Replaced the estimate with the per-leg table and the manifest mechanism.
- The CI paragraph described the 3.5.0 suite as a separate nightly job. It
  is now the required gate, four legs, on every pull request.
- CVE-2026-53791: the placeholder-peer-address prerequisite is fixed
  (#7303), not pending. CVE-2026-70452, -70463 and -70453 are fixed
  (#7314, #7345, #7293) and were still listed as under audit.
- The new-defensive-surface paragraph listed all eight 3.5.0 additions as
  being adopted; four have shipped and two directives have not.
- The fuzz list named 24 targets including "rsyncd_conf", which does not
  exist in fuzz/fuzz_targets. There are 26; added the three real ones that
  were missing.
- The buffer-pool hardening note claimed recycle_buffer guards buf_id with
  a debug assertion and warned against exposing io_uring to untrusted
  input. The check is a real release-mode bound returning
  BufferIdOutOfRange before any state is mutated, so the warning was false.

README:
- Status and interop sections listed 3.5.0 as built-and-cached ahead of
  gating; run_interop.sh has it in the gating version list, and the
  protocol table row still said "not yet gating".
- Added the current 3.5.0 testsuite outcomes rather than only describing
  the mechanism, so the 64 open divergences are stated plainly.
- The CVE line stopped at the 2024 batch; the 3.4.3 batch is closed and
  3.5.0 is partially closed and tracked.
- The spill CLI flags were described as planned for STN-11; both exist.
- The OC_RSYNC_BUFFER_POOL variables were attributed to the io_uring
  registered pool. All three live in crates/engine/src/local_copy/
  buffer_pool/ and tune the engine pool; the io_uring pool is a
  different, static one.
- The bgid note advised monitoring for exhaustion that measurement shows
  does not occur.
- Fixed a broken link: compressed_token/zstd_codec is a directory.
- Listed the shipped 3.5.0 option surface in the feature table.
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