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
I'm generally new to the code base but it looks like existing fuzz tests might be generating random data and making sure it can be read back, but we don't have any fuzz tests for malformed data. I think in the context of Rust the goal would be to avoid panics?
If this is accurate, I'd propose creating fuzz tests that check succeed as long as there is no panic. A beginning corpus arrow-testing repo2 for each file type.
A second step would be integrate with oss-fuzz (Arrow C++ already does so).
If this is of interest and i'm correct this isn't already done, I can try to see if I can prototype something.
It isn't an issue IMO if the reader panics on malformed data, this is a perfectly safe and well-defined behaviour. We should try to avoid it, but its not like UB where it would indicate a bug. Panics are just exceptions.
The bigger issue with untrusted/malicious inputs is avoiding the reader getting stuck in infinite loops or exploding the memory usage. I'm not sure how easy such things are to catch using a fuzz testing framework.
With regards to parquet, I can't help feeling the format is sufficiently complex that supporting untrusted input is essentially a fools errand though...
That's all to say adding fuzzing support would be a nice add. I'm not too familiar with the Rust ecosystem's support for it, but @crepererum may know more.
Fuzzing is a good thing, even when you accept panics as an outcome. The fuzzer then has two wrap the method call accordingly.
Regarding the toolchain: We should use cargo-fuzz. That gives us the option to use multiple fuzzers. Then you need to choose a fuzzer. I would suggest you use libFuzzer which comes w/ LLVM, since it is the least invasive one, however it has entered maintenance mode. I see the following options:
don't care about maintainance mode and just use libFuzzer
That said, the choice can easily be changed later, since the fuzzer is effectively just a "run some code on this blackbox [u8] input" (like "parse parquet from bytes").
Footnotes
Note that AFL was abandoned for a while, but development is now open and active under the AFL++ project. ↩
I think one important item is a philosophical question, of if malformed data should trigger a panic. Can I interpret the comment above:
"We should try to avoid it, but its not like UB where it would indicate a bug. Panics are just exceptions." as if the fuzzer uncovers a panic, then submitting a patch to avoid the panic would be accepted?
We've had good experience in parquet-cpp of integrating with google/oss-fuzz I haven't looked into what supporting Rust would look like exactly but that seems like a reasonable place to start?
Before we integrate anything into oss-fuzz, we need to write the fuzz harness. We also need to fix the bugs that occur when you run this for an hour or so on your developer machine (which can be a laptop), just to make sure we sure that we don't end up with SPAM when handing to to oss-fuzz.
I think one important item is a philosophical question, of if malformed data should trigger a panic. Can I interpret the comment above:
"We should try to avoid it, but its not like UB where it would indicate a bug. Panics are just exceptions." as if the fuzzer uncovers a panic, then submitting a patch to avoid the panic would be accepted?
I think there are two levels of safety here:
no crash: It can panic, but it should segfault or something. We have some unsafe code in our code base and even with safe code you can still trigger out-of-memory errors (e.g. when the input file header says it's 10000TB of data but the file is only 1kb large, you shouldn't try to allocate a vector/buffer with 10000TB). I think everyone agrees that this is the absolute minimum we have to provide.
no panic: Here different developers may have different opinions. I personally think not panicking for a bunch of seemingly random kernel computations (esp. in the DataFusion context) is hard to avoid, but merely deserializing a parquet file to arrow should never panic and only use proper errors.
That said, I would be OK if we start with a fuzz harness that catches panics, stabilize that (e.g. it doesn't crash if you run it on your machine for a while), and then in a follow-up remove the panic-catch and see how far we get.
Footnotes
I was somewhat hoping that libAFL would evolve a bit faster but you still have to manually build it and last time I've checked -- which was a few months ago -- it was rather complicated to integrate into cargo-fuzz, even with the libFuzzer shim. ↩
not panicking for a bunch of seemingly random kernel computations (esp. in the DataFusion context) is hard to avoid,
i agree that it's tricky to fully eliminate panics, though fuzz can help reduce panics. IMHO the current codes include many unnecessary panics: e.g., overflow panics due to not using checked operation (such as shift, add, etc.), explicit panics from unimplemented!(), assert!(), panic!().
It seems we can either replace those with proper errors, or maybe just add some sanity checks while keeping the panic codes, e.g., for the bit_width panic we can reject invalid bit_width earlier here such that the panic codes would never get executed)
With regards to parquet, I can't help feeling the format is sufficiently complex that supporting untrusted input is essentially a fools errand though...
FWIW, I have always assumed proper handling of untrusted inputs to be an intentional feature of Parquet. Many data services accept Parquet as input. Being an open format it has become a de-facto interchange format between systems.
I do agree with Rafael though that infinite loops and memory overflows are in a more severe category than panics and it would be acceptable (though mildly unfortunate) to clearly state that invalid input may cause panics and users should catch unwind parquet routines.
In a way, this is actually similar to C++ where Parquet throws exceptions while the rest of the Arrow library uses Result. Arrow has "catch unwinds" at all the boundaries.
Many data services accept Parquet as input. Being an open format it has become a de-facto interchange format between systems.
Different applications will have different threat models and should make their own judgements, but I would certainly encourage any applications accepting truly untrusted parquet data to rewrite them in some sandboxed environment before handing them off to other systems. This is fairly standard practice when it comes to other media files, e.g. images, video, etc... even where there are extremely mature and well tested transcoders.
However, many systems will instead be accepting files from other internal systems, at which point perhaps the thread model is different.
Security concerns aside, I would recommend rewriting parquet files anyway because of the sheer variety of parquet implementations - two files with the same data may behave very differently depending on how they've been written
This is fairly standard practice when it comes to other media files, e.g. images, video, etc... even where there are extremely mature and well tested transcoders.
That might be true, but mostly due to the fact that most media decoders are written using unsafe languages (see The Rule Of 2). In contrary, it's "fairly standard practice" for all kinds of data scientists to load whatever data set they have at hand without piping it through some security sanitizer step first.
I'd like to take this on, building on the direction agreed in this thread (cargo-fuzz + libFuzzer; panics treated as bugs to fix; memory-blowup / infinite-loop as the higher-severity targets).
Concrete plan
Add fuzz/ directories under the most security-relevant parsers, prioritized by past trouble area: parquet/fuzz/, arrow-ipc/fuzz/, then arrow-json/, arrow-csv/, arrow-avro/. One target per entry point (e.g. parquet_arrow_reader, parquet_thrift_decode, ipc_stream_reader).
Seed corpora from apache/arrow-testing (parquet/fuzzing/, arrow-ipc-stream/, arrow-ipc-file/, csv/fuzzing/), plus minimal hand-crafted dictionaries.
Wire ClusterFuzzLite in GitHub Actions for short PR-time fuzz + nightly batch + corpus pruning, so regressions get caught before merge.
Open the OSS-Fuzz integration PR (projects/arrow-rs/) once (1)–(3) land, mirroring the layout of existing Rust workspace integrations like gitoxide. Coverage target ≥80% on harness-touched modules per the Integration Rewards bar.
What this would catch — concretely
I've been hitting the exact memory-blowup class of bug this issue calls out:
Both reproduce in seconds under cargo-fuzz with a small seed corpus, so a harness pays for itself immediately rather than only finding things in long ClusterFuzz runs.
Layout preference: per-crate fuzz/ dirs (gitoxide-style) vs. a single top-level fuzz/ workspace? I'd lean per-crate — keeps parquet's fuzz target buildable without pulling in the IPC tree, matches how each crate ships to crates.io, and lets the OSS-Fuzz build.sh use the standard find . -type d -name fuzz pattern.
primary_contact / auto_ccs for OSS-Fuzz project.yaml: OSS-Fuzz wants Google-account emails on file. Who from the PMC would want crash notifications? Happy to default to a maintainer-monitored alias if there's a preference; otherwise I can list myself + auto_ccs to whoever opts in here.
Happy to adjust scope / sequencing — flagging here first per @emkornfield's original "step 2 = oss-fuzz" framing rather than just pushing a PR cold. xref #9358.
I also wanted to repeat something I said in the datafusion ticket:
I think any additional sql fuzzing coverage that finds issues is valuable. I don't think there is any particular reason the fuzz testing has to be added to this repository / maintained by the same maintainers as the core repo. Fuzz teseting can be done using only DataFusion's pubic APIs
SO in other words thank you for the help so far and I think the PRs I see so far look valuable.
As for committing to this new infrastructure into the arrow-rs / parquet repo directly that is something we should evaluate based on maintainence bandwidth
Thanks @alamb — that framing is helpful. Echoing back what I'm taking from it so I don't drift:
Continued bug-hunting + fix PRs against arrow / arrow-ipc / parquet (and the related rust-format crates) is welcome and lives entirely on my side. ✅
Committing in-repo fuzz infrastructure ({crate}/fuzz/ dirs + ClusterFuzzLite GA wiring) into arrow-rs is a maintenance ask the project hasn't decided on. I should treat that as deferred, not in-flight.
Adjusting the plan accordingly. Items (1)–(3) of my 2026-05-03 plan (per-crate fuzz/ dirs, seed corpora committed to this repo, ClusterFuzzLite GA) — withdrawn / parked indefinitely. No PRs from me on that front; happy to revisit only if a maintainer brings it up.
Item (4) OSS-Fuzz integration can go forward without any in-repo code change here. Concretely:
I host the harnesses on a personal fork branch (masumi-ryugo/arrow-rs:fuzz/initial-harnesses) — already pushed, not asking for it to be merged.
The google/oss-fuzzprojects/arrow-rs/ directory (also already prepped on a fork) clones that branch in its Dockerfile and builds the harnesses from there. This is the same pattern several Rust projects use when the upstream repo doesn't host fuzz/.
Net change in apache/arrow-rs: zero. Net change in google/oss-fuzz: one new projects/arrow-rs/ directory. Maintainer touchpoint: just the primary_contact / auto_ccs emails for crash notifications.
If that out-of-tree model is acceptable, I can send the google/oss-fuzz PR once contact emails are sorted. If a PMC member or two would like crash notifications, please drop a Google-account email here (or DM me) and I'll list you as auto_ccs. Otherwise I'll list myself as primary_contact only — arrow-rs maintainers wouldn't be on the notification list at all unless they ask to be.
If even the out-of-tree OSS-Fuzz integration is more than the project wants right now, just say so and I'll keep running cargo-fuzz locally + sending fix PRs without the OSS-Fuzz piece.
Either way, no code action from me on this issue until I hear back. The fix-PR stream continues independently.
I don't fully follow what you are talking about / asking about above and I don't thnik I will have the time to provide much specific feedback as I am not familr with oss-fuzz etc
The fix-PR stream continues independently.
Thank you. I will likely focus almost all my efforts on reviewing the fixes for any issues you find with this testing
Activity
tustvold commentedon Jan 25, 2024
It isn't an issue IMO if the reader panics on malformed data, this is a perfectly safe and well-defined behaviour. We should try to avoid it, but its not like UB where it would indicate a bug. Panics are just exceptions.
The bigger issue with untrusted/malicious inputs is avoiding the reader getting stuck in infinite loops or exploding the memory usage. I'm not sure how easy such things are to catch using a fuzz testing framework.
With regards to parquet, I can't help feeling the format is sufficiently complex that supporting untrusted input is essentially a fools errand though...
That's all to say adding fuzzing support would be a nice add. I'm not too familiar with the Rust ecosystem's support for it, but @crepererum may know more.
.
crepererum commentedon Jan 25, 2024
Fuzzing is a good thing, even when you accept panics as an outcome. The fuzzer then has two wrap the method call accordingly.
Regarding the toolchain: We should use
cargo-fuzz. That gives us the option to use multiple fuzzers. Then you need to choose a fuzzer. I would suggest you uselibFuzzerwhich comes w/ LLVM, since it is the least invasive one, however it has entered maintenance mode. I see the following options:libFuzzerafl.rs/cargo afl1libAFL-- which is a modern Rust redesign of AFL(++) -- and also provides alibFuzzershimThat said, the choice can easily be changed later, since the fuzzer is effectively just a "run some code on this blackbox
[u8]input" (like "parse parquet from bytes").Footnotes
Note that AFL was abandoned for a while, but development is now open and active under the AFL++ project. ↩
emkornfield commentedon Nov 5, 2024
We've had good experience in parquet-cpp of integrating with https://github.com/google/oss-fuzz I haven't looked into what supporting Rust would look like exactly but that seems like a reasonable place to start?
I think one important item is a philosophical question, of if malformed data should trigger a panic. Can I interpret the comment above:
"We should try to avoid it, but its not like UB where it would indicate a bug. Panics are just exceptions." as if the fuzzer uncovers a panic, then submitting a patch to avoid the panic would be accepted?
crepererum commentedon Nov 6, 2024
Before we integrate anything into oss-fuzz, we need to write the fuzz harness. We also need to fix the bugs that occur when you run this for an hour or so on your developer machine (which can be a laptop), just to make sure we sure that we don't end up with SPAM when handing to to oss-fuzz.
Have a look at https://rust-fuzz.github.io/book/introduction.html . Despite what I said in #5332 (comment) , I think combining that with
libFuzzeris still the best choice1. It results in a reasonably efficient fuzzer with a somewhat low barrier of entrance. You may want to combine this witharbitraryif you need more than just a few bytes, e.g. you also want to fuzz parameters or something.I think there are two levels of safety here:
That said, I would be OK if we start with a fuzz harness that catches panics, stabilize that (e.g. it doesn't crash if you run it on your machine for a while), and then in a follow-up remove the panic-catch and see how far we get.
Footnotes
I was somewhat hoping that
libAFLwould evolve a bit faster but you still have to manually build it and last time I've checked -- which was a few months ago -- it was rather complicated to integrate into cargo-fuzz, even with thelibFuzzershim. ↩jp0317 commentedon Nov 6, 2024
i agree that it's tricky to fully eliminate panics, though fuzz can help reduce panics. IMHO the current codes include many unnecessary panics: e.g., overflow panics due to not using checked operation (such as shift, add, etc.), explicit panics from unimplemented!(), assert!(), panic!().
It seems we can either replace those with proper errors, or maybe just add some sanity checks while keeping the panic codes, e.g., for the bit_width panic we can reject invalid bit_width earlier here such that the panic codes would never get executed)
westonpace commentedon Dec 18, 2024
FWIW, I have always assumed proper handling of untrusted inputs to be an intentional feature of Parquet. Many data services accept Parquet as input. Being an open format it has become a de-facto interchange format between systems.
I do agree with Rafael though that infinite loops and memory overflows are in a more severe category than panics and it would be acceptable (though mildly unfortunate) to clearly state that invalid input may cause panics and users should catch unwind parquet routines.
In a way, this is actually similar to C++ where Parquet throws exceptions while the rest of the Arrow library uses Result. Arrow has "catch unwinds" at all the boundaries.
tustvold commentedon Dec 18, 2024
Different applications will have different threat models and should make their own judgements, but I would certainly encourage any applications accepting truly untrusted parquet data to rewrite them in some sandboxed environment before handing them off to other systems. This is fairly standard practice when it comes to other media files, e.g. images, video, etc... even where there are extremely mature and well tested transcoders.
However, many systems will instead be accepting files from other internal systems, at which point perhaps the thread model is different.
Security concerns aside, I would recommend rewriting parquet files anyway because of the sheer variety of parquet implementations - two files with the same data may behave very differently depending on how they've been written
crepererum commentedon Mar 20, 2025
That might be true, but mostly due to the fact that most media decoders are written using unsafe languages (see The Rule Of 2). In contrary, it's "fairly standard practice" for all kinds of data scientists to load whatever data set they have at hand without piping it through some security sanitizer step first.
alamb commentedon Apr 16, 2026
I do think it would help to fuzz testing to make sure the parquet reader isn't panic'ing on invalid input (rather than panic):
youichi-uda commentedon May 3, 2026
I'd like to take this on, building on the direction agreed in this thread (cargo-fuzz + libFuzzer; panics treated as bugs to fix; memory-blowup / infinite-loop as the higher-severity targets).
Concrete plan
fuzz/directories under the most security-relevant parsers, prioritized by past trouble area:parquet/fuzz/,arrow-ipc/fuzz/, thenarrow-json/,arrow-csv/,arrow-avro/. One target per entry point (e.g.parquet_arrow_reader,parquet_thrift_decode,ipc_stream_reader).apache/arrow-testing(parquet/fuzzing/,arrow-ipc-stream/,arrow-ipc-file/,csv/fuzzing/), plus minimal hand-crafted dictionaries.projects/arrow-rs/) once (1)–(3) land, mirroring the layout of existing Rust workspace integrations likegitoxide. Coverage target ≥80% on harness-touched modules per the Integration Rewards bar.What this would catch — concretely
I've been hitting the exact memory-blowup class of bug this issue calls out:
read_thrift_vecallocatingVec::with_capacityfrom an attacker-controlled list length without bounding by remaining input → DoS via tiny crafted file.MessageReadersizing allocations from a header field rather than actual stream bytes.Both reproduce in seconds under cargo-fuzz with a small seed corpus, so a harness pays for itself immediately rather than only finding things in long ClusterFuzz runs.
Two questions before I start writing harnesses (cc @alamb @tustvold @crepererum @emkornfield):
fuzz/dirs (gitoxide-style) vs. a single top-levelfuzz/workspace? I'd lean per-crate — keepsparquet's fuzz target buildable without pulling in the IPC tree, matches how each crate ships to crates.io, and lets the OSS-Fuzzbuild.shuse the standardfind . -type d -name fuzzpattern.primary_contact/auto_ccsfor OSS-Fuzzproject.yaml: OSS-Fuzz wants Google-account emails on file. Who from the PMC would want crash notifications? Happy to default to a maintainer-monitored alias if there's a preference; otherwise I can list myself + auto_ccs to whoever opts in here.Happy to adjust scope / sequencing — flagging here first per @emkornfield's original "step 2 = oss-fuzz" framing rather than just pushing a PR cold. xref #9358.
fuzz: add seed corpus builders and parquet dictionary
fuzz: add arrow-json reader harness
fuzz: add arrow-csv and arrow-avro reader harnesses
alamb commentedon May 4, 2026
I also wanted to repeat something I said in the datafusion ticket:
SO in other words thank you for the help so far and I think the PRs I see so far look valuable.
As for committing to this new infrastructure into the arrow-rs / parquet repo directly that is something we should evaluate based on maintainence bandwidth
youichi-uda commentedon May 5, 2026
Thanks @alamb — that framing is helpful. Echoing back what I'm taking from it so I don't drift:
{crate}/fuzz/dirs + ClusterFuzzLite GA wiring) intoarrow-rsis a maintenance ask the project hasn't decided on. I should treat that as deferred, not in-flight.Adjusting the plan accordingly. Items (1)–(3) of my 2026-05-03 plan (per-crate
fuzz/dirs, seed corpora committed to this repo, ClusterFuzzLite GA) — withdrawn / parked indefinitely. No PRs from me on that front; happy to revisit only if a maintainer brings it up.Item (4) OSS-Fuzz integration can go forward without any in-repo code change here. Concretely:
masumi-ryugo/arrow-rs:fuzz/initial-harnesses) — already pushed, not asking for it to be merged.google/oss-fuzzprojects/arrow-rs/directory (also already prepped on a fork) clones that branch in itsDockerfileand builds the harnesses from there. This is the same pattern several Rust projects use when the upstream repo doesn't hostfuzz/.apache/arrow-rs: zero. Net change ingoogle/oss-fuzz: one newprojects/arrow-rs/directory. Maintainer touchpoint: just theprimary_contact/auto_ccsemails for crash notifications.If that out-of-tree model is acceptable, I can send the
google/oss-fuzzPR once contact emails are sorted. If a PMC member or two would like crash notifications, please drop a Google-account email here (or DM me) and I'll list you asauto_ccs. Otherwise I'll list myself asprimary_contactonly —arrow-rsmaintainers wouldn't be on the notification list at all unless they ask to be.If even the out-of-tree OSS-Fuzz integration is more than the project wants right now, just say so and I'll keep running cargo-fuzz locally + sending fix PRs without the OSS-Fuzz piece.
Either way, no code action from me on this issue until I hear back. The fix-PR stream continues independently.
fix(parquet): bound schema num_children before Vec::with_capacity (#9884
fix(arrow-csv): bound RecordDecoder::flush offset accumulation (#9886)
alamb commentedon May 6, 2026
I don't fully follow what you are talking about / asking about above and I don't thnik I will have the time to provide much specific feedback as I am not familr with oss-fuzz etc
Thank you. I will likely focus almost all my efforts on reviewing the fixes for any issues you find with this testing
Thank you again
fix(parquet): bound schema num_children before Vec::with_capacity (ap…
fix(arrow-csv): bound RecordDecoder::flush offset accumulation (apach…