Repository navigation
fix(matching): bound the equal-weak-checksum chain in the delta matcher - #7293
Merged
Merged
Conversation
The signature that populates the matcher's hash chain is peer-supplied. A crafted basis whose blocks all share one weak checksum turned the per-offset chain walk into an O(source_len * chain_len) scan, so a hostile peer could pin a sender CPU for hours (CVE-2026-70453). Measured on the crafted fixture (release, 64 KiB source, aarch64): 373 ms at 500 colliding blocks rising linearly to 1077 ms at 4000, against 138 ms for a same-size basis with distinct rolling sums. The zsync BitHash prefilter and the compact bucket key do not help here - every candidate carries the probed rolling sum, so all of them are admitted. Mirror upstream's rule from match.c: cap the candidates verified at one source offset at MAX_CHAIN_LEN (1024) and treat an over-long chain as a non-match, which rolls the window forward a byte and sends the skipped data as literals. The counter sits after the prune skips, matching upstream's placement after its own chain unlink, so a duplicate basis block is still matched by the first live candidate and the bound stays observably neutral on honest bases. The two probe paths that walked the chain are collapsed onto one walk_chain helper so the rule has a single home. Tests sweep the class rather than one case: the candidate's position across the boundary, the bound across chain lengths, delta correctness when the bound is reached, and an inertness check that no chain in a 10000-block realistic basis comes near the cap.
oferchen
enabled auto-merge (squash)
August 13, 2026 18:19
oferchen
added a commit
that referenced
this pull request
Aug 21, 2026
…te (#7423) The changelog had not been touched since 2026-08-13 (#7279) while ~140 PRs merged, and several factual claims in README/SECURITY had drifted far enough to mislead an operator. Each correction below was verified against the tree, not inferred. CHANGELOG: fill in Unreleased for everything merged since #7279, grouped by Security / Added / Changed / Fixed / Testing and CI / Documentation. SECURITY: - The 3.5.0 divergence figure said 133. The committed expect manifests say 43 + 62 on the two full-corpus legs (64 distinct) and 89 across all four. Replaced the estimate with the per-leg table and the manifest mechanism. - The CI paragraph described the 3.5.0 suite as a separate nightly job. It is now the required gate, four legs, on every pull request. - CVE-2026-53791: the placeholder-peer-address prerequisite is fixed (#7303), not pending. CVE-2026-70452, -70463 and -70453 are fixed (#7314, #7345, #7293) and were still listed as under audit. - The new-defensive-surface paragraph listed all eight 3.5.0 additions as being adopted; four have shipped and two directives have not. - The fuzz list named 24 targets including "rsyncd_conf", which does not exist in fuzz/fuzz_targets. There are 26; added the three real ones that were missing. - The buffer-pool hardening note claimed recycle_buffer guards buf_id with a debug assertion and warned against exposing io_uring to untrusted input. The check is a real release-mode bound returning BufferIdOutOfRange before any state is mutated, so the warning was false. README: - Status and interop sections listed 3.5.0 as built-and-cached ahead of gating; run_interop.sh has it in the gating version list, and the protocol table row still said "not yet gating". - Added the current 3.5.0 testsuite outcomes rather than only describing the mechanism, so the 64 open divergences are stated plainly. - The CVE line stopped at the 2024 batch; the 3.4.3 batch is closed and 3.5.0 is partially closed and tracked. - The spill CLI flags were described as planned for STN-11; both exist. - The OC_RSYNC_BUFFER_POOL variables were attributed to the io_uring registered pool. All three live in crates/engine/src/local_copy/ buffer_pool/ and tune the engine pool; the io_uring pool is a different, static one. - The bgid note advised monitoring for exhaustion that measurement shows does not occur. - Fixed a broken link: compressed_token/zstd_codec is a directory. - Listed the shipped 3.5.0 option surface in the feature table.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…er (#7293) The signature that populates the matcher's hash chain is peer-supplied. A crafted basis whose blocks all share one weak checksum turned the per-offset chain walk into an O(source_len * chain_len) scan, so a hostile peer could pin a sender CPU for hours (CVE-2026-70453). Measured on the crafted fixture (release, 64 KiB source, aarch64): 373 ms at 500 colliding blocks rising linearly to 1077 ms at 4000, against 138 ms for a same-size basis with distinct rolling sums. The zsync BitHash prefilter and the compact bucket key do not help here - every candidate carries the probed rolling sum, so all of them are admitted. Mirror upstream's rule from match.c: cap the candidates verified at one source offset at MAX_CHAIN_LEN (1024) and treat an over-long chain as a non-match, which rolls the window forward a byte and sends the skipped data as literals. The counter sits after the prune skips, matching upstream's placement after its own chain unlink, so a duplicate basis block is still matched by the first live candidate and the bound stays observably neutral on honest bases. The two probe paths that walked the chain are collapsed onto one walk_chain helper so the rule has a single home. Tests sweep the class rather than one case: the candidate's position across the boundary, the bound across chain lengths, delta correctness when the bound is reached, and an inertness check that no chain in a 10000-block realistic basis comes near the cap.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…te (#7423) The changelog had not been touched since 2026-08-13 (#7279) while ~140 PRs merged, and several factual claims in README/SECURITY had drifted far enough to mislead an operator. Each correction below was verified against the tree, not inferred. CHANGELOG: fill in Unreleased for everything merged since #7279, grouped by Security / Added / Changed / Fixed / Testing and CI / Documentation. SECURITY: - The 3.5.0 divergence figure said 133. The committed expect manifests say 43 + 62 on the two full-corpus legs (64 distinct) and 89 across all four. Replaced the estimate with the per-leg table and the manifest mechanism. - The CI paragraph described the 3.5.0 suite as a separate nightly job. It is now the required gate, four legs, on every pull request. - CVE-2026-53791: the placeholder-peer-address prerequisite is fixed (#7303), not pending. CVE-2026-70452, -70463 and -70453 are fixed (#7314, #7345, #7293) and were still listed as under audit. - The new-defensive-surface paragraph listed all eight 3.5.0 additions as being adopted; four have shipped and two directives have not. - The fuzz list named 24 targets including "rsyncd_conf", which does not exist in fuzz/fuzz_targets. There are 26; added the three real ones that were missing. - The buffer-pool hardening note claimed recycle_buffer guards buf_id with a debug assertion and warned against exposing io_uring to untrusted input. The check is a real release-mode bound returning BufferIdOutOfRange before any state is mutated, so the warning was false. README: - Status and interop sections listed 3.5.0 as built-and-cached ahead of gating; run_interop.sh has it in the gating version list, and the protocol table row still said "not yet gating". - Added the current 3.5.0 testsuite outcomes rather than only describing the mechanism, so the 64 open divergences are stated plainly. - The CVE line stopped at the 2024 batch; the 3.4.3 batch is closed and 3.5.0 is partially closed and tracked. - The spill CLI flags were described as planned for STN-11; both exist. - The OC_RSYNC_BUFFER_POOL variables were attributed to the io_uring registered pool. All three live in crates/engine/src/local_copy/ buffer_pool/ and tune the engine pool; the io_uring pool is a different, static one. - The bgid note advised monitoring for exhaustion that measurement shows does not occur. - Fixed a broken link: compressed_token/zstd_codec is a directory. - Listed the shipped 3.5.0 option surface in the feature table.
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.
Problem
The delta matcher's hash chain is populated from the peer-supplied signature. A crafted basis whose blocks all share one weak (rolling) checksum makes every source offset walk the entire chain, turning the scan into
O(source_len * chain_len)— the quadratic-CPU DoS fixed upstream in rsync 3.5.0 as CVE-2026-70453.oc has the defect. The two probe paths in
crates/matching/src/index/mod.rswalkedCompactLookup::find_allto exhaustion with no bound, and neither zsync-inspired structure helps here:sum1discriminator +sum2bucket) does not discriminate, because every candidate carries exactly the probed sum.Measured
Fixture: a basis of blocks crafted to share the all-zero window's rolling sum
(0, 0)while differing in content, probed with an all-zero source so every offset hits the chain and never matches. Release build, 64 KiB source, aarch64:Linear in chain length at fixed source size (~0.20 ms per 1000 blocks), i.e.
O(source_len * chain_len). Extrapolating the measured ~3.15 ns per candidate step, a 1 GiB source against a 40000-block chain is on the order of tens of hours of pure CPU — matching the multi-hour hangs upstream reports.Fix
Mirror upstream's rule from
match.cexactly:MAX_CHAIN_LEN = 1024;The counter is placed after the prune skips, mirroring upstream's placement after its own chain unlink. That is what keeps the bound observably neutral: a duplicate basis block is still matched by the first live candidate rather than by walking past a thousand dead ones.
The two probe paths that each carried their own copy of the chain walk are collapsed onto a single
walk_chainhelper, so the rule (prune skips + bound + strong compare) has one home.Neutrality
Delta output is unchanged for non-malicious input:
bound_is_inert_on_a_realistic_basisasserts that in a 10000-block pseudo-random basis the longest chain is far below the cap, and that an identical source still resolves to pureCopytokens;zsync_wire_parity,parallel_delta_wire_parity,seq_match_golden,block_matching_accuracy) are green;crates/protocolis upstream ofcrates/matchingin the dependency graph, so the protocol golden-byte tests cannot be affected by this change;engineandtransfer, which do consume the matcher, are green.Tests
New
crates/matching/src/index/chain_bound_tests.rs, written over the class rather than one hand-picked case:candidate_is_reachable_exactly_below_the_bound— sweeps the candidate's position across the boundary (0, 1, 2, 512, 1022, 1023, 1024, 1025, 1199); reachable exactly whileposition < MAX_CHAIN_LEN.bound_holds_across_chain_lengths— sweeps chain length (1, 2, 16, 1023, 1024, 1025).skipped_data_is_sent_literally_not_corrupted— the delta over a hostile basis is pure literal andapply_deltareproduces the source byte for byte.bound_is_inert_on_a_realistic_basis— the neutrality check above.crafted_blocks_collide_on_the_weak_checksum_only— validates the fixture construction itself (all blocks share the rolling sum, none share a strong sum, all land in one chain).bound_matches_upstream_max_chain_len— pins the constant to upstream's literal 1024, so oc cannot drift to a limit upstream does not have.Non-vacuity confirmed: with the bound removed,
candidate_is_reachable_exactly_below_the_boundfails at position 1024 withSome(1024)instead ofNone.Verification
Follow-up noted, deliberately not in scope
oc's consumed-block prune (ZSO-3) skips chain entries rather than unlinking them the way upstream unlinks its bypassed in-place entries. Those skipped entries stay on the chain and are re-walked on every later probe, so a basis with a very large run of genuinely duplicate blocks retains an unbounded walk over dead entries. That is an oc-only characteristic, distinct from CVE-2026-70453, and bounding it by counting skipped candidates would break output neutrality against upstream. The correct fix is to unlink consumed entries, which touches the
&self-shared lookup structure — a separate change.