Repository navigation
fix(batch): close two replay-script injections in the generated .sh - #7445
Merged
Merged
Conversation
Two independent ways a crafted name reached the shell when an operator ran BATCH.sh, both reproduced against the rsync 3.5.0 testsuite with the real 3.5.0 binary passing as the control. 1. write-batch-quoting - shell_quote implemented upstream 3.4.x's CONDITIONAL quoting: it wrapped an argument only when `strpbrk` matched a special-character set. That set omits the backtick, `<`, `>` and the braces, so a destination named `d`>PWNED`x/` was written bare and the command substitution EXECUTED on replay. Upstream 3.5.0 rewrote write_arg (batch.c:164-198) to single-quote unconditionally, and its own comment gives the reason: every metacharacter - backtick, newline, redirection - must stay literal. Two further rules changed with it: an embedded `'` now uses the POSIX close/escape/reopen idiom `'\''` rather than `''`, and the bare `-opt=` prefix is emitted only when the option name is `[-_0-9A-Za-z]`, so an attacker-shaped `-a`cmd`=v` is quoted whole. Switching to `'\''` also fixes a silent data-loss bug the old form had: `'a''b'` collapses to `ab`, so an option value containing a quote was corrupted by the generated script. The round-trip test that pinned that loss as a known limitation now pins the opposite - the quote survives. 2. write-batch-filter-injection - the filter here-doc had no newline guard, so a rule whose pattern contained a newline could forge the `#E#` terminator on a line of its own and append arbitrary shell to the script. Upstream refuses fail-closed per rule (batch.c:213-240, RERR_SYNTAX); the refusal goes in serialize_filter_rules, the last layer that still sees rules individually - by the time the script emitter runs they are one flattened string where a rule-internal newline is indistinguishable from the separator between rules. Tests: the existing shell_quote goldens encoded the 3.4.x rules and are re-based against the 3.5.0 C source, not against current oc output. Added a case per metacharacter the old set missed, with the live backtick exploit first, plus the conditional-prefix rows in both directions. Verified: write-batch-quoting and write-batch-filter-injection both PASS (upstream 3.5.0 passes both as control); core+batch 3035/3035; fmt and workspace clippy clean.
The manifest is the ledger: with the injections closed, both cells pass, and leaving the rows at `fail` would report an unexpected PASS and redden the required legs. Measured green against a freshly built binary, with each fix mutated in isolation to prove the row is earned - reverting shell_quote to the conditional form reds write-batch-quoting alone, and disabling the newline guard reds write-batch-filter-injection alone, each leaving the other cell green as its non-vacuity control. Row counts unchanged at 349 on both legs.
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
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.
What
Two independent ways a crafted name reached the shell when an operator ran the
BATCH.sha--write-batchrun generates. Both reproduce against the rsync3.5.0 testsuite, with the real 3.5.0 binary passing as the control.
1.
write-batch-quoting- the option quoter was upstream 3.4.xshell_quoteimplemented upstream's conditional quoting: wrap an argumentonly when
strpbrkmatches a special-character set. Its doc even cited the set,"'&;|[]()$#!*?^\- which omits the backtick,<,>and the braces. Adestination named
d`>PWNED`x/was therefore written bare, and the commandsubstitution executed on replay.
Upstream 3.5.0 rewrote
write_arg(batch.c:164-198) to single-quoteunconditionally, and its own comment gives the reason: every metacharacter -
backtick, newline, redirection - must stay literal. Two further rules changed
with it, and all three are ported:
strpbrkhits'''(close/reopen)'\''(close/escape/reopen)-opt=prefix=exists-to the=is[-_0-9A-Za-z]The third rule matters on its own: without it an attacker-shaped
-a`cmd`=vgets its
-acmd=half emitted outside the quotes.Bonus defect closed. Switching to
'\''also fixes silent data loss the oldform had:
'a''b'collapses toab, so an option value containing a quote wascorrupted by the generated replay script. The round-trip test that pinned
that loss as a known limitation now pins the opposite - the quote survives.
2.
write-batch-filter-injection- the filter here-doc had no newline guardFilter rules are replayed through a here-doc terminated by
#E#. Nothingrejected a rule whose pattern contained a newline, so a pattern could forge that
terminator on a line of its own and append arbitrary shell to the script.
Upstream refuses fail-closed, per rule (
batch.c:213-240):strchr(pattern, '\n')->rprintf(FERROR, ...)+exit_cleanup(RERR_SYNTAX). Ported verbatim,message included.
Placement is the substance here. The refusal goes in
serialize_filter_rules, the last layer that still sees rules individually.By the time the script emitter runs they are one flattened string, where a
rule-internal newline is indistinguishable from the separator between rules - a
check there could only guess.
Tests
The existing
shell_quotegoldens encoded the 3.4.x rules, so they had to bere-based - against the 3.5.0 C source, not against current oc output, which
would have made them tautological. Added:
first;
--no_iconv='x'takes theprefix,
'-a`b=c'does not);''\'''and'a'\''b'for the new escape idiom.Verification
write-batch-quotingandwrite-batch-filter-injection: PASS. Real rsync3.5.0 passes both as the control.
shell_quoteto theconditional form reds
write-batch-quotingand leaveswrite-batch-filter-injectiongreen; disabling the newline guard redswrite-batch-filter-injectionand leaveswrite-batch-quotinggreen. Eachcell is the other's non-vacuity control, so neither row can be passing for the
other fix's reason.
cargo fmt --all -- --checkclean;cargo clippy --workspace --all-targets --all-features --no-deps -- -D warningsclean.cargo nextest run -p core -p batch --all-features: 3035 passed. The onefailure,
run_client_sparse_copy_creates_holes, passes in isolation and is arecorded APFS parallel-run flake unrelated to this change.
Manifest
Both rows flip
fail->passinupstream-3.5.0-expect.{nonroot,root}.txtin the same PR. Row counts unchanged at 349 per leg. The TCP manifests do not
carry these cells.