Repository navigation
fix(server): bound a peer-named merge file by --confine-root - #7598
Merged
Merged
Conversation
oferchen
force-pushed
the
feat/confine-merge-file-open
branch
from
September 1, 2026 10:50
7a10545 to
3053c63
Compare
A dir-merge rule travels over the protocol as a filter rule, not in the
argv an rrsync wrapper validates, so the PEER names the merge file:
`--filter=':-s ../outside-secret'` reads a file beside the restricted
directory. An exclude-only merge turns every line into a pattern, so
nothing fails to parse and the file's contents come back as absences from
the file list - no error, no verbosity, and on a pull no --delete either.
oc walked the ownership of that open but never bounded it:
- `filters::merge_open::read_to_string` - the per-directory merge open
the generator scan and the receiver delete pass both use - took the
ANCILLARY entry point (`operator_read_to_string`), so the walk
followed a trusted symlink and judged nothing about where it landed.
Its sibling in the local-copy engine was already confined.
- Nothing published `--confine-root` into the walk's session. Both
`install_local_session` call sites passed `confine_root: None`, and
`--server` mode installed no session at all, so even the already
confined opens measured against an empty root.
Route the merge open through a new `operator_read_to_string_confined`,
and give `install_local_session` the root so the client and the
non-daemon server both publish it. A daemon still publishes its module
root instead, matching upstream's `am_daemon ? module_dir : confine_root`
- `--server --daemon` is dispatched before `run_server_mode`, so the arm
that honours a peer-supplied argv value is never a daemon.
The resolution is kernel-anchored, which is what the symlinked-source-arg
case needs: reached through `root/self-alias -> .`, the merge file's own
`../secret` normalises to `root/secret` textually - inside - while the
kernel lands outside. `AbsPathTracker` advances by RESOLVED components
from the physical cwd, so it sees the escape a string comparison cannot.
Second defect, found while measuring the cell: the server argv parser
filtered EVERY `.` operand as the cwd placeholder. Upstream consumes one
slot - `dir = argv[0]; argc--; argv++;` - whatever it holds, so
`rsync host:. dest/` (which rrsync emits as `-- . .`) left oc's server
with no operand at all: an empty file list and a silent rc=0 no-op.
Spend the placeholder once.
upstream: exclude.c:1668-1684 parse_filter_file() - the
`if (!daemon_config_filter_file) operator_path_resolve = 1;` around
`open_no_attacker_symlinks()`; syscall.c:186-240
abspath_outside_confinement(); syscall.c:311-322 - the `confine_root` arm
seeds `abspath` from getcwd() because "curr_dir is the lexical name
change_dir() was given"; syscall.c:136-144 confinement_root();
main.c:966-975 do_server_sender(); main.c:1192-1194 do_server_recv().
testsuite: rrsync-merge-file-confine flips fail -> pass in the nonroot
and root 3.5.0 manifests. Reverting either half reopens the escape and
reddens the cell.
oferchen
force-pushed
the
feat/confine-merge-file-open
branch
from
September 1, 2026 17:41
3053c63 to
626cf26
Compare
This was referenced Sep 1, 2026
oferchen
added a commit
that referenced
this pull request
Sep 2, 2026
…e tree (#7626) An accuracy audit of every performance, coverage and security claim in README.md and SECURITY.md against a workflow file, a committed manifest, a test or a measured number. Most of the 3.5.0 alignment already checked out; what follows is what did not. Stale testsuite outcomes. Both files carried 254/6 and 282/7 for the two full-corpus legs, "7 of 345 tests currently diverge", and "32 across all four". The committed manifests say 257/3 and 286/3, with 3 distinct divergences on the pipe legs and 29 across all four; #7596, #7598 and #7599 each fixed a divergence and flipped its manifest rows without refreshing the prose. Re-derived with the awk one-liner both files already publish. An unmeasured measurement. Both files said "a measured run of 100,000 sessions consumed a single bgid" as the evidence that the u16 bgid namespace cannot be exhausted. No such run exists in the tree, and it could not: per docs/audits/bgid-lifecycle.md section 5, BufferRing and BgidAllocator are constructed only inside fast_io and its tests, so an accepted connection consumes no bgid at all. The conclusion holds; the evidence for it is now the structural fact rather than an invented number. A benchmark shape no published release carries. The Performance section described the dual-baseline, peak-RSS, corpus-rate, spread-carrying report as what is "attached to every GitHub release", and the image alt text named both baselines. The linked image is served from the latest release, v0.6.4, whose benchmark_results.json has one baseline (3.4.4), a 148 MB corpus, and only mean/min/max per series. The paragraph now describes the harness and says plainly which releases predate it. MAX_WIRE_DEL_STAT. SECURITY cited crates/protocol/src/flist/delete_stats.rs, which does not exist, and claimed a cap "well below the upstream lowered ceiling". The reader is crates/protocol/src/stats/delete.rs and its cap is 1 << 28 - exactly upstream's rsync.h:187 value, unchanged in 3.4.4 and 3.5.0 - and it rejects rather than clamps. Parity is the right answer; "well below" was not. Landlock framing. README presented the daemon's Landlock layer as "cargo feature landlock", which reads as opt-in. crates/daemon pins fast_io with that feature under cfg(target_os = "linux"), so it is on in every Linux build including the released binaries. SECURITY's ABI enumeration stopped at v3 while the helper requests AccessFs::from_all(ABI::V5). Benchmark report: publish the sample size. stats() records `runs` with the stated intent that "a reader can tell a three-run cell from a six-run one", but the report left it in the JSON. A reset cell is timed 3 times with the warm-up discarded, so its median rests on 2 samples, and it rendered identically to a 6-run cell's median over 5. One `Runs` column per row states it - compare() hands every series in a row the same count - and the footnote now names which population the median and the spread each describe. benchmark_chart.py's no-baselines fallback said "3.4.4" while benchmark_report.py's said "3.5.0"; two renderers of one file would have named different upstream releases for the same run. Verified and left alone: the 33-CVE count, the five new options and three new daemon directives, the 13 Aug 2026 date, PROTOCOL_VERSION 32 / SUBPROTOCOL_VERSION 0 and byte-identical errcode.h (checked against the pinned 3.5.0 source); the 345/155 corpus sizes and the two tcp manifest rows; the interop version lists against run_interop.sh; the 26 fuzz targets against fuzz/Cargo.toml, name for name; the empty known-failures roster already described as historical; daemon-seccomp absent from the default set and from the release build; and every 3.4.4 mention that is deliberately about 3.4.4.
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.
The gap
Testsuite cell
rrsync-merge-file-confine(3.5.0) passes on upstream and failedon oc.
A dir-merge rule travels over the protocol as a filter rule, not in the argv an
rrsyncwrapper validates, so the peer names the merge file.--filter=':-s ../outside-secret'reads a file beside the restricted directory,and because an exclude-only merge turns every line into a pattern, nothing fails
to parse: the file's contents come back as absences from the file list. No
error, no verbosity, and on a pull no
--deleteeither.oc walked the ownership of that open but never bounded it. Two halves were
missing, and each is independently load-bearing:
filters::merge_open::read_to_string- the per-directory merge open thegenerator scan and the receiver delete pass both use - took the ancillary
entry point (
operator_read_to_string), so the walk followed a trustedsymlink and judged nothing about where it landed. Its sibling in the
local-copy engine (
engine::local_copy::dir_merge::load::open_merge_file)was already confined.
--confine-rootinto the walk's session. Bothinstall_local_sessioncall sites passedconfine_root: None, and--servermode installed no session at all, so even the already-confinedopens measured against an empty root.
The fix
fast_io::operator_read_to_string_confined, the confined counterpart ofoperator_read_to_string(asoperator_open_read_confinedis tooperator_open_read). The filters seam routes onto it - one seam, three callsites (
enter_directory,load_inline_dir_merge,merge::read::read_rules).install_local_sessionnow carries the--confine-rootroot, and both theclient (
workflow::run::execute) and the non-daemon server(
run_server_mode) publish it. A daemon still publishes its module root(
install_daemon_session), matching upstream'sam_daemon ? module_dir : confine_root;--server --daemonis dispatchedbefore
run_server_mode, so the arm that honours a peer-supplied argv valueis never a daemon.
Without
--confine-rootthe session is(optout=false, root=None)on bothpaths - byte-identical to today - so nothing changes for an ordinary transfer.
Kernel-anchored, not lexical
The cell's second leg reaches the tree through
root/self-alias -> ., sorsync's tracked path sits one component deeper than the kernel's. The merge
file's own
../secretthen normalises toroot/secrettextually - insidethe root - while the kernel lands outside:
AbsPathTrackeralready advanced by RESOLVED components, seeded fromstd::env::current_dir()(the physical cwd), which is upstream's ownrequirement at
syscall.c:311-322.crates/fast_io/tests/confine_root_merge_alias.rspins it, with
lexical_normalisation_lands_inside_the_rootas the instrumentcheck: the fixture is provably invisible to a string comparison.
Second defect, found while measuring
The server argv parser filtered every
.operand as the cwd placeholder.Upstream consumes one slot -
dir = argv[0]; argc--; argv++;- whatever itholds, so
rsync host:. dest/(which rrsync emits as-- . .) left oc's serverwith no operand at all. Measured: an empty file list and a silent
rc=0no-op,in both directions. The placeholder is now spent once.
Two existing cells asserted
pos_args.is_empty()for-- . .; they encodedthis behaviour and are corrected to
["."].Sites deliberately left alone
daemon::sections::module_access::helpers::read_patterns_from_file- thedaemon's own
include from/exclude from. Upstream exempts exactly these(
if (!daemon_config_filter_file)); they legitimately live outside themodule.
daemon::operator_file(config, motd, secrets) - operator-configured, andupstream opens them with
operator_path_resolve = 0.--files-fromopens - a different option family, and one upstream namesamong the opens that "may legitimately live elsewhere" (
syscall.c:232-239).$HOME/.cvsignore- named by--cvs-exclude, not by the peer.cli::frontend::filter_rules::sources(--*clude-from, CLImerge) and thelocal-copy engine loader - both already confined.
Upstream
exclude.c:1668-1684parse_filter_file()- theif (!daemon_config_filter_file) operator_path_resolve = 1;aroundopen_no_attacker_symlinks()syscall.c:186-240abspath_outside_confinement()syscall.c:311-322- theconfine_rootarm seedsabspathfromgetcwd()because "
curr_diris the lexical namechange_dir()was given"syscall.c:136-144confinement_root()main.c:966-975do_server_sender(),main.c:1192-1194do_server_recv()Evidence
Upstream control - 3.5.0 built from the pinned tree:
PASS.oc before:
FAIL- "the server read a merge file outside the restricted dir".Mutation A - revert
merge_opento the ancillary open, rebuild, rerun:FAIL, andstraceshows the escape as syscalls:with
secretwordmissing from the delivered file list. With the fix the walkstops at the confinement check and
secretwordarrives.Mutation B - keep the confined open but drop the server's
install_local_session(.., confine_root), rebuild, rerun:FAIL, sameassertion. Each half is independently load-bearing: the routing without the
published root confines nothing, and the published root without the routing is
never consulted at that open.
Non-vacuity - the cell carries its own controls, and both hold: an in-tree
.rsync-filteris still read and obeyed (intree-droppedexcluded,intree-keptdelivered), and the in-tree merge reached through the SAMEsymlinked source arg still works.
confine_root_merge_alias.rsrepeats both atthe resolver level, plus an ancillary-open control showing
--log-fileand the--*-fromfamily are still not bound by the root.Both testsuite legs, Linux (aarch64), 3.5.0, pipe transport:
daemon-scan-cwd-desync(EAGAIN under a loaded VM - passes 3/3 re-run inisolation) and
simd-checksum(skipped,simdtestnot built on this host).rrsync-merge-file-confinePASS.batch-file-symlink(passes in isolation on a re-run - the char-device fixture flaked under load)
and
simd-checksumagain.rrsync-merge-file-confinePASS.--expect-resultfails on an unexpected PASS too, so the manifest flip isconfirmed by the run rather than asserted.
cargo nextest run -p fast_io -p filters: 2349 passed, 0 failed.Clippy
-D warningsclean on the pinned 1.88.0 toolchain;tools/ci/check_rustfmt_all.pyclean.