Skip to content

GH-47740: [C++][Parquet] Fix undefined behavior when reading invalid Parquet data - #47741

Merged
pitrou merged 2 commits into
apache:mainfrom
pitrou:gh47740-parquet-fuzz
Oct 8, 2025
Merged

GH-47740: [C++][Parquet] Fix undefined behavior when reading invalid Parquet data#47741
pitrou merged 2 commits into
apache:mainfrom
pitrou:gh47740-parquet-fuzz

Conversation

@pitrou

@pitroupitrou commented Oct 7, 2025

Copy link
Copy Markdown
Member

Rationale for this change

Fix issues found by OSS-Fuzz when invalid Parquet data is fed to the Parquet reader:

Are these changes tested?

Yes, using the updated fuzz regression files from apache/arrow-testing#115

Are there any user-facing changes?

No.

This PR contains a "Critical Fix". (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)

@pitrou
pitrou requested a review from wgtmac as a code ownerOctober 7, 2025 13:57
@pitrou

Copy link
Copy Markdown
MemberAuthor

@github-actions crossbow submit -g cpp

@pitrou

Copy link
Copy Markdown
MemberAuthor

@AntoinePrv Would you like to take a look?

@github-actionsgithub-actionsBot added the awaiting review Awaiting review label Oct 7, 2025
// There may be remaining null if they are not greedily filled by either decoder calls
check_and_handle_fully_null_remaining();

ARROW_DCHECK(batch.is_done() || exhausted());

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check could trigger if the RLE-bit-packed data is invalid (for example a run of invalid size). @AntoinePrv

@pitroupitrou changed the title GH-47740: [C++][Parquet] Fix dangerous behavior when reading invalid Parquet dataGH-47740: [C++][Parquet] Fix undefined behavior when reading invalid Parquet dataOct 7, 2025
@github-actions

Copy link
Copy Markdown

Revision: d620685

Submitted crossbow builds: ursacomputing/crossbow @ actions-0059c16459

TaskStatus
example-cpp-minimal-build-staticGitHub Actions
example-cpp-minimal-build-static-system-dependencyGitHub Actions
example-cpp-tutorialGitHub Actions
test-build-cpp-fuzzGitHub Actions
test-conda-cppGitHub Actions
test-conda-cpp-valgrindGitHub Actions
test-cuda-cpp-ubuntu-22.04-cuda-11.7.1GitHub Actions
test-debian-12-cpp-amd64GitHub Actions
test-debian-12-cpp-i386GitHub Actions
test-fedora-42-cppGitHub Actions
test-ubuntu-22.04-cppGitHub Actions
test-ubuntu-22.04-cpp-20GitHub Actions
test-ubuntu-22.04-cpp-bundledGitHub Actions
test-ubuntu-22.04-cpp-emscriptenGitHub Actions
test-ubuntu-22.04-cpp-no-threadingGitHub Actions
test-ubuntu-24.04-cppGitHub Actions
test-ubuntu-24.04-cpp-bundled-offlineGitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundledGitHub Actions
test-ubuntu-24.04-cpp-gcc-14GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formatsGitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizerGitHub Actions

@github-actionsgithub-actionsBot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Oct 7, 2025
@pitrou

Copy link
Copy Markdown
MemberAuthor

Valgrind failure is unrelated and will be fixed by #47743

@WillAydWillAyd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - nice work!

@pitrou
pitrou merged commit 33d1f32 into apache:mainOct 8, 2025
45 checks passed
@pitroupitrou removed the awaiting committer review Awaiting committer review label Oct 8, 2025
@pitrou
pitrou deleted the gh47740-parquet-fuzz branch October 8, 2025 06:43
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 2 benchmarking runs that have been run so far on merge-commit 33d1f32.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 7 possible false positives for unstable benchmarks that are known to sometimes produce them.

raulcd pushed a commit that referenced this pull request Oct 8, 2025
…Parquet data (#47741)
### Rationale for this change
Fix issues found by OSS-Fuzz when invalid Parquet data is fed to the Parquet reader:
* https://issues.oss-fuzz.com/issues/447262173
* https://issues.oss-fuzz.com/issues/447480433
* https://issues.oss-fuzz.com/issues/447490896
* https://issues.oss-fuzz.com/issues/447693724
* https://issues.oss-fuzz.com/issues/447693728
* https://issues.oss-fuzz.com/issues/449498800
### Are these changes tested?
Yes, using the updated fuzz regression files from apache/arrow-testing#115
### Are there any user-facing changes?
No.
**This PR contains a "Critical Fix".** (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)
* GitHub Issue: #47740
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
typename EncodingTraits<DType>::Accumulator* out,
int* out_num_values) {
std::vector<ByteArray> values(num_values);
std::vector<ByteArray> values(num_values - null_count);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha...

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this was not a problem in itself, it was just allocating too much memory :)

@github-actionsgithub-actionsBot added the awaiting committer review Awaiting committer review label Oct 10, 2025
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Oct 15, 2025
…valid Parquet data (apache#47741)
### Rationale for this change
Fix issues found by OSS-Fuzz when invalid Parquet data is fed to the Parquet reader:
* https://issues.oss-fuzz.com/issues/447262173
* https://issues.oss-fuzz.com/issues/447480433
* https://issues.oss-fuzz.com/issues/447490896
* https://issues.oss-fuzz.com/issues/447693724
* https://issues.oss-fuzz.com/issues/447693728
* https://issues.oss-fuzz.com/issues/449498800
### Are these changes tested?
Yes, using the updated fuzz regression files from apache/arrow-testing#115
### Are there any user-facing changes?
No.
**This PR contains a "Critical Fix".** (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)
* GitHub Issue: apache#47740
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
Mottl pushed a commit to Mottl/arrow that referenced this pull request May 26, 2026
…valid Parquet data (apache#47741)
### Rationale for this change
Fix issues found by OSS-Fuzz when invalid Parquet data is fed to the Parquet reader:
* https://issues.oss-fuzz.com/issues/447262173
* https://issues.oss-fuzz.com/issues/447480433
* https://issues.oss-fuzz.com/issues/447490896
* https://issues.oss-fuzz.com/issues/447693724
* https://issues.oss-fuzz.com/issues/447693728
* https://issues.oss-fuzz.com/issues/449498800
### Are these changes tested?
Yes, using the updated fuzz regression files from apache/arrow-testing#115
### Are there any user-facing changes?
No.
**This PR contains a "Critical Fix".** (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)
* GitHub Issue: apache#47740
Authored-by: Antoine Pitrou <antoine@python.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@pitrou@WillAyd@adamreeve@wgtmac@mapleFU