]> git.ipfire.org Git - thirdparty/rsync.git/commit
defence-in-depth: bound wire-supplied counts and lengths
authorAndrew Tridgell <andrew@tridgell.net>
Wed, 31 Dec 2025 01:56:54 +0000 (12:56 +1100)
committerAndrew Tridgell <andrew@tridgell.net>
Thu, 7 May 2026 21:49:13 +0000 (07:49 +1000)
commitf0155902cb0392203b16f9d190b6cddba47967e6
tree755b7f5774c35bd7e70b4fa4b8d3e96aad1545fb
parent6b6d875a2e3f30a4309a4e09bdeeb774b1155915
defence-in-depth: bound wire-supplied counts and lengths

Multiple receiver-side fields read from the wire were trusted
without upper-bound checks. A hostile peer could either request
extreme allocations (DoS via --max-alloc) or, on platforms where
read_varint returned a negative value, push ~SIZE_MAX through the
size_t conversion to wrap downstream length checks.

Introduce read_int_bounded(), read_varint_bounded() and
read_varint_size() in io.c so wire-derived integer ranges are
checked at the read site rather than scattered across each
caller, with RERR_PROTOCOL on out-of-range input.

Apply the bounded primitives to:
  - sum->count (checksum count -- previously could overflow
    (size_t)count * xfer_sum_len on 32-bit with raised max-alloc)
  - xattrs: count, name_len, datum_len, plus rel_pos overflow
    detect to stop chain wrapping the num accumulator
  - acls: ida-entry count
  - flist: file mode S_IFMT validation, modtime_nsec range check
  - delete-stat counters in main: per-summand cap so the total
    can't overflow a signed 32-bit accumulator

Reporters include Joshua Rogers (checksum-count overflow finding).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
acls.c
flist.c
io.c
main.c
rsync.h
xattrs.c