Skip to content

fix(protocol): guard flist name decode against length overflow - #5764

Merged
oferchen merged 1 commit into
masterfrom
fix/fuzz-flist-name-overflow
Jun 14, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/fuzz-flist-name-overflow

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

Closes the libFuzzer crash in the nightly Differential Fuzzer Overnight job (run 27491864218, all three targets: differential_flist / differential_multiplex / differential_outcome).

Root cause

`crates/protocol/src/flist/read/name.rs:90` performs `same_len + suffix_len` as plain `usize` addition.

The `suffix_len` value flows from `read_long_name_len`, which on both legacy (proto < 30) and modern (proto >= 30) codecs decodes a wire `i32` and casts to `usize`. A negative wire value (e.g. `0xFFFFFFFF`) silently becomes `usize::MAX`. The subsequent `255 + usize::MAX` addition then panics in debug builds with arithmetic overflow — exactly the libFuzzer-reported "deadly signal".

Fix (three layers of defense)

  1. `flist/read/name.rs:90` — replace bare `+` with `checked_add`. Returns a typed `InvalidData` error instead of panicking.
  2. `codec/protocol/legacy.rs::read_long_name_len` — explicitly reject negative i32 instead of silently widening to `usize::MAX`. Matches upstream's protocol-error treatment.
  3. `codec/protocol/modern.rs::read_long_name_len` — same negative-value guard on the varint path.

Wire compatibility

Zero wire-format change. Both fixes only convert previously-panicking inputs into typed `InvalidData` errors, which is what upstream rsync does for the same conditions.

Test plan

  • CI fmt+clippy + nextest stays green
  • Differential Fuzzer Overnight on next nightly run no longer crashes on this input

Three defensive fixes to close the libFuzzer crash in differential_flist:

1. `flist/read/name.rs:90` — replace `same_len + suffix_len` with
   `checked_add` so a malicious wire value cannot trigger an arithmetic
   overflow panic in debug builds (which is what libFuzzer caught).

2. `codec/protocol/legacy.rs::read_long_name_len` — reject negative
   `i32` wire values explicitly instead of silently widening to
   `usize::MAX`. Upstream's `read_int` treats this as a protocol error.

3. `codec/protocol/modern.rs::read_long_name_len` — same negative-value
   guard for the varint path.

Closes the differential_flist / differential_multiplex / differential_outcome
artifact crashes from the nightly fuzzer run (job 27491864218).

upstream: flist.c:719-722, read_varint30 dispatch
@github-actions github-actions Bot added the bug Something isn't working label Jun 14, 2026
@oferchen
oferchen merged commit 3eded02 into master Jun 14, 2026
44 of 69 checks passed
@oferchen
oferchen deleted the fix/fuzz-flist-name-overflow branch June 14, 2026 11:57
oferchen added a commit that referenced this pull request Aug 24, 2026
Three defensive fixes to close the libFuzzer crash in differential_flist:

1. `flist/read/name.rs:90` — replace `same_len + suffix_len` with
   `checked_add` so a malicious wire value cannot trigger an arithmetic
   overflow panic in debug builds (which is what libFuzzer caught).

2. `codec/protocol/legacy.rs::read_long_name_len` — reject negative
   `i32` wire values explicitly instead of silently widening to
   `usize::MAX`. Upstream's `read_int` treats this as a protocol error.

3. `codec/protocol/modern.rs::read_long_name_len` — same negative-value
   guard for the varint path.

Closes the differential_flist / differential_multiplex / differential_outcome
artifact crashes from the nightly fuzzer run (job 27491864218).

upstream: flist.c:719-722, read_varint30 dispatch
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