Repository navigation
fix(alp): bounds-check ALP-RD stored metadata and left-parts codes - #10760
Open
devtechedge wants to merge 1 commit into
Open
devtechedge wants to merge 1 commit into
devtechedge wants to merge 1 commit into
Conversation
ALP-RD deserialize and decode paths trust stored metadata, so a corrupt file can panic a read instead of returning an error. deserialize bounds-checks the stored dict_len against the stored dictionary, validate rejects dictionaries above MAX_DICT_SIZE and a right_bit_width at or above the float bit width, and both decode paths error on a left-parts code outside the dictionary instead of panicking or decoding garbage. Partially addresses vortex-data#10756. Signed-off-by: devtechedge <devtechedge@gmail.com>
This branch has not been deployed
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.
Summary
ALP-RD's
deserializeand decode paths trust stored metadata, so a corrupt or crafted file can panic a read instead of returning an error.This covers the ALP-RD items from the issue that #10755 does not:
deserializenow bounds-checks the storeddict_lenagainst the stored dictionary, andvalidaterejects a dictionary longer thanMAX_DICT_SIZEand aright_bit_widthat or above the float's bit width, which is the bound the decode shift requires.Left-parts codes are checked on first use:
alp_rd_decodescans the codes once before decoding, andscalar_atuses a checked lookup, because both decode paths index (or mask into) the dictionary with each code.The
left_parts_ptypeand RLE items from the issue look like they belong to #10755, so they are not touched here.Partially addresses #10756.
Changes
deserializebails whendict_lenexceeds the stored dictionary entries.validate_partsrejects dictionaries aboveMAX_DICT_SIZEand aright_bit_widthat or above the float's bit width, covering deserialized and in-memory arrays.alp_rd_decodeerrors on a left-parts code outside the dictionary before decoding.scalar_atuses a checked dictionary lookup.Each check has a regression test that feeds corrupt metadata through the plugin deserialize path, which is the same door a file read uses, plus a first-use test for an out-of-dictionary code and a control showing valid metadata still decodes.
The repro from the issue panics on develop and returns an error with this change.
The suite for
vortex-alppasses locally (179 tests), along withclippyandfmton the pinned toolchains.This change was developed with AI assistance (GLM-5.3); I reviewed the diff, ran the tests, and stand behind it.