Repository navigation
Conversation
added 3 commits
November 24, 2026 16:04
…nce(Memory) Backport of apache#777 (merged as eb131f9 for 9.1.0) to 7.0.X. Part of the fix for CVE-2026-122096. getInstance(String) built the hash map from the length and numActive tokens without checking either against the map, so a crafted string could make deserialization, or a later update(), probe forever. Reject a map length below 1 << LG_MIN_MAP_SIZE or above the max map length, and numActive outside [0, capacity]. Apply the same lgCurMapSize checks to the binary preamble in getInstance(Memory). In 7.0.X the class is LongsSketch (renamed FrequentLongsSketch in 9.0.0).
Backport of apache#783 (merged as a6eac94 for 9.1.0) to 7.0.X. Part of the fix for CVE-2026-122096. ArrayOfStringsSerDe and ArrayOfUtf16StringsSerDe allocated the result array from numItems, and each item's byte array from its declared length, before checking either against the Memory capacity. Check that the Memory can hold numItems length prefixes before allocating the array, and check each item's length before allocating its bytes. Tests ported from StringSerDeBoundsTest, using Memory instead of MemorySegment.
Backport of apache/datasketches-java 4dc80fe (9.1.0) to 7.0.X. Part of the fix for CVE-2026-122096. This commit is not in apache#777 or apache#783, but Sketch.heapify() and the other theta deserializers are affected without it. - checkMemIntegrity(), used for updatable, alpha and union images (heapify and wrap): check lgNomLongs <= 26, 0 <= lgArrLongs <= lgNomLongs + 1 and 0 <= curCount <= table size, and compute the required size in long arithmetic. (8 << lgArrLongs) overflowed int for lgArrLongs >= 28, which let a 32-byte image pass the size check. - Compact images (heapify and wrap): check that curCount is non-negative and that the image holds the hashes. Images in hash-table form must hold the whole table. - Compressed images (serial version 4): check preLongs, entryBits and numEntriesBytes, and that the image holds numEntries * entryBits bits. - Intersection images (heapify and wrap): check 0 <= lgArrLongs <= 27, -1 <= curCount <= table size, and that the image holds the table when curCount > 0. 7.x only: serial version 1 and 2 images (ForwardCompatibility) computed the required size as (curCount + preLongs) << 3 in int arithmetic, which overflowed. Compute it in long arithmetic and reject a negative curCount. 9.x no longer reads these images. Tests ported from ThetaCorruptImageTest, using Memory instead of MemorySegment and without AllocationTracker, plus a test for the serial version 1 and 2 overflow.
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
This backports the 9.1.0 fixes for CVE-2026-122096 to the 7.0.X branch. 9.1.0 requires Java 25, so users on Java 17 cannot take the fix today. A 7.0.2 release from this branch would give them one.
Commits
The theta commit is not part of #777 or #783, but without it
Sketch.heapify(Memory)in 7.0.1 still allocates gigabytes from a 12 to 32 byte image.Differences from 9.1.0
LongsSketchinstead ofFrequentLongsSketch,Memoryinstead ofMemorySegment,UpdateSketch.checkMemIntegrity()instead ofcheckSegIntegrity().ForwardCompatibility(serial version 1 and 2 images) computed the required size as(curCount + preLongs) << 3in int arithmetic, which overflows. It is now computed in long arithmetic, and a negative curCount is rejected. 9.x no longer reads these images.Memoryand check forSketchesArgumentExceptionwithoutAllocationTracker, which 7.0.X does not have.Not included
The other 9.1.0 hardening commits: CountMin (8256f17), Frequencies binary item counts (c95fb7c), Tuple (8c2e288), ArrayOfDoubles (55d9b77), HLL (f8f41cd), Bloom (e004666), ArrayOfNumbersSerDe (3930b5a), Quantiles items (4e02458), REQ (024dc74), VarOpt (5061899) and CPC (9cf8254). They can be added to this PR or a follow-up if the PMC wants full parity for a 7.0.2 release.
Testing
mvn teston Java 17: 2192 tests, 0 failures.OutOfMemoryErrorinstead ofSketchesArgumentException, and the string SerDe tests fail without the bounds checks.Request
If the PMC accepts this, please consider releasing 7.0.2 and updating the CVE-2026-122096 record to list 7.0.2 as fixed, so dependency scanners stop flagging it.