Skip to content

Validate deserialized size in CircularFifoQueue.readObject#678

Merged
garydgregory merged 4 commits into
apache:masterfrom
digi-scrypt:circularfifoqueue-readobject-size-check
Jun 27, 2026
Merged

Validate deserialized size in CircularFifoQueue.readObject#678
garydgregory merged 4 commits into
apache:masterfrom
digi-scrypt:circularfifoqueue-readobject-size-check

Conversation

@digi-scrypt

Copy link
Copy Markdown
Contributor
  1. maxElements is reconstructed from the stream and the backing array is sized to it, but the element count read with readInt() is never checked against it.
  2. a count greater than maxElements writes past elements[] (ArrayIndexOutOfBoundsException), and a negative count yields a queue whose start/end are inconsistent so size() reports elements that were never read.

What happens with a tampered stream: have we considered that maxElements is final and trusted while the count beside it is not? Validated both (maxElements >= 1, 0 <= size <= maxElements) in readObject and throw InvalidObjectException, which keeps the check at the only layer that sees the raw stream.

@garydgregory garydgregory changed the title validate deserialized size in CircularFifoQueue.readObject Validate deserialized size in CircularFifoQueue.readObject Jun 27, 2026
@garydgregory garydgregory merged commit a7f8871 into apache:master Jun 27, 2026
10 checks passed
@garydgregory

Copy link
Copy Markdown
Member

TY @digi-scrypt , merged 🚀

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.

2 participants