Skip to content

GH-54903: [C++][OSS-Fuzz fuzzing] Add new fuzzer targets json processing - #54886

Open
arthurscchan wants to merge 3 commits into
apache:mainfrom
arthurscchan:fuzz/json-fuzz-target
Open

arthurscchan wants to merge 3 commits into
apache:mainfrom
arthurscchan:fuzz/json-fuzz-target

Conversation

@arthurscchan

@arthurscchan arthurscchan commented Oct 21, 2026 •

Copy link
Copy Markdown

Rationale for this change

This PR creates a new OSS-Fuzz fuzzer for JSON processing in the Arrow C++ library, with corpora and dictionary targets. The JSON reader currently has no dedicated fuzz target, so its option space (explicit schemas, unexpected field handling, block sizes, threading, incremental reads) is only exercised indirectly. This is the 1st PR aiming to improve the overall fuzzing coverage and effectiveness of the arrow project, mentioned in #54903.

This change is coordinated with the OSS-Fuzz side in google/oss-fuzz#16328.

What changes are included in this PR?

  • cpp/src/arrow/json/fuzz.cc (new): the fuzz target. Each input is read with the JSON TableReader (single-threaded and multi-threaded), the streaming StreamingReader, and ParseOne. A small packed header (marker byte) selects the option space explored: block size, threading, newlines_in_values, unexpected_field_behavior, and several explicit-schema variants (including mismatched field names and type coercion). Inputs without the marker byte are read with the default options, so plain-JSON corpora keep working. Each read strategy is given a fresh input stream, as readers consume the stream they are passed. Reader errors on malformed input are tolerated (merged and logged), while validation failures of successful reads are treated as fatal, as a successful read producing invalid Arrow data is a reader bug.
  • cpp/src/arrow/json/CMakeLists.txt: registers the fuzz target and the corpus generator executable.
  • cpp/src/arrow/json/generate_fuzz_corpus.cc (new): generates seed corpus files of valid JSON.
  • cpp/build-support/fuzzing/generate_corpuses.sh: adds the JSON corpus section, guarded so that builds without JSON support skip it instead of failing.
  • cpp/build-support/fuzzing/dicts/arrow-json-fuzz.dict (new): dictionary of JSON tokens (structural characters, literals, escapes, numeric edge cases) to help the fuzzing engine generate meaningful inputs.
  • cpp/CMakePresets.json: enables ARROW_JSON in the fuzzing preset so the new target is built by cmake --preset=fuzzing.

Are these changes tested?

Yes on OSS-Fuzz side.

Are there any user-facing changes?

No.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Code and description were drafted with the help of an AI coding agent, then reviewed, revised and validated by the author before submission.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format.

If this is not a minor PR, could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

After updating the title, you can mark the pull request as ready for review.

See also:

@github-actions
github-actions Bot marked this pull request as draft October 21, 2026 07:08
@arthurscchan arthurscchan changed the title OSS-Fuzz: Add new fuzzer targets json processing GH-54903: [OSS-Fuzz fuzzing] Add new fuzzer targets json processing Oct 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54903 has been automatically assigned in GitHub to PR creator.

@arthurscchan
arthurscchan marked this pull request as ready for review October 21, 2026 08:54
@arthurscchan arthurscchan changed the title GH-54903: [OSS-Fuzz fuzzing] Add new fuzzer targets json processing GH-54903: [C++][OSS-Fuzz fuzzing] Add new fuzzer targets json processing Oct 22, 2026
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 10:27

Copilot AI 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.

🟡 Changes recommended

Validation failures are silently treated as tolerated parse errors, preventing fuzz findings, and corpus generation unconditionally invokes a JSON executable that the default fuzzing preset does not build.

2 open issues
What changed in this PR

Adds a JSON reader fuzz target to Arrow’s C++ fuzzing infrastructure, expanding OSS-Fuzz coverage as part of GH-54903.

Changes:

  • Exercises table, streaming, and single-object parsing with varied reader options and schemas.
  • Adds a seed corpus generator and JSON mutation dictionary.
  • Registers the target in CMake and adds JSON corpus packaging.
File Description
cpp/​src/​arrow/​json/​generate_fuzz_corpus.cc Generates seeds combining option headers with JSON payloads.
cpp/​src/​arrow/​json/​fuzz.cc Exercises JSON reader paths and validates successful results.
cpp/​src/​arrow/​json/​CMakeLists.txt Registers the fuzzer and corpus generator.
cpp/​build-support/​fuzzing/​generate_corpuses.sh Generates and packages the JSON seed corpus.
cpp/​build-support/​fuzzing/​dicts/​arrow-json-fuzz.dict Supplies JSON tokens for fuzz mutations.

Review effort: Balanced

Comment thread cpp/src/arrow/json/fuzz.cc Resolved
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 14:43

Copilot AI 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.

🔵 Needs a closer look

The threading setting is overwritten, preventing fuzz inputs from exercising the non-threaded streaming decoding path.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve the encoded threading setting for streaming reads

cpp/​src/​arrow/​json/​fuzz.cc:137

The threading bit decoded from header[3] has no effect: table reads overwrite it with both fixed values, and this assignment forces streaming reads to use threads. Consequently, no input can exercise the separate non-threaded streaming decoding path in reader.cc. Preserve the encoded setting here so mutations and corpus headers can reach both streaming implementations.

2 resolved since last review

Review effort: Balanced

Sign up for free to 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.

3 participants