Harden RLE decompression against untrusted indices and offsets#8953
Open
joseph-isaacs wants to merge 2 commits into
Open
Harden RLE decompression against untrusted indices and offsets#8953joseph-isaacs wants to merge 2 commits into
joseph-isaacs wants to merge 2 commits into
Conversation
fastlanes 0.6.0 renames `RLE::{encode,decode}` to `unsafe
{encode,decode}_unchecked`, surfacing that the decoder performs
unchecked indexing into the run-values slice.
The encode call site trivially satisfies the contract (all arguments
are 1024-element arrays). The decode path now proves the contract
before entering the unchecked gather:
- `values_idx_offsets` (read from possibly untrusted storage) is
validated once per decompress: offsets must be non-decreasing and
span at most `values.len()`, bounding every per-chunk value slice.
- Chunks referencing zero values are rejected instead of underflowing
the null-position clamp.
- For all-valid chunks, a single SIMD-friendly max-reduction over the
1024 chunk indices verifies they are all below the chunk's value
count before `decode_unchecked`, keeping the bounds check out of the
per-element decode loop.
- The null-clamping path already bounds every index, so it calls
`decode_unchecked` directly.
Adds regression tests that corrupt indices and offsets must fail
decompression with an error rather than read out of bounds.
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L499Tv8CF7Aj7a3cABW9fp
The nullable-indices decode path previously clamped every index into range, which silently remapped a corrupt out-of-bounds index at a *valid* position to the last chunk value. Only null positions may legitimately hold garbage indices (e.g. after further compression of the indices child), so treat the two cases differently: - Materialize the indices validity mask once per decompress, then use a per-chunk SIMD popcount (`count_range`) to classify chunks. - Fully-valid chunks take the existing max-reduction bounds check. - Fully-null chunks skip the gather entirely (all values are masked). - Mixed chunks zero out the null positions via word-at-a-time `for_each_set_index` and then run the same max-reduction check, so an out-of-bounds index at a valid position now fails decompression with an error rather than being clamped. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L499Tv8CF7Aj7a3cABW9fp
joseph-isaacs
marked this pull request as ready for review
July 24, 2026 15:00
joseph-isaacs
force-pushed
the
claude/vortex-fastlanes-upgrade-pljujw
branch
from
July 27, 2026 10:24
b1dfdd4 to
c99326c
Compare
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.
Rationale for this change
The RLE decompression code didn't carefully validate indices.
This PR fixes that.