tableFromIPC runs out of memory on a corrupted dictionary batch header instead of throwing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, typescript
- Domain
- backend-api-design, security
Research direction
Start by tracing tableFromIPC and RecordBatchReader through the IPC message header parsing and buffer allocation paths; the issue names no source files or tests. Check how declared nodes and buffers lengths are validated against available metadata, then add coverage using the supplied corrupted dictionary batch reproduction. Done means decoding rejects the malformed header with an error instead of exhausting memory.
Written by the indexing model from the issue text.
Description
Describe the bug, including details regarding any error messages, version, and platform.
Decoding an IPC stream with one corrupted vector length in a dictionary batch header makes tableFromIPC allocate until the process aborts with JavaScript heap out of memory, instead of throwing an error.
Version and platform: apache-arrow 21.2.0 (also 21.1.0), Node v26.13.0, macOS arm64.
Reproduction. The bytes are a valid stream from tableToIPC(tableFromArrays({ id: Int32Array.from([0, 0]), name: ["", ""] }), "stream"). Without the patch line it decodes 2 rows. (name is dictionary-encoded, so the stream holds a dictionary batch.) With it, the dictionary batch's buffers vector length goes from 3 to 0x06000003:
import { tableFromIPC } from "apache-arrow";
const bytes = Buffer.from(
"/////9gAAAAQAAAAAAAKABAADgAHAAgACgAAAAAAAAEIAAAAAAAEAKj///8EAAAAAgAAAHgAAAAUAAAAEAAcAAgADwAXABgABAAQABAAAAA4AAAAFAAAAAAAAAEYAAAAAAAABRgAAAAEAAAAbmFtZQAAAAAAAAAABAAEAAQAAAAIAAgAAAAEAAgAAAAEAAAAxP///wAAAAEgAAAAEAAUAAQAAAAPABAAAAAIABAAAAAQAAAAFAAAAAAAAAIYAAAAAgAAAGlkAAAAAAAACAAMAAgABwAIAAAAAAAAASAAAAD/////sAAAABQAAAAAAAAADAAcABoAEwAUAAQADAAAAAgAAAAAAAAAAAAAAAAAAAIQAAAAAAAEAAgACgAAAAQACAAAABAAAAAAAAoAGAAMAAgABAAKAAAAFAAAAEgAAAABAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////uAAAABQAAAAAAAAADAAWABQADwAQAAQADAAAABAAAAAAAAAAAAAAAxAAAAAEAAoAGAAMAAgABAAKAAAAFAAAAFgAAAACAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAA=",
"base64"
);
bytes[335] = 6;
tableFromIPC(bytes);
Observed: with the default heap, it runs for about 56 seconds, reaches about 2.7 GB resident and aborts:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
The same happens with byte 334 set to 255, and with the same header's nodes length (bytes 390 and 391). With --max-old-space-size=256 it aborts in a few seconds.
Expected: a thrown error saying the header is invalid. A vector length in a message header can't be larger than the metadata that holds it, so the reader could check each declared length (for example a batch's nodes and buffers) against the bytes present before allocating.
Why it matters: anything that decodes IPC it didn't produce, such as an Arrow Flight client reading FlightData from a server, can be stopped by one bad message. We now run a bounds check before decoding in our own Flight client, but every other consumer of tableFromIPC and RecordBatchReader is still exposed.
- Dominant language
- TypeScript
- Stars
- 114
- Forks
- 35
- Avg merge
- 13h 35m
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-js
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
The IPC reader accepts a column that is shorter than its RecordBatch, and fills the missing rows with nullsPossibly taken @Sealdot claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
The IPC reader ignores Schema.endianness: a big-endian stream reads 1, 2, 3 as 16777216, 33554432, 50331648Possibly taken @aniket-r2Dev2 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
tableFromIPC loops with no end on a file whose RecordBatch block points at a DictionaryBatchPossibly taken @aniket-r2Dev2 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
apache/arrow-js#547 · 1 comment ·
Maintainers usually reply within 1 day
-
The stream reader drops a message of an unexpected type but not its body, and parses the body as the next messagesPossibly taken @Umer-Butt07 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
earendil-works/gondolin#222 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
endora-commerce/endora-commerce#2203 ·
Maintainers usually reply within 1 day
-
enhancement priority:medium ready-for-human
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
wondermoney/wondermoney#1079 ·
Maintainers usually reply within 1 day