fix: bound decodeString/decodeBytes growth to avoid OOM on untrusted length#4
Open
moshap-firebolt wants to merge 1 commit into
Open
fix: bound decodeString/decodeBytes growth to avoid OOM on untrusted length#4moshap-firebolt wants to merge 1 commit into
moshap-firebolt wants to merge 1 commit into
Conversation
…length Avro string/bytes values carry a length prefix that is attacker controlled when the Avro data is untrusted (e.g. Iceberg manifest files). decodeString and decodeBytes resized their destination to that full length in one call, so a malformed multi-GiB length triggered a huge allocation (OOM) before a single byte was read and the stream was found to be far shorter. Grow the destination in bounded 1 MiB chunks instead: a bogus length now fails on the "EOF reached" thrown by readBytes() after only a bounded allocation, while well-formed values still read in full.
Author
|
Review pass: this change looks correct to me. The bounded 1 MiB chunk growth in decodeString/decodeBytes prevents attacker-controlled OOM from oversized length prefixes while still streaming valid payloads correctly. I also checked that all PR checks are passing. |
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.
Problem
BinaryDecoder::decodeString/decodeBytesread a length prefix and thenresize()the destination to that full length in a single call before readingany bytes. The length prefix is attacker-controlled when the Avro data is
untrusted (e.g. Iceberg manifest files read by PackDB). A malformed multi-GiB
length triggers a huge allocation — an OOM — before the decoder discovers the
stream is far shorter than the declared length.
Surfaced by PackDB's
iceberg_avrolibFuzzer harness: a mutated length prefixin the Avro file's metadata map (
map<string,bytes>) drove a ~2 GiBstd::string::resizeinreadHeader(), reported as a libFuzzer OOM.Fix
Grow the destination in bounded 1 MiB chunks. A bogus length now fails on the
"EOF reached"exception thrown byreadBytes()after only a boundedallocation, while well-formed values still read in full (identical bytes).
Test
iceberg_avrofuzzer, then confirmedthe crash input runs clean (exit 0, 2 ms) with this change.