Repository navigation
fix(core): take the rsync:// daemon host verbatim - #7431
Merged
Merged
Conversation
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
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
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.
oc rewrote the
rsync://daemon host three ways before anything could judgeit. Upstream rewrites it in none of them:
check_for_hostspec(
options.c:3295) takes the host as written and hands the same bytes togetaddrinfo, or, underRSYNC_CONNECT_PROG, toshell_unsafe_connect_host(
socket.c:204-215).%XXin host and username%rejected as a malformed escapelocalhostEach one fails in the same direction: the validator can only refuse what
reaches it.
%selfwas rejected as a bad escape before the connect-program guard couldrefuse it - and refusing it is the point, since a nested fish expands
%selfto its pid.rsync:///mod/silently dialled a host the operator never named. Measuredagainst the pinned 3.5.0 binary: upstream fails in
getaddrinfowith anempty 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.
rsync:// localhost /m/under aconnect program is refused by upstream as shell-unsafe (space is outside the
allowed byte set) while oc handed the program a clean
localhost. Trimmingconverted a host upstream refuses into one it accepts.
An IPv6 zone id (
fe80::1%eth0) relies on the same literal treatment, whichis why the decoder needed a zone-id fallback to paper over itself.
DaemonAddress::newtherefore cannot fail and no longer returnsResult; itsempty-host rejection existed only to be routed around by the
localhostdefault. The CONNECT-header CRLF guard in
proxy.rsis now the only thingbetween a hostile host and the request line, and its comment says so rather
than describing the trim that used to precede it.
Measured
Against the pinned upstream 3.5.0 binary as the control, on Linux:
connect-prog-host-quotingconnect-prog-nested-singlequote-host-injectionThe nested cell needs both this change and #7430 - neither flips it alone,
which is why #7430's body claimed no row and this one carries all four
manifest flips (nonroot, root, and both TCP legs).
RED proven by restoring only the
localhostdefault: the cell returns tooverall result is 1.Full nonroot leg at this commit: 219 passed / 40 failed / 86 skipped = 345,
and the only expected-result mismatch is
simd-checksum: expected pass, got skip- which the real upstream 3.5.0 binary also skips on this aarch64host ("simdtest not built (SIMD not available)"). Environmental, not from this
change; CI's x86_64 runner is where that
passrow was generated.⚠ 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.
Gates
cargo nextest run -p core --all-features --lib: 2558/2558 on Linuxcargo fmt --all -- --check: clean on Linuxcargo clippy --workspace --all-targets --all-features --no-deps -D warnings: clean on Linux