Repository navigation
fix: Nested collections multiply the 512MB allocation budget arbitrarily - #639
Merged
Merged
Conversation
Kriskras99
requested changes
Aug 26, 2026
|
|
||
| /// Debit `bytes` from the per-datum allocation budget, erroring when the | ||
| /// cumulative allocations for this datum would exceed it. | ||
| fn debit(&mut self, bytes: usize) -> AvroResult<()> { |
Contributor
There was a problem hiding this comment.
I think renaming this to debit_bytes would make it a lot clearer to future readers of the code
Comment on lines
+582
to
+585
| assert!( | ||
| result.is_err(), | ||
| "nested collections must share one allocation budget, got {result:?}" | ||
| ); |
Contributor
There was a problem hiding this comment.
Please check the error is actually Details::MemoryAllocation
martin-g
commented
Aug 26, 2026
decode.rs::decode_internal (for Schema::Array & Map): safe_collection_len bounds each individual Vec/HashMap against max_allocation_bytes, but no state tracks the running total across the decoded value tree. Elements that cost zero wire bytes (null, empty records, zero-size fixed) let each ~7-byte inner array<null> block materialize ~512MB of live Value slots, so array<array<null>> from an attacker OCF header holds K x 512MB simultaneously from ~130 datum bytes. Reported-by: Security scans
Co-authored-by: Kriskras99 <[email protected]> Co-authored-by: Martin Grigorov <[email protected]>
Co-authored-by: Kriskras99 <[email protected]>
martin-g
force-pushed
the
track-allocated-bytes-during-decoding
branch
from
August 26, 2026 09:55
08f2d01 to
5a7bb4a
Compare
Kriskras99
approved these changes
Aug 26, 2026
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.
decode.rs::decode_internal (for Schema::Array & Map): safe_collection_len bounds each individual Vec/HashMap against max_allocation_bytes, but no state tracks the running total across the decoded value tree. Elements that cost zero wire bytes (null, empty records, zero-size fixed) let each ~7-byte inner array block materialize ~512MB of live Value slots, so array<array> from an attacker OCF header holds K x 512MB simultaneously from ~130 datum bytes.
Reported-by: Security scans