Skip to content

Replace unmaintained mholt/archiver/v3 with mholt/archives - #5620

Merged
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:replace-archiver-5610
Jul 11, 2026
Merged

Replace unmaintained mholt/archiver/v3 with mholt/archives#5620
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:replace-archiver-5610

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

What

Replaces github.com/mholt/archiver/v3 (archived upstream, no fixes coming) with its maintained successor github.com/mholt/archives at the single call site: unpacking a user-uploaded application archive during cf push (plugins/cfapppush/deploy.go).

Why

make audit (govulncheck) reports three reachable vulnerabilities through this path with no upstream fix available:

  • GO-2025-3605 — path traversal via crafted ZIP (Zip Slip)
  • GO-2024-2698 — path traversal
  • GO-2025-4020 — DoS via unrestricted RAR dictionary sizes (nwaples/rardecode v1, pulled in by archiver)

How

archives has no high-level Unarchive; extraction is handler-driven, which puts path handling in our hands. The new unarchive helper rejects any entry whose name escapes the extraction directory (filepath.IsLocal) and any symlink whose target resolves outside it — the Zip Slip guard archiver never had. Format support stays broad via archives.Identify (zip, tar, tar.gz, ...).

Dependency effect: archiver/v3 and rardecode v1 evicted from both go.mods; archives v0.1.5 + rardecode/v2 in. govulncheck reachable count drops 8 → 5 (the remainder are the containerd/k8s family, tracked separately).

Tests

Four new tests in unarchive_test.go: zip and tar.gz happy paths, Zip Slip rejection, escaping-symlink rejection. Full make check gate green.

Note for future maintenance

Running bare go mod tidy in src/jetstream silently drops all plugin dependencies because plugin imports live in the generated extra_plugins.go — run go generate ./... there first.

Closes #5610

…hives

archiver/v3 is archived with reachable path-traversal vulns and no fix
(GO-2025-3605, GO-2024-2698, plus GO-2025-4020 via rardecode v1). Replace
the single Unarchive call in cfapppush deploy with an archives-based
extractor that rejects entries and symlink targets escaping the
extraction directory (Zip Slip), which archiver never guarded.

govulncheck reachable count drops 8 -> 5 (remaining are containerd/k8s).

Closes cloudfoundry#5610
@nabramovitz
nabramovitz marked this pull request as draft July 11, 2026 04:27
Comment thread src/jetstream/plugins/cfapppush/unarchive.go Dismissed

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - The archive package gets analyzed by CAPI

@norman-abramovitz
norman-abramovitz marked this pull request as ready for review July 11, 2026 06:41
@norman-abramovitz
norman-abramovitz merged commit 590530d into cloudfoundry:develop Jul 11, 2026
21 checks passed
@nabramovitz
nabramovitz deleted the replace-archiver-5610 branch July 11, 2026 06:50
nabramovitz added a commit to nabramovitz/stratos that referenced this pull request Jul 11, 2026
The deploy websocket's folder/file source handler joined client-supplied
folder names and file paths straight onto the temp upload dir, so a
message like "../../../home/vcap/app/x" escaped the sandbox: os.Mkdir
created directories and os.WriteFile wrote attacker-controlled content
outside tempDir, as the backend (vcap) user, before any Cloud Foundry
authorization check. Any authenticated Stratos user could reach it.

Add safeUploadJoin, which rejects names that are not local
(filepath.IsLocal) before joining — the same guard cloudfoundry#5620 applied to
archive extraction in unarchive.go, which never covered this separate
upload loop. Route both the folder-create and file-write sinks through
it. Legitimate nested paths still pass; only traversal and absolute
paths are rejected.

CodeQL: go/path-injection in cfapppush/deploy.go (297, 338).
norman-abramovitz pushed a commit that referenced this pull request Jul 11, 2026
The deploy websocket's folder/file source handler joined client-supplied
folder names and file paths straight onto the temp upload dir, so a
message like "../../../home/vcap/app/x" escaped the sandbox: os.Mkdir
created directories and os.WriteFile wrote attacker-controlled content
outside tempDir, as the backend (vcap) user, before any Cloud Foundry
authorization check. Any authenticated Stratos user could reach it.

Add safeUploadJoin, which rejects names that are not local
(filepath.IsLocal) before joining — the same guard #5620 applied to
archive extraction in unarchive.go, which never covered this separate
upload loop. Route both the folder-create and file-write sinks through
it. Legitimate nested paths still pass; only traversal and absolute
paths are rejected.

CodeQL: go/path-injection in cfapppush/deploy.go (297, 338).
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.

Replace unmaintained mholt/archiver/v3 (reachable path-traversal, no upstream fix)

3 participants