Repository navigation
fix(core): validate and quote the RSYNC_CONNECT_PROG %H substitution - #7430
Merged
Merged
Conversation
…am cells Both rows of testsuite/connect-prog-host-quoting_test.py are now covered directly, and the assertions that recorded the pre-fix unquoted rendering are inverted rather than deleted: upstream substitutes the single-quoted host (socket.c:495), so an empty host and a byte outside the allowed set are refusals, not renderings.
Same defect class as the previous commit; found by sweeping every format_command call in the module rather than only the one the failing run named.
oferchen
added a commit
that referenced
this pull request
Aug 21, 2026
oc rewrote the daemon host three ways before anything could judge it. Upstream rewrites it in none of them: `check_for_hostspec` (options.c:3295) takes the host as written and hands the same bytes to `getaddrinfo`, or, under `RSYNC_CONNECT_PROG`, to `shell_unsafe_connect_host` (socket.c:204-215). | rewrite | oc before | upstream | |---|---|---| | percent-decode `%XX` in host and username | decoded, and rejected a lone `%` as a malformed escape | no percent-decoder exists anywhere | | empty authority | substituted `localhost` | stays empty | | leading/trailing whitespace | trimmed | kept | Each one is load-bearing in the same direction: the validator can only refuse what reaches it. - `%self` was rejected as a bad escape before the connect-program guard could refuse it - and refusing it is the point, since a nested fish expands `%self` to its pid. - `rsync:///mod/` silently dialled a host the operator never named. Measured against the pinned 3.5.0 binary: upstream fails in `getaddrinfo` with an empty node, and refuses the empty host outright under `RSYNC_CONNECT_PROG` (an empty argument survives a direct exec but vanishes when a nested shell re-splits, shifting every later argument left). - Trimming is not cosmetic. Measured: `rsync:// localhost /m/` under a connect program is refused by upstream as shell-unsafe (space is outside the allowed byte set) while oc handed the program a clean `localhost`. Trimming converted a host upstream refuses into one it accepts. An IPv6 zone id (`fe80::1%eth0`) relies on the same literal treatment, which is why the decoder needed a zone-id fallback to paper over itself. `DaemonAddress::new` therefore cannot fail and no longer returns `Result`; its empty-host rejection existed only to be routed around by the `localhost` default. The CONNECT-header CRLF guard in `proxy.rs` is now the only thing standing between a hostile host and the request line, and its comment says so. ## Measured Against the pinned upstream 3.5.0 binary as the control, on Linux: | cell | before | after | upstream 3.5.0 | |---|---|---|---| | `connect-prog-host-quoting` | pass | pass | pass | | `connect-prog-nested-singlequote-host-injection` | fail | **pass** | pass | The nested cell needed both this change and #7430; neither flips it alone. Its four manifest rows flip in this commit. RED proven by restoring only the `localhost` default: the cell returns to `overall result is 1`. ⚠ The empty-host parse had no test at all before this - that absence is why the substitution survived. It is pinned now, with a named-host companion so the pin cannot pass by everything coming back empty. - `cargo nextest run -p core --all-features --lib`: 2558/2558 on Linux - `cargo fmt --all -- --check` and `cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings`: both clean on Linux
oferchen
added a commit
that referenced
this pull request
Aug 21, 2026
oc rewrote the daemon host three ways before anything could judge it. Upstream rewrites it in none of them: `check_for_hostspec` (options.c:3295) takes the host as written and hands the same bytes to `getaddrinfo`, or, under `RSYNC_CONNECT_PROG`, to `shell_unsafe_connect_host` (socket.c:204-215). | rewrite | oc before | upstream | |---|---|---| | percent-decode `%XX` in host and username | decoded, and rejected a lone `%` as a malformed escape | no percent-decoder exists anywhere | | empty authority | substituted `localhost` | stays empty | | leading/trailing whitespace | trimmed | kept | Each one is load-bearing in the same direction: the validator can only refuse what reaches it. - `%self` was rejected as a bad escape before the connect-program guard could refuse it - and refusing it is the point, since a nested fish expands `%self` to its pid. - `rsync:///mod/` silently dialled a host the operator never named. Measured against the pinned 3.5.0 binary: upstream fails in `getaddrinfo` with an empty node, and refuses the empty host outright under `RSYNC_CONNECT_PROG` (an empty argument survives a direct exec but vanishes when a nested shell re-splits, shifting every later argument left). - Trimming is not cosmetic. Measured: `rsync:// localhost /m/` under a connect program is refused by upstream as shell-unsafe (space is outside the allowed byte set) while oc handed the program a clean `localhost`. Trimming converted a host upstream refuses into one it accepts. An IPv6 zone id (`fe80::1%eth0`) relies on the same literal treatment, which is why the decoder needed a zone-id fallback to paper over itself. `DaemonAddress::new` therefore cannot fail and no longer returns `Result`; its empty-host rejection existed only to be routed around by the `localhost` default. The CONNECT-header CRLF guard in `proxy.rs` is now the only thing standing between a hostile host and the request line, and its comment says so. ## Measured Against the pinned upstream 3.5.0 binary as the control, on Linux: | cell | before | after | upstream 3.5.0 | |---|---|---|---| | `connect-prog-host-quoting` | pass | pass | pass | | `connect-prog-nested-singlequote-host-injection` | fail | **pass** | pass | The nested cell needed both this change and #7430; neither flips it alone. Its four manifest rows flip in this commit. RED proven by restoring only the `localhost` default: the cell returns to `overall result is 1`. ⚠ The empty-host parse had no test at all before this - that absence is why the substitution survived. It is pinned now, with a named-host companion so the pin cannot pass by everything coming back empty. - `cargo nextest run -p core --all-features --lib`: 2558/2558 on Linux - `cargo fmt --all -- --check` and `cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings`: both clean on Linux
oferchen
added a commit
that referenced
this pull request
Aug 21, 2026
oc rewrote the daemon host three ways before anything could judge it. Upstream rewrites it in none of them: `check_for_hostspec` (options.c:3295) takes the host as written and hands the same bytes to `getaddrinfo`, or, under `RSYNC_CONNECT_PROG`, to `shell_unsafe_connect_host` (socket.c:204-215). | rewrite | oc before | upstream | |---|---|---| | percent-decode `%XX` in host and username | decoded, and rejected a lone `%` as a malformed escape | no percent-decoder exists anywhere | | empty authority | substituted `localhost` | stays empty | | leading/trailing whitespace | trimmed | kept | Each one is load-bearing in the same direction: the validator can only refuse what reaches it. - `%self` was rejected as a bad escape before the connect-program guard could refuse it - and refusing it is the point, since a nested fish expands `%self` to its pid. - `rsync:///mod/` silently dialled a host the operator never named. Measured against the pinned 3.5.0 binary: upstream fails in `getaddrinfo` with an empty node, and refuses the empty host outright under `RSYNC_CONNECT_PROG` (an empty argument survives a direct exec but vanishes when a nested shell re-splits, shifting every later argument left). - Trimming is not cosmetic. Measured: `rsync:// localhost /m/` under a connect program is refused by upstream as shell-unsafe (space is outside the allowed byte set) while oc handed the program a clean `localhost`. Trimming converted a host upstream refuses into one it accepts. An IPv6 zone id (`fe80::1%eth0`) relies on the same literal treatment, which is why the decoder needed a zone-id fallback to paper over itself. `DaemonAddress::new` therefore cannot fail and no longer returns `Result`; its empty-host rejection existed only to be routed around by the `localhost` default. The CONNECT-header CRLF guard in `proxy.rs` is now the only thing standing between a hostile host and the request line, and its comment says so. ## Measured Against the pinned upstream 3.5.0 binary as the control, on Linux: | cell | before | after | upstream 3.5.0 | |---|---|---|---| | `connect-prog-host-quoting` | pass | pass | pass | | `connect-prog-nested-singlequote-host-injection` | fail | **pass** | pass | The nested cell needed both this change and #7430; neither flips it alone. Its four manifest rows flip in this commit. RED proven by restoring only the `localhost` default: the cell returns to `overall result is 1`. ⚠ The empty-host parse had no test at all before this - that absence is why the substitution survived. It is pinned now, with a named-host companion so the pin cannot pass by everything coming back empty. - `cargo nextest run -p core --all-features --lib`: 2558/2558 on Linux - `cargo fmt --all -- --check` and `cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings`: both clean on Linux
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7430) * wip: connect-prog host validation (production only) * test(core): pin RSYNC_CONNECT_PROG host validation against the upstream cells Both rows of testsuite/connect-prog-host-quoting_test.py are now covered directly, and the assertions that recorded the pre-fix unquoted rendering are inverted rather than deleted: upstream substitutes the single-quoted host (socket.c:495), so an empty host and a byte outside the allowed set are refusals, not renderings. * test(core): quote the two remaining port-boundary expectations Same defect class as the previous commit; found by sweeping every format_command call in the module rather than only the one the failing run named. * style(core): satisfy rustfmt and clippy on the host-safety helpers * style(core): match rustfmt's line width on the safe-byte predicate
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
oc rewrote the daemon host three ways before anything could judge it. Upstream rewrites it in none of them: `check_for_hostspec` (options.c:3295) takes the host as written and hands the same bytes to `getaddrinfo`, or, under `RSYNC_CONNECT_PROG`, to `shell_unsafe_connect_host` (socket.c:204-215). | rewrite | oc before | upstream | |---|---|---| | percent-decode `%XX` in host and username | decoded, and rejected a lone `%` as a malformed escape | no percent-decoder exists anywhere | | empty authority | substituted `localhost` | stays empty | | leading/trailing whitespace | trimmed | kept | Each one is load-bearing in the same direction: the validator can only refuse what reaches it. - `%self` was rejected as a bad escape before the connect-program guard could refuse it - and refusing it is the point, since a nested fish expands `%self` to its pid. - `rsync:///mod/` silently dialled a host the operator never named. Measured against the pinned 3.5.0 binary: upstream fails in `getaddrinfo` with an empty node, and refuses the empty host outright under `RSYNC_CONNECT_PROG` (an empty argument survives a direct exec but vanishes when a nested shell re-splits, shifting every later argument left). - Trimming is not cosmetic. Measured: `rsync:// localhost /m/` under a connect program is refused by upstream as shell-unsafe (space is outside the allowed byte set) while oc handed the program a clean `localhost`. Trimming converted a host upstream refuses into one it accepts. An IPv6 zone id (`fe80::1%eth0`) relies on the same literal treatment, which is why the decoder needed a zone-id fallback to paper over itself. `DaemonAddress::new` therefore cannot fail and no longer returns `Result`; its empty-host rejection existed only to be routed around by the `localhost` default. The CONNECT-header CRLF guard in `proxy.rs` is now the only thing standing between a hostile host and the request line, and its comment says so. ## Measured Against the pinned upstream 3.5.0 binary as the control, on Linux: | cell | before | after | upstream 3.5.0 | |---|---|---|---| | `connect-prog-host-quoting` | pass | pass | pass | | `connect-prog-nested-singlequote-host-injection` | fail | **pass** | pass | The nested cell needed both this change and #7430; neither flips it alone. Its four manifest rows flip in this commit. RED proven by restoring only the `localhost` default: the cell returns to `overall result is 1`. ⚠ The empty-host parse had no test at all before this - that absence is why the substitution survived. It is pinned now, with a named-host companion so the pin cannot pass by everything coming back empty. - `cargo nextest run -p core --all-features --lib`: 2558/2558 on Linux - `cargo fmt --all -- --check` and `cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings`: both clean on Linux
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…7477) The docs were last refreshed at #7423; 55 PRs have merged since, and the testsuite figures they quote had drifted far enough to understate the current state by roughly half. CHANGELOG: fill in Unreleased for everything merged since #7423. The dominant theme is routing every operator-named auxiliary file open onto the ownership walk - upstream's open_no_attacker_symlinks() applied at the call sites upstream applies it - plus a daemon hardening batch and an alt-dest correctness batch. README and SECURITY: the per-leg outcome tables were re-derived from the committed expect manifests rather than carried forward. Failures fell and the corpus grew, so every figure moved: non-root pipe 43 -> 21 fail (345 -> 349 corpus) root pipe 62 -> 29 fail (345 -> 349 corpus) non-root tcp 42 -> 29 fail (155 -> 158 corpus) root tcp 55 -> 38 fail (155 -> 158 corpus) Distinct divergences: 64 -> 31 across the two full-corpus legs, 89 -> 55 across all four. SECURITY, two CVE rows that had gone stale: - CVE-2026-53790 said "under audit". The refusal has since been applied at the live sink - oc-rsync's own single-character config expander, which upstream does not have, so an upstream-shaped port alone would have been inert (#7465, #7430, #7445). - CVE-2026-53795 listed only the staging family. The auxiliary-file family followed it onto the walk (#7421-#7426, #7439, #7441-#7443, #7459, #7463); what remains is the per-option-family confinement.
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.
Ports upstream 3.5.0's two
RSYNC_CONNECT_PROGhost defences, which oc didnot have at all.
What was wrong
%His substituted into a command string that a shell runs. oc substitutedthe host with zero validation and no quoting, so a host taken from an
rsync://HOST/modoperand became shell syntax rather than data.Upstream applies two defences, both inside
if (prog && strchr(prog, '%'))(
socket.c:488-495), so a template with no specifier never inspects the host:socket.c:204-215shell_unsafe_connect_host()socket.c:152shell_quote_connect_host()The refusal is not redundant with the quoting. Quoting keeps a host one word
but cannot stop a leading
-/+looking like an option to the namedprogram,
~rootbeing tilde-expanded by a nested shell, or%selfbeingexpanded by a nested fish - those change an argument's meaning, not its text.
An empty host is refused for the same reason: it survives a direct exec as an
empty argument but vanishes when a nested shell re-splits, shifting every
later argument left.
Measured
Against the real upstream 3.5.0 binary as the control, on Linux:
connect-prog-host-quotingconnect-prog-nested-singlequote-host-injection⚠ This change flips no manifest row, and the PR does not claim one.
connect-prog-host-quotingwas already recordedpass; the cell thatactually exercises the guard is the nested one, and it still fails for an
independent reason given below. The change is upstream fidelity plus a real
injection defence, not a row flip - stated plainly rather than implied.
⚠ METHOD NOTE. My first control run used
rsyncfromPATH, which is3.4.1 here - it fails the nested cell too, which would have read as
"fixture-limited, not an oc bug" and closed the investigation. Re-run against
the pinned 3.5.0 binary, upstream passes and the residual is oc's. A control
from
PATHis not a control.The residual, surfaced rather than folded in
The nested cell now fails on exactly one row: host
%selfis not refused,because it never reaches the validator. oc percent-decodes the daemon host
(
module_list/parsing.rs,invalid percent-encoding in daemon host) with anIPv6-zone fallback, so
%selfis rejected as a malformed escape before theconnect-program path runs.
Upstream 3.5.0 has no percent-decoding of the daemon host anywhere -
verified by reading, not assumed:
%is a literal hostname byte, which is why%selfreachesshell_unsafe_connect_host()and is refused there. So oc'sdecode is an invention, and removing it is the upstream-fidelity direction.
It is left out of this PR deliberately: it is a user-visible behaviour change
to every
rsync://URL, it has its own tests asserting the current error, andthe IPv6-zone fallback exists only to paper over the decode. That belongs in
its own reviewable change, not bolted onto a security fix.
Tests
Both upstream cells are transcribed directly, row for row - the refuse set
(
localhost;touch${IFS}pwned;#,-c,+x,~root,%self, empty) and theaccept set (
example.com,example.com.,host_name,host+alias,host~alias,fe80::1%eth0), so an allow-list that simply refused everythingcannot pass. Plus the no-specifier gate, and a direct pin on the
'\''escapeformat_commandby construction, since'is outsidethe allowed byte set, so it is pinned against its own helper instead of
through a path that cannot reach it.
Nine existing assertions recorded the pre-fix unquoted rendering. They are
inverted, not deleted:
format_command("example.com")now yieldsconnect to 'example.com', and the empty-host anduser@hostcases becomerefusals. The end-to-end
run_module_list_uses_connect_program_commandtestis untouched and still passes - the outer shell strips the quotes, which is
the demonstration that the quoting is transparent to a real connect program.
⚠ The first two rounds fixed only the assertions a failing run named. The
third round swept every
format_commandcall in the module and found two more(
port_zero,port_max) that no run had reached yet.cargo nextest -p core --all-features --lib -E 'test(connect) or test(format_command) or test(shell_quote)': 181/181 on Linuxcargo fmt --all -- --checkclean andcargo clippy --workspace --all-targets --all-features --no-deps -- -D warningsclean, both verifiedon Linux (macOS
cargo fmtreported clean while Linux rustfmt did not)