Skip to content

[Java] Check var-data length and group blockLength in the OTF decoder - #1154

Draft
slachiewicz wants to merge 3 commits into
aeron-io:masterfrom
slachiewicz:java-otf-wire-length-checks
Draft

slachiewicz wants to merge 3 commits into
aeron-io:masterfrom
slachiewicz:java-otf-wire-length-checks

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

OtfMessageDecoder passed the wire var-data length straight to the listener, and JsonTokenListener allocated a byte[] of that length before reading. A frame whose length prefix runs past the buffer therefore made JsonPrinter allocate up to 2 GB, or fail with OutOfMemoryError. The decoder also accepted a group blockLength of 0, which lets nested group headers expand the JSON output without bound.

The decoder now throws IndexOutOfBoundsException for an out-of-range var-data length, and for a group blockLength below the non-constant fields present at the acting version (composite members added in a later version do not count). JsonTokenListener checks the length itself before allocating.

Part of #969.

Verified: five of the new JsonPrinterTest cases fail on master (OutOfMemoryError, out-of-bounds read, accepted short block) and all pass here; sbe-tool checkstyle, tests, verifyJavaIrCodecsInSync and sbe-samples check pass.

@slachiewicz
slachiewicz force-pushed the java-otf-wire-length-checks branch 2 times, most recently from cc56604 to 9fdae95 Compare November 19, 2026 21:00
OtfMessageDecoder rejects a var-data length past the buffer and a group
blockLength below the non-constant fields of the acting version, and
JsonTokenListener checks the length before it allocates.
@slachiewicz
slachiewicz force-pushed the java-otf-wire-length-checks branch from 9fdae95 to 3d08c88 Compare November 27, 2026 15:17
@slachiewicz
slachiewicz marked this pull request as draft November 27, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant