Skip to content

Bug: OOM Risk in Witness Parsing #41

@Jaydeep869

Description

@Jaydeep869

Description

ParseWitnessFile() in pkg/attestation/parser.go reads entire files with os.ReadFile and decodes with json.Unmarshal. Large witness files can cause significant memory spikes and possible OOM.

Steps to Reproduce

  1. Run parser against a very large network-trace witness JSON file.
  2. Monitor process memory while parsing.
  3. Observe high peak memory and possible OOM termination.

Expected Behavior

Parser processes large witness files with stable memory usage.

Actual Behavior

Parser loads full file into memory, causing spikes and instability on very large inputs.

Environment

  • sbomit version: current main branch
  • Go version: any supported version
  • OS: Linux/macOS/Windows

Additional Context

  • Area: pkg/attestation/parser.go
  • Suggested fix:
    • Use json.NewDecoder(file) with streaming/incremental decode.
    • Avoid loading complete file content into a single byte slice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions