Skip to content

Add parser fuzz targets and boundary corruption fixtures #14

Description

@tuki0918

Summary

BundlePack parses attacker-controlled ZIP records, encrypted container headers and chunks, JSON manifests, PNG metadata, and GIF block structures, but the repository has no fuzz target, property-based framework, minimized crash corpus, or systematic boundary matrix.

Current malformed fixtures cover only a small set of hand-written cases.

Impact

Crashes, hangs, oversized allocations, parser differentials, and off-by-one limit errors can survive the current smoke tests even when normal and selected hostile cases pass.

Evidence

  • macOS/Scripts/test.sh:18-61
  • Windows/BundlePack.Core.Tests/BundlePack.Core.Tests.csproj:1-9
  • macOS/Tests/EndToEndSmoke.ArchiveValidation.swift:38-160
  • Windows/BundlePack.Core.Tests/ArchiveValidationScenarios.cs:20-106
  • macOS/BundlePack/Shared/ZipArchiveInspector.Validation.swift
  • macOS/BundlePack/Shared/EncryptedContainer.Header.swift
  • macOS/BundlePack/Shared/PackageManifest.swift:15-29

Proposed change

Create fuzz and generated-fixture targets for:

  • ZIP EOCD, central and local records
  • encrypted fixed header and chunk layout
  • manifest JSON
  • PNG structural validation
  • GIF blocks and sub-blocks

Add deterministic boundary cases for:

  • entries: 9,998 / 9,999 / 10,000
  • metadata: 16 MiB - 1 / exact / + 1
  • expanded size: 20 GiB - 1 / exact / + 1
  • ratio threshold around 1 GiB and 1,000 / 1,001
  • KDF iterations and chunk-size accepted ranges
  • data descriptors, ZIP64 sentinels, invalid UTF-8, overlapping ranges, duplicate offsets, and file-directory prefix conflicts
  • PNG/GIF dimension, frame, CRC, truncation, and trailing-data boundaries

Acceptance criteria

  • PR CI runs each seed corpus for a short bounded duration.
  • A nightly workflow runs sanitizer-enabled fuzzing for 15 to 30 minutes per target.
  • The oracle rejects crashes, traps, hangs, unclassified exceptions, and allocations beyond configured budgets.
  • Accepted archives always satisfy path containment, manifest-to-payload agreement, and configured limits.
  • Failures store the seed, iteration, and minimized input as CI artifacts.
  • Large-limit tests use synthetic records or sparse streams rather than checked-in multi-GiB binaries.

Compatibility constraints

Do not make the fuzzer define the format. Expected accept/reject behavior must come from Docs/FORMAT.md and the neutral conformance corpus.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions