Skip to content

fix: reject invalid pack entry header metadata#2678

Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
pack-entry-header-safety
Draft

fix: reject invalid pack entry header metadata#2678
Sebastian Thiel (Byron) wants to merge 1 commit into
mainfrom
pack-entry-header-safety

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Jun 26, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Summary

Fixes #2676.

OSS-Fuzz reported malformed pack data handling in #2676. This changes the pack entry decoder so malformed or unsupported pack entry metadata is reported as an error instead of relying on panic-capable invariants.

Changes

  • Replaces the infallible consumed.try_into().expect("pack entry headers fit into u16") conversions in gix-pack entry decoding with checked conversion and a decode error.
  • Uses fallible ref-delta base-id construction for both byte-slice and streaming entry decoders.
  • Rejects unsupported ref-delta hash lengths as invalid input instead of panicking while slicing or constructing an object id.
  • Adds regression coverage for unsupported ref-delta hash lengths and oversized encoded header metadata.

Validation

  • cargo test -p gix-pack data::entry::decode::tests
  • cargo test -p gix-pack
  • cargo clippy -p gix-pack --all-targets
  • cargo check -p gix-pack --no-default-features --features sha1 (run during Codex review)
  • cargo check -p gix-pack --no-default-features --features sha256 (run during Codex review)
  • cargo test -p gix-pack --no-default-features --features sha1 data::entry::decode::tests (run during Codex review)

Review Status

Codex review completed for commit 6fb4bee6dce99f487cff3134d2e6fbf6deed7cdb and did not find any discrete regression.

Issue #2676 reports an OSS-Fuzz finding in pack data handling.

The pack entry decoder stored the consumed header length with an infallible u16 conversion and accepted ref-delta hash lengths through panic-capable slice and ObjectId conversions. Malformed or unsupported metadata should become decode errors instead of process panics.

Add regression coverage for unsupported ref-delta hash lengths and oversized encoded header metadata. Route both byte-slice and streaming decoders through checked header-size conversion, and use fallible ObjectId construction for ref-delta base ids.

Validation:
- cargo test -p gix-pack data::entry::decode::tests
- cargo test -p gix-pack
- cargo clippy -p gix-pack --all-targets
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.

OSS-Fuzz issue 527743588

2 participants