Skip to content

test(fuzz): fuzz five more untrusted decoders, and fix a pack offset overflow they found - #360

Merged
tonibergholm-codento merged 5 commits into
mainfrom
test/fuzz-decoders
Nov 20, 2026
Merged

tonibergholm-codento merged 5 commits into
mainfrom
test/fuzz-decoders

Conversation

@tonibergholm-codento

Copy link
Copy Markdown
Collaborator

The only fuzz target, wire_decode, left most of the untrusted decoders unfuzzed. That included the pack index and record readers a bucket remote feeds. Writing the first new target found a real bug: an index offset near u64::MAX overflowed record_bounds in crates/core/src/pack.rs. Debug builds panic on it. Release builds have overflow checks off, so the sum wraps instead.

This PR adds five targets and fixes that overflow:

  • pack_decode: pack index parse, pack reader, and read_object_at_bounded with a full 8-byte offset and the expected id taken from the input. Seeded with a valid record and a raw pack.
  • pack_stream: read_pack_stream with a budget below libFuzzer's default input size, so the cap path is reachable.
  • walfmt_decode: bucket manifest, log entry and checkpoint decoders.
  • http_opening: the three HTTP opening readers, run with -max_len=8192 so the 8 KiB limit is reachable.
  • text_files: the TLS pin file and serve-token parsers.

record_bounds now converts the offset with try_from and uses checked_add, and the bounded zstd read uses saturating_add. A hostile offset or length now returns PackCorrupt. The fuzz workflow runs the six targets as a matrix. Three #[doc(hidden)] pub hooks in scl-repo expose private parsers to the harness; serve_tokens::load and tls_pins::list call them, so behaviour is unchanged.

Proof: record_bounds_rejects_overflowing_offsets_and_lengths covers offsets u64::MAX, u64::MAX - 3 and usize::MAX - 3, and a u32::MAX length. The reproducer panicked before the fix. cargo test -p scl-core passes. The harness replay tests and cargo check --bins pass in fuzz/. No libFuzzer run was possible locally (no nightly toolchain), so the first nightly run is the first real fuzzing.

Reviewed with sol-loop: 2 rounds with gpt-6.2-sol. Sol verdict: round 2 left one item, a corpus seed for the streaming parser, which the last commit adds.

Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ae912d7-5bee-49ad-83f4-443908659259
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T08:42:44.397782Z 72b04cb New commits
🔒 Security Review ✅ Completed 2026-11-20T08:45:03.362330Z 72b04cb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tonibergholm tonibergholm left a comment

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.

Reviewed: sol-loop (2 rounds), all checks green including the six fuzz targets (600 s each, no crash), Codex review has no findings.

@tonibergholm-codento
tonibergholm-codento merged commit b3ebbd8 into main Nov 20, 2026
18 checks passed
@tonibergholm-codento
tonibergholm-codento deleted the test/fuzz-decoders branch November 20, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants