You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
arrow-ipc: a footer block's declared body length is zero-filled before it is read #10921
arrow_ipc::reader::read_block (reader.rs:922) sizes its buffer from the
footer's Block before reading:
let body_len = block.bodyLength().to_usize().unwrap();
let metadata_len = block.metaDataLength().to_usize().unwrap();
let total_len = body_len.checked_add(metadata_len).unwrap();
let mut buf = MutableBuffer::from_len_zeroed(total_len);
reader.read_exact(&mut buf)?;
A 1,018-byte file whose footer holds a record-batch block with bodyLength = 0x280000000240 (44 TB) reaches from_len_zeroed, which
ASan reports as allocation-size-too-big and which aborts the process on
a normal build. read_exact would have returned UnexpectedEof had the
allocation been bounded — the check exists one line too late. FileReader::try_new verifies the footer's flatbuffer but not that its
blocks lie within the file.
To Reproduce
cargo new ipc-repro && cd ipc-repro
cargo add [email protected]
# copy the attached block-body.arrow beside Cargo.toml
// src/main.rs
fn main() {
let file = std::fs::File::open("block-body.arrow").unwrap();
let reader = arrow_ipc::reader::FileReader::try_new(file, None).unwrap();
for batch in reader {
println!("{:?}", batch.map(|b| b.num_rows()));
}
}
cargo run --release
Expected behavior
Err(ArrowError::IpcError(..)) — the block is beyond the file.
Additional context
FileReader knows the file's length (it seeks to the footer). Checking
each block's offset + metaDataLength + bodyLength <= file_len when the
footer is parsed — or reading with a length-capped take into a growing
buffer in read_block — turns this into an error. The MessageReader
path (reader.rs:1845, from_len_zeroed(message.bodyLength())) has the
same shape for the stream format.
Linux x86_64, Rust stable 1.98.0. Found by fuzzing a reader built on the
crate.
@Tembocs , Thanks for the detailed report and the reproducible example. I’m interested in investigating this issue and working on a fix.
From the description, it looks like the reader trusts the declared block/message body length before confirming that the data is actually available, which can lead to an excessively large allocation for malformed input. I’d like to investigate both the file IPC path and the stream/message reader path mentioned in the report, and add regression tests to ensure malformed length values return an appropriate ArrowError rather than causing an allocation failure or process abort.
If no one is already working on this, would it be okay for me to take it up?
@Tembocs , Thanks for the detailed report and the reproducible example. I’m interested in investigating this issue and working on a fix.
From the description, it looks like the reader trusts the declared block/message body length before confirming that the data is actually available, which can lead to an excessively large allocation for malformed input. I’d like to investigate both the file IPC path and the stream/message reader path mentioned in the report, and add regression tests to ensure malformed length values return an appropriate ArrowError rather than causing an allocation failure or process abort.
If no one is already working on this, would it be okay for me to take it up?
@Tembocs Thanks for confirming! I’ve implemented the fix and added regression tests to ensure malformed block offsets/lengths are rejected before any oversized allocation occurs. I’ll open the PR shortly for review.
I am preparing a patch covering all three sites without imposing a protocol-size limit:
read_block: reject checked body+metadata lengths that exceed the remaining file bytes before allocating.
MessageReader: validate signed lengths and read metadata/body incrementally in bounded chunks, growing the destination only as bytes actually arrive. Truncated declarations therefore return the read error with bounded memory instead of forcing the declared allocation; valid large messages remain supported.
The patch will include truncated i32::MAX metadata and i64::MAX body regressions plus the existing valid-message suite. I will link it here when available.
Hi @geoHeil, I have a fix ready for the read_block part of this issue. It validates the block offset and lengths against the file length before allocating, and rejects blocks that extend past the end of the file. It follows the same approach as #11012, which was closed as abandoned.
I saw your comment about preparing a patch covering all three sites, including the StreamReader path. Before I open a PR, I wanted to check: is your patch still coming, and would you prefer to cover read_block in it as well? Or is it fine for the read_block fix to land separately first, with the StreamReader part following in your patch?
I originally intended to send it here only if one of the arrow-ipc core-team people really wants to get it - feel free to copy it from telekom/sutura#1930 and refine it
Activity
KHARSHAVARDHAN-eng commentedon Aug 31, 2026
@Tembocs , Thanks for the detailed report and the reproducible example. I’m interested in investigating this issue and working on a fix.
From the description, it looks like the reader trusts the declared block/message body length before confirming that the data is actually available, which can lead to an excessively large allocation for malformed input. I’d like to investigate both the file IPC path and the stream/message reader path mentioned in the report, and add regression tests to ensure malformed length values return an appropriate ArrowError rather than causing an allocation failure or process abort.
If no one is already working on this, would it be okay for me to take it up?
Tembocs commentedon Sep 5, 2026
Yes, it is ok to take it. Please proceed.
KHARSHAVARDHAN-eng commentedon Sep 7, 2026
@Tembocs Thanks for confirming! I’ve implemented the fix and added regression tests to ensure malformed block offsets/lengths are rejected before any oversized allocation occurs. I’ll open the PR shortly for review.
geoHeil commentedon Nov 15, 2026
The same allocate-before-read pattern is also reachable through
StreamReader:MessageReader::maybe_nextresizes the metadata buffer from an untrusted length and then allocatesmessage.bodyLength()before either read. A downstream fuzz run reached this after ~2.69M executions and OOMed, so the issue is not limited toread_block(run: https://github.com/telekom/sutura/actions/runs/43700135555/job/132769252432).I am preparing a patch covering all three sites without imposing a protocol-size limit:
read_block: reject checked body+metadata lengths that exceed the remaining file bytes before allocating.MessageReader: validate signed lengths and read metadata/body incrementally in bounded chunks, growing the destination only as bytes actually arrive. Truncated declarations therefore return the read error with bounded memory instead of forcing the declared allocation; valid large messages remain supported.The patch will include truncated
i32::MAXmetadata andi64::MAXbody regressions plus the existing valid-message suite. I will link it here when available.Mola-maker commentedon Nov 22, 2026
Hi @geoHeil, I have a fix ready for the read_block part of this issue. It validates the block offset and lengths against the file length before allocating, and rejects blocks that extend past the end of the file. It follows the same approach as #11012, which was closed as abandoned.
I saw your comment about preparing a patch covering all three sites, including the StreamReader path. Before I open a PR, I wanted to check: is your patch still coming, and would you prefer to cover read_block in it as well? Or is it fine for the read_block fix to land separately first, with the StreamReader part following in your patch?
geoHeil commentedon Nov 22, 2026
well the patch is linked in my own project - vendored on nix. You can take that as reference potentially?
geoHeil commentedon Nov 22, 2026
I originally intended to send it here only if one of the arrow-ipc core-team people really wants to get it - feel free to copy it from telekom/sutura#1930 and refine it
Mola-maker commentedon Nov 22, 2026
Thanks for u codebases
emmm I'm not sure whether the core dev teams adapt this...
I just act as core dev haha😄
Mola-maker commentedon Nov 22, 2026
@geoHeil Lucky to harvest a brandnew proj of codebases 👍