Skip to content

fix(pkg): bound local mirror package archives before allocation #38

Description

@TheHalfMoon

Finding

Canonical LocalMirrorSource::archive reads <root>/<package>/<version>/package.tgz with unbounded fs::read, while the public registry transport enforces a 128 MiB compressed archive body limit before further archive traversal bounds apply.

Canonical base inspected:

main: 8a45857bf31c4acae57fdfb1e3cdde3d0f7d0361

This means a caller-selected local mirror file can force allocation of an arbitrarily large file before commandF applies manifest/decompressed/entry limits.

Risk

Local untrusted-input resource exhaustion / assurance asymmetry. No remote exploitability is claimed. Local/offline operation should not silently have a weaker archive-size boundary than network acquisition unless the difference is explicit and justified.

Required repair

  • define/reuse a commandF-owned compressed package archive size bound for local mirror acquisition;
  • inspect metadata/stream at most bound+1 before allocating/returning the archive bytes;
  • align with the registry's 128 MiB limit unless legitimate public/local package evidence requires a documented different bound;
  • preserve package-not-found behavior, provenance/source identity, manifest traversal bounds, and resolver semantics;
  • audit other local file acquisition paths for the same allocate-before-bound pattern.

Tests

  • exact compressed bound accepted when otherwise valid;
  • bound+1 rejected before complete allocation/manifest parsing;
  • ordinary local-mirror resolution remains deterministic;
  • malformed/oversized local archive fails closed with stable error classification;
  • no regression in real registry path or archive manifest bounds.

Governance

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