Repository navigation
fix(daemon): resolve the real peer address on both stdio paths - #7303
Merged
Merged
Conversation
`hosts allow` / `hosts deny` were evaluated against a synthetic `127.0.0.1:0` on both stdio entry points, so the canonical "local only" rule admitted every client and an allow-list naming real subnets rejected every legitimate one. Broken in both directions, depending on the config. The two paths are NOT the same case, which is what made the old code look defensible: - inetd / socket activation (upstream `am_daemon > 0`): fd 0 IS the connected socket. `client_addr()` skips the environment arm entirely and `client_sockaddr()` reads the peer with `getpeername` (clientname.c:80-83, :37-45). oc was discarding an available value, and its comment's premise - "there is no TCP socket to query" - was false. - daemon behind a remote shell (`am_daemon < 0`): fd 0 is a pipe and `getpeername` genuinely cannot work. Upstream seeds `"0.0.0.0"` then takes the first of REMOTE_HOST, SSH_CONNECTION, SSH_CLIENT, SSH2_CLIENT, truncated at the first space and kept only if it parses (clientname.c:63-78). None of those four variables appeared anywhere in the tree. Both oc sites carried an `upstream:` comment asserting that upstream uses `127.0.0.1:0`. It does not, on either path. Those comments are why the hole survived review, and they are deleted. The `0.0.0.0` seed is the security-relevant half: it matches no realistic allow token, so a remote-shell daemon with no peer information in its environment fails CLOSED where `127.0.0.1` failed open against exactly the rule operators write to mean "local only". Also mirrored: `getpeername` failure aborts with RERR_SOCKETIO rather than substituting a placeholder (clientname.c:41-45), and an IPv4-mapped IPv6 peer (`::ffff:a.b.c.d`) is normalised to IPv4 before any ACL comparison (clientname.c:47-74), which changes what an IPv4 `hosts allow` matches on a dual-stack listener. One deliberate, documented narrowing of the abort: a peer that has an address but not an IP one - an AF_UNIX socketpair, as used by systemd socket activation with `Accept=yes` and by RSYNC_CONNECT_PROG - degrades to the same `0.0.0.0` sentinel instead of failing. Upstream serves that configuration (its `getnameinfo` return is unchecked, leaving the address empty); refusing it would have been a regression, and it is what the existing `daemon_empty_digest_list_refused` tests exercise. No unsafe is added: `socket2` is already a direct dependency of `crates/daemon`, and `SockRef::from(&io::Stdin)` borrows fd 0 through `AsFd` - the same construction `is_stdin_socket()` already uses. Tests, one per entry point because a per-path test would have passed on whichever path its author picked: - `tests/daemon_stdio_peer_address_acl.rs` - remote shell. The loopback rule must DENY (it ADMITTED before) and REMOTE_HOST must ADMIT (it would have been DENIED before). Each is the other's control. - `tests/daemon_inetd_peer_address_acl.rs` - inetd, peered over IPv6 loopback so the fabricated `127.0.0.1` and the true `::1` cannot coincide. An earlier revision used `127.0.0.2` and silently SKIPPED on macOS, proving nothing on half the matrix. Non-vacuity was proven by restoring the fabricated address at each site independently: 3 of 4 remote-shell cases and both inetd cases turn red.
…form
The three Windows cells were failing to BUILD, not to test:
Windows ACL/xattr step 7 "Build oc-rsync"
interop (Windows, best-effort) step 5 "Build oc-rsync"
Feature flags / concurrent-sessions step 9 "Test" (compiles first)
One cause for all three. `normalize_v4_mapped` is called only from
`inherited_socket_peer_addr`, which is `#[cfg(unix)]` - a V4MAPPED peer
can only arrive through the inetd stdin socket that function reads. On
Windows the caller is compiled out, the function is dead, and
`RUSTFLAGS: "-D warnings"` (set in `_interop-windows.yml:70` and
`_test-features.yml:77`) turns the `dead_code` warning into a build
failure. Its two unit tests are gated for the same reason.
MEASURED, not inferred. Windows-gnu cross-check on the PR head, which
reproduces the failure exactly:
cargo check --target x86_64-pc-windows-gnu --all-features -p daemon
warning: function `normalize_v4_mapped` is never used
--> crates/daemon/src/daemon/peer_address.rs:124:4
and after the fix, with `-D warnings` and `--all-targets`, plus the
`concurrent-sessions` feature cell separately: both clean.
⚠ It is NOT `SockRef::from(&stdin)`. That reading is structurally sound
about socket2 - on Windows the conversion needs `S: AsSocket`
(sockref.rs:97-100) and `std::io::Stdin` is `AsHandle` - but it does not
apply here, because BOTH `SockRef::from(&stdin)` sites were already
`#[cfg(unix)]` with explicit non-Unix arms (`peer_address.rs:155`,
`inetd.rs:23-37`), and the two remaining `SockRef::from` calls in
`inetd.rs` sit inside a `#[cfg(unix)]` test. Code that is not compiled on
Windows cannot be the Windows compile error. The other 14 `SockRef::from`
sites in `crates/daemon` all take a real `TcpListener`/`TcpStream`/
`UnixStream`, which do implement `AsSocket` where they are compiled.
No `#[allow(dead_code)]`: per the cross-platform policy the Windows arm
must be as explicit as the Unix one, and a suppressed warning would hide
the next instance of this exact class.
oferchen
enabled auto-merge (squash)
August 14, 2026 04:02
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
* fix(daemon): resolve the real peer address on both stdio paths
`hosts allow` / `hosts deny` were evaluated against a synthetic
`127.0.0.1:0` on both stdio entry points, so the canonical "local only"
rule admitted every client and an allow-list naming real subnets rejected
every legitimate one. Broken in both directions, depending on the config.
The two paths are NOT the same case, which is what made the old code look
defensible:
- inetd / socket activation (upstream `am_daemon > 0`): fd 0 IS the
connected socket. `client_addr()` skips the environment arm entirely and
`client_sockaddr()` reads the peer with `getpeername`
(clientname.c:80-83, :37-45). oc was discarding an available value, and
its comment's premise - "there is no TCP socket to query" - was false.
- daemon behind a remote shell (`am_daemon < 0`): fd 0 is a pipe and
`getpeername` genuinely cannot work. Upstream seeds `"0.0.0.0"` then
takes the first of REMOTE_HOST, SSH_CONNECTION, SSH_CLIENT, SSH2_CLIENT,
truncated at the first space and kept only if it parses
(clientname.c:63-78). None of those four variables appeared anywhere in
the tree.
Both oc sites carried an `upstream:` comment asserting that upstream uses
`127.0.0.1:0`. It does not, on either path. Those comments are why the
hole survived review, and they are deleted.
The `0.0.0.0` seed is the security-relevant half: it matches no realistic
allow token, so a remote-shell daemon with no peer information in its
environment fails CLOSED where `127.0.0.1` failed open against exactly the
rule operators write to mean "local only".
Also mirrored: `getpeername` failure aborts with RERR_SOCKETIO rather than
substituting a placeholder (clientname.c:41-45), and an IPv4-mapped IPv6
peer (`::ffff:a.b.c.d`) is normalised to IPv4 before any ACL comparison
(clientname.c:47-74), which changes what an IPv4 `hosts allow` matches on a
dual-stack listener.
One deliberate, documented narrowing of the abort: a peer that has an
address but not an IP one - an AF_UNIX socketpair, as used by systemd
socket activation with `Accept=yes` and by RSYNC_CONNECT_PROG - degrades to
the same `0.0.0.0` sentinel instead of failing. Upstream serves that
configuration (its `getnameinfo` return is unchecked, leaving the address
empty); refusing it would have been a regression, and it is what the
existing `daemon_empty_digest_list_refused` tests exercise.
No unsafe is added: `socket2` is already a direct dependency of
`crates/daemon`, and `SockRef::from(&io::Stdin)` borrows fd 0 through
`AsFd` - the same construction `is_stdin_socket()` already uses.
Tests, one per entry point because a per-path test would have passed on
whichever path its author picked:
- `tests/daemon_stdio_peer_address_acl.rs` - remote shell. The loopback
rule must DENY (it ADMITTED before) and REMOTE_HOST must ADMIT (it would
have been DENIED before). Each is the other's control.
- `tests/daemon_inetd_peer_address_acl.rs` - inetd, peered over IPv6
loopback so the fabricated `127.0.0.1` and the true `::1` cannot
coincide. An earlier revision used `127.0.0.2` and silently SKIPPED on
macOS, proving nothing on half the matrix.
Non-vacuity was proven by restoring the fabricated address at each site
independently: 3 of 4 remote-shell cases and both inetd cases turn red.
* fix(daemon): gate normalize_v4_mapped to Unix, its only caller's platform
The three Windows cells were failing to BUILD, not to test:
Windows ACL/xattr step 7 "Build oc-rsync"
interop (Windows, best-effort) step 5 "Build oc-rsync"
Feature flags / concurrent-sessions step 9 "Test" (compiles first)
One cause for all three. `normalize_v4_mapped` is called only from
`inherited_socket_peer_addr`, which is `#[cfg(unix)]` - a V4MAPPED peer
can only arrive through the inetd stdin socket that function reads. On
Windows the caller is compiled out, the function is dead, and
`RUSTFLAGS: "-D warnings"` (set in `_interop-windows.yml:70` and
`_test-features.yml:77`) turns the `dead_code` warning into a build
failure. Its two unit tests are gated for the same reason.
MEASURED, not inferred. Windows-gnu cross-check on the PR head, which
reproduces the failure exactly:
cargo check --target x86_64-pc-windows-gnu --all-features -p daemon
warning: function `normalize_v4_mapped` is never used
--> crates/daemon/src/daemon/peer_address.rs:124:4
and after the fix, with `-D warnings` and `--all-targets`, plus the
`concurrent-sessions` feature cell separately: both clean.
⚠ It is NOT `SockRef::from(&stdin)`. That reading is structurally sound
about socket2 - on Windows the conversion needs `S: AsSocket`
(sockref.rs:97-100) and `std::io::Stdin` is `AsHandle` - but it does not
apply here, because BOTH `SockRef::from(&stdin)` sites were already
`#[cfg(unix)]` with explicit non-Unix arms (`peer_address.rs:155`,
`inetd.rs:23-37`), and the two remaining `SockRef::from` calls in
`inetd.rs` sit inside a `#[cfg(unix)]` test. Code that is not compiled on
Windows cannot be the Windows compile error. The other 14 `SockRef::from`
sites in `crates/daemon` all take a real `TcpListener`/`TcpStream`/
`UnixStream`, which do implement `AsSocket` where they are compiled.
No `#[allow(dead_code)]`: per the cross-platform policy the Windows arm
must be as explicit as the Unix one, and a suppressed warning would hide
the next instance of this exact class.
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.
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.
What
hosts allow/hosts denywere evaluated against a synthetic127.0.0.1:0on both stdio daemon entry points. The canonical "local only" rule admitted every client; an allow-list naming real subnets rejected every legitimate one. Broken in both directions depending on the config, and%a/%hmisattributed every audit line.The two paths are not the same case
That is what made the old code look defensible, and it is why the fix has two halves:
am_daemon > 0)client_addr()skips the env arm andclient_sockaddr()reads the peer viagetpeername(clientname.c:80-83, :37-45)127.0.0.1, with a comment claiming "there is no TCP socket to query"am_daemon < 0)"0.0.0.0", then the first ofREMOTE_HOST/SSH_CONNECTION/SSH_CLIENT/SSH2_CLIENT, truncated at the first space, kept only if it parses (clientname.c:63-78)127.0.0.1; none of those four variables appeared anywhere in the treeBoth sites carried an
upstream:comment asserting that upstream uses127.0.0.1:0. It does not, on either path, and on the inetd path the stated premise is simply false. Those comments are why the hole survived review; they are deleted and replaced with real citations.The
0.0.0.0seed is the security-relevant half: it matches no realistic allow token, so a remote-shell daemon with no peer information in its environment fails closed, where127.0.0.1failed open against exactly the rule operators write to mean "local only".Also mirrored
getpeernamefailure aborts withRERR_SOCKETIOrather than substituting a placeholder (clientname.c:41-45). Serving a session whose peer cannot be named would evaluate the ACL against nothing.::ffff:a.b.c.d→ IPv4) before any lookup or comparison (clientname.c:47-74). This changes what an IPv4hosts allowmatches on a dual-stack listener, so it is part of the ACL contract, not cosmetics.One deliberate, documented narrowing
A peer that has an address but not an IP one — an
AF_UNIXsocketpair, as used by systemd socket activation withAccept=yesand byRSYNC_CONNECT_PROG— degrades to the same0.0.0.0sentinel instead of aborting. Upstream serves that configuration:getpeernamesucceeds, and thegetnameinfothat follows fails but its return value is never checked (clientname.c:81), so the address is simply left empty. Both""and0.0.0.0match no realistic allow token, so the ACL outcome is identical; the sentinel just stops oc inventing an address it does not have.I found this the honest way: the first revision aborted, and it broke the existing
daemon_empty_digest_list_refusedtests, which hand the daemon aUnixStream::pair(). I verified those three pass on cleanorigin/masterbefore concluding it was my regression rather than a pre-existing failure.No new unsafe, no new dependency
socket2is already a direct dependency ofcrates/daemon(Cargo.toml:87, v0.6.5).SockRef::from(&io::Stdin)borrows fd 0 throughAsFd— the same constructionis_stdin_socket()already uses to classify that descriptor. The task anticipated relocating unsafe intofast_io; there is none to relocate.Tests — one per entry point
A per-path test would have passed on whichever path its author happened to pick, which is how this survived.
tests/daemon_stdio_peer_address_acl.rs(remote shell): the loopback rule must DENY (it ADMITTED before) andREMOTE_HOSTmust ADMIT (it would have been DENIED before, since the fabricated peer was never192.0.2.7). Each is the other's control. PlusSSH_CONNECTIONfirst-field truncation.tests/daemon_inetd_peer_address_acl.rs(inetd): the daemon's socket is peered over IPv6 loopback, so the fabricated127.0.0.1and the true::1cannot coincide, and both directions are asserted.⚠ An earlier revision of the inetd file used
127.0.0.2, which silently skipped on macOS (only127.0.0.1is configured there). It reported "2 passed" in 0.00s and proved nothing on half the CI matrix. Caught by checking--nocapturefor the skip reason rather than trusting the green.One case (
subnet_allow_does_not_admit_an_unknown_peer) is explicitly annotated as not discriminating —127.0.0.1fails a198.51.100.0/24rule too, so it passed pre-fix. It is kept for the second operator-visible symptom, and says so.Non-vacuity
Restoring the fabricated address at each site independently:
Verification
Scope
Task 401, covering 412 / 413 / 414. Deliberately not included: 416 (
%a/%h) is gated on this landing — rendering those from a fabricated address is the same defect in a costume — and 417, which on reading upstream turns out to be client-side (start_inband_exchange, clientserver.c:263), not daemon, and is unrelated to the peer address.