CVE-2026-102554: Google Guava: CompactHashMap/CompactHashSet/MapMakerInternalMap deserialization triggers uncontrolled memory allocation
Google Guava (com.google.guava:guava) 4.0 through 33.7.1 lets a tiny crafted Java serialization stream crash a JVM with OutOfMemoryError. CompactHashMap, CompactHashSet and MapMakerInternalMap size their arrays from an attacker-declared count during deserialization. Any app that deserializes untrusted data with Guava on the classpath is exposed. Upgrade to 33.7.2.
Published Oct 27, 2026 · Analysis Nov 1, 2026
What an attacker can do
CompactHashMap.readObject() reads an elementCount from the stream and only checks that it is not negative. The first put() calls allocArrays(), which allocates a hash table and three arrays sized to that count, up to 2^30-1. CompactHashSet and the linked variants share the path. MapMakerInternalMap takes a size from the stream, stores it in a MapMaker, and allocates segments with that capacity during deserialization.
The reporter built a 72-byte stream with one small element and a patched count of 0x3FFFFFFF. It forced about 4.1 GB of allocation on an 8 GB heap before OutOfMemoryError, and killed a 128 MB heap in 24 ms.
The attacker needs a path to feed bytes into ObjectInputStream.readObject() in an app that has Guava on its classpath. The attacker names the Guava class directly, so the app does not need to use these collections itself. The result is denial of service only: no code execution and no data exposure. It is the same shape as the older CVE-2018-10237 in AtomicDoubleArray.
Who is affected
Affected: com.google.guava:guava from 4.0 up to and including 33.7.1, both the jre and android flavors. The reporter confirmed 33.7.1-jre and did not test older releases individually. Your risk depends on whether any code path deserializes untrusted Java objects, for example RMI, JMS, session stores, caches or custom TCP protocols. Check the resolved version:
mvn dependency:tree -Dincludes=com.google.guava:guavaFor Gradle, run gradle dependencies --configuration runtimeClasspath and look for guava. Check shaded jars as well.
com.google.guava:guava
- Ecosystem
- Maven
- Affected
- >= 4.0, <= 33.7.1
- Fixed in
- 33.7.2
- Check
mvn dependency:tree -Dincludes=com.google.guava:guava
How to fix it
Upgrade to Guava 33.7.2. The release notes say deserialization of MapMaker, CompactHashMap and CompactHashSet no longer eagerly allocates as much memory as the payload requests.
mvn versions:use-dep-version -Dincludes=com.google.guava:guava -DdepVersion=33.7.2In Gradle, set the guava dependency to 33.7.2. Rebuild any fat jars that bundle or shade Guava. The advisory gives no other workaround. Separately, avoid native Java deserialization of untrusted input, or restrict it with an ObjectInputFilter allow-list.
How to tell if you were hit
Look for java.lang.OutOfMemoryError: Java heap space whose stack trace passes through ObjectInputStream.readObject and CompactHashMap.allocArrays, CompactHashSet.allocArrays or MapMakerInternalMap. Sudden heap spikes followed by restarts right after a request carrying a serialized object point to exploitation. Check network logs for very small binary payloads that start with the Java serialization magic bytes 0xACED0005 sent to services that deserialize input.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
CompactHashMap/CompactHashSet/MapMakerInternalMap native deserialization triggers uncontrolled memory allocation
Summary
CompactHashMap, CompactHashSet, and MapMakerInternalMap implement readObject(ObjectInputStream) by reading an attacker-controlled elementCount or initialCapacity from the stream. On the very first insertion during or after deserialization (for the CompactHash* collections, inside allocArrays()) or immediately during deserialization (for MapMakerInternalMap), the implementation eagerly allocates arrays sized to that full, unvalidated value (up to CompactHashing.MAX_SIZE = 2^30-1, ~1.07 billion, for example) before the rest of the stream's actual content has been consumed. A 72-byte malicious serialized stream containing a single tiny element can force a multi-gigabyte allocation and crash a JVM with OutOfMemoryError, dynamically confirmed against the current release.
Details
CompactHashMap.readObject() (guava/src/com/google/common/collect/CompactHashMap.java):
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int elementCount = stream.readInt();
if (elementCount < 0) {
throw new InvalidObjectException("Invalid size: " + elementCount);
}
init(elementCount);
for (int i = 0; i < elementCount; i++) {
K key = (K) stream.readObject();
V value = (V) stream.readObject();
put(key, value);
}
}elementCount is only checked for being non-negative; there is no upper bound and no relationship enforced between the declared count and how much data actually follows in the stream. init(elementCount) (line 251) just stores the value (clamped to [1, CompactHashing.MAX_SIZE], i.e. up to 2^30-1):
void init(int expectedSize) {
Preconditions.checkArgument(expectedSize >= 0, "Expected size must be >= 0");
this.metadata = Ints.constrainToRange(expectedSize, 1, CompactHashing.MAX_SIZE);
}The real allocation is deferred to allocArrays(), which fires lazily on the *first* put() call — i.e. after only one key/value pair has actually been read off the wire:
int allocArrays() {
...
int expectedSize = metadata;
int buckets = CompactHashing.tableSize(expectedSize);
this.table = CompactHashing.createTable(buckets);
setHashTableMask(buckets - 1);
this.entries = new int[expectedSize];
this.keys = new Object[expectedSize];
this.values = new Object[expectedSize];
return expectedSize;
}With expectedSize near CompactHashing.MAX_SIZE (2^30-1), this single call allocates a hash table plus three expectedSize-length arrays — multiple gigabytes — triggered by a stream that has, at that point, only supplied one small real element. CompactHashSet.readObject()/allocArrays() have the identical shape. CompactLinkedHashMap/CompactLinkedHashSet extend these classes and inherit the same unguarded path.
The problem with MapMakerInternalMap is similar, with a size read from the serialized data and stored in a `MapMaker` instance for later user during deserialization, when the `MapMaker` is passed back to `MapMakerInternalMap` and segments are allocated by calling `newSegment`, whose implementations (example) create Segment instances (example) that allocate arrays of the requested capacity through the `newTable` helper.
This is the same amplification shape as the already-fixed CVE-2018-10237 (AtomicDoubleArray/CompoundOrdering: attacker declares a large size, library eagerly allocates before validating against actual stream content). That fix rewrote AtomicDoubleArray.readObject() to grow an ImmutableLongArray.Builder incrementally per element actually read, rather than pre-allocating from the declared size — Guava's own HashBiMap.readObject() documents the same defensive principle explicitly in a comment: init(16); // resist hostile attempts to allocate gratuitous heap. CompactHashMap/CompactHashSet do not follow either of these two patterns already present elsewhere in the same codebase.
Reachability: All classes are top-level, implements ... Serializable, and require no special classpath setup beyond Guava being present (near-ubiquitous on JVM backends). A native Java deserialization attacker names the class directly in a hand-crafted stream — no particular Guava factory method needs to have been used by the victim application, exactly as with the precedent CVE.
PoC
Full source and run instructions in the attached poc-guava-compacthash-dos.zip (Maven project, guava:33.7.1-jre — the current latest release — as the only dependency). The PoC:
- Uses reflection only to legitimately obtain a
CompactHashSetinstance (it is package-private; a real attacker does not need this step, since they craft the serialized bytes directly rather than calling Guava's own serialization code). - Serializes one set with 1 element and one with 2 elements, diffs the two byte streams to locate the exact offset of the
elementCountfield (byte-precise, not guessed). - Patches that one 4-byte field in the 1-element stream from
1to0x3FFFFFFF(CompactHashing.MAX_SIZE), leaving the rest of the 72-byte stream (one real"A"element) untouched. - Feeds the resulting 72-byte malicious stream into a plain
new ObjectInputStream(...).readObject()call against the real, unmodifiedguava-33.7.1-jre.jar.
Actual run output:
### -Xmx8g (generous heap) ###
Located size field at offset 63, value=1 (expected 1)
Malicious stream size: 72 bytes
Declared elementCount: 1073741823 (~1.07 billion)
Real payload: 1 tiny string element ("A")
=== RESULT ===
Exception: java.lang.OutOfMemoryError: Java heap space
Time to allocate+fail: 4013 ms
Heap used before: 3 MB
Heap used after (at failure point): 4103 MB
JVM max heap (-Xmx): 8192 MB
### -Xmx128m (ordinary service-sized heap) ###
Located size field at offset 63, value=1 (expected 1)
Malicious stream size: 72 bytes
Declared elementCount: 1073741823 (~1.07 billion)
Real payload: 1 tiny string element ("A")
=== RESULT ===
Exception: java.lang.OutOfMemoryError: Java heap space
Time to allocate+fail: 24 ms
Heap used before: 4 MB
Heap used after (at failure point): 2 MB
JVM max heap (-Xmx): 128 MBA 72-byte input forces ~4.1 GB of real allocation before failing on an 8 GB heap, and crashes a 128 MB heap in 24 ms — over 50,000x amplification between input size and forced allocation.
To reproduce: mvn -q compile dependency:build-classpath -Dmdep.outputFile=cp.txt && java -Xmx128m -cp "target/classes:$(cat cp.txt)" poc.Poc
Impact
Uncontrolled resource consumption (CWE-770 / CWE-400) via native Java deserialization: any application that runs ObjectInputStream.readObject() on data reachable by an attacker, and has Guava on its classpath (true for a large fraction of the JVM ecosystem), can be crashed with a single ~72-byte payload, regardless of what type the application itself expected to deserialize.
Severity
CVSS 3.1: AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H — identical vector to CVE-2018-10237, the precedent this is a sibling of. Recomputed with the full formula: exploitability = 8.22×0.85×0.44×0.85×0.85 = 2.221; ISS = 1-(1×1×0.44) = 0.56; impact = 6.42×0.56 = 3.595; base = roundup(5.816) = 5.9 (Medium).
Affected
com.google.guava:guava, all editions (-jre/-android) — confirmed on the current latest release, 33.7.1-jre. CompactHashMap/CompactHashSet/CompactLinkedHashMap/CompactLinkedHashSet have had this same readObject/allocArrays shape for a long time (probably since they were added in Guava 23.6), and similarly for MapMakerInternalMap (which was introduced in Guava 4.0); not tested against older individual releases.
Suggested fix
Apply the same defense already used elsewhere in this codebase: either clamp the initial init() capacity to a small constant regardless of the declared elementCount (as HashBiMap.readObject() already does — init(16); // resist hostile attempts to allocate gratuitous heap) and grow incrementally as elements are actually read, or grow the backing arrays incrementally per iteration of the deserialization loop (as the fixed AtomicDoubleArray.readObject() does via ImmutableLongArray.Builder) instead of eagerly sizing to the full attacker-declared count on first insert.
Credited to kemrec.
Questions
- Is CVE-2026-102554 exploited in the wild?
No source reports exploitation, and it is not in CISA KEV. The advisory includes a working proof of concept. The EPSS score is 0.0035.
- Does it give remote code execution?
No. The impact is availability only: a small payload forces a huge allocation and an OutOfMemoryError. The CVSS 3.1 vector has no confidentiality or integrity impact.
- Am I affected if I never use CompactHashMap?
Possibly. The attacker writes the class name into the serialized stream. If your app calls readObject on untrusted data and Guava is on the classpath, the class can be instantiated.
- Which Guava version is fixed?
33.7.2. Affected versions run from 4.0 through 33.7.1.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
