Skip to content

fix: validate patch indices read from a file instead of panicking - #9741

Open
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:patches-validate-file-indices
Open

fix: validate patch indices read from a file instead of panicking#9741
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:patches-validate-file-indices

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Two fuzzer files reach a write loop through unvalidated patch indices: fuzz3.vortex panics in
BitBufferMut::set ("index 402653634 exceeds len 1024"), fuzz3b.vortex in patch_chunk's bare
index. Patches::new does bound the maximum, but derives it from indices[len - 1] — only the
maximum when the indices are sorted, and sortedness is asserted under debug_assertions only.

Each write site now scans the slice first, or checks the subtraction it was doing blind. Contained at
the use sites on purpose: the check belongs on Patches, but patches_from_slots and its nine call
sites are covered by five open PRs, and #9611 is replacing the type outright.

Tests

cargo test -p vortex-array -p vortex-alp goes 3435 → 3442; the two failures in both runs are
pre-existing (arrays::listview::tests::basic::*). Neutralising the two new guards fails 4 of the 5
new negative tests; a second mutation covers the fifth.

AI assistance

Written with agentic AI assistance; I traced both backtraces to their write loops and checked the
mutations fail.

Two fuzzer files reach a write loop through unvalidated patch indices:
fuzz3.vortex panics in BitBufferMut::set via BoolArray::patch, fuzz3b.vortex
in patch_chunk's bare index.

Patches::new does bound the maximum, but it derives it from indices[len - 1],
which is only the maximum when the indices are sorted, and sortedness is
asserted under debug_assertions only. Unsorted indices deserialized from a
file therefore pass construction and reach code that indexes without checking.

Each site that writes through patch indices now scans the slice up front, or
checks the subtraction it previously did blind. This is contained at the use
sites because patches_from_slots and its nine call sites are covered by five
open PRs, and one of them is replacing Patches outright.

Signed-off-by: jackylee <qcsd2011@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant