Skip to content

fix(core): take the rsync:// daemon host verbatim - #7431

Merged
oferchen merged 1 commit into
masterfrom
fix/daemon-host-no-percent-decode
Aug 21, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/daemon-host-no-percent-decode

Conversation

@oferchen

Copy link
Copy Markdown
Owner

oc rewrote the rsync:// 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 3.5.0
percent-decode %XX in host and username decoded; a lone % rejected as a malformed escape no percent-decoder exists anywhere
empty authority substituted localhost stays empty
leading/trailing whitespace trimmed kept

Each one fails 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
between 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:

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 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 localhost default: the cell returns to
overall 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 aarch64
host ("simdtest not built (SIMD not available)"). Environmental, not from this
change; CI's x86_64 runner is where that pass row 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 Linux
  • cargo fmt --all -- --check: clean on Linux
  • cargo clippy --workspace --all-targets --all-features --no-deps -D warnings: clean on Linux

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
@github-actions github-actions Bot added the bug Something isn't working label Aug 21, 2026
@oferchen
oferchen merged commit 9ecdd58 into master Aug 21, 2026
71 checks passed
@oferchen
oferchen deleted the fix/daemon-host-no-percent-decode branch August 21, 2026 22:39
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
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