Skip to content

reject invalid message length in MessageSerializer.readMessage - #1361

Open
Support-itecz wants to merge 1 commit into
apache:mainfrom
Support-itecz:readmessage-invalid-length
Open

Support-itecz wants to merge 1 commit into
apache:mainfrom
Support-itecz:readmessage-invalid-length

Conversation

@Support-itecz

Copy link
Copy Markdown

What's Changed

MessageSerializer.readMessage reads the 4-byte little-endian length prefix and hands it straight to ByteBuffer.allocate(messageLength) without checking it. When a stream ends right after a continuation token (0xFFFFFFFF) messageLength is left at -1, and a malformed prefix can carry any other negative value. Both reach ByteBuffer.allocate with a negative argument and throw IllegalArgumentException, which escapes the IOException / end-of-stream contract that ArrowStreamReader, ArrowFileReader and MessageChannelReader rely on when reading untrusted input.

Treat a continuation token with no following length as end-of-stream (return null, matching how a short first read is already handled) and reject a negative length with an IOException before the allocation. The guard sits in readMessage because every IPC reader funnels through it.

AI assistance was used to prepare this change; I reviewed the diff and test results before submitting.

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