Skip to content

Remove download dependency to resolve transitive security findings (#373) - #374

Merged
jrothrock merged 1 commit into
masterfrom
fix/remove-download-dependency
Aug 26, 2026
Merged

Remove download dependency to resolve transitive security findings (#373)#374
jrothrock merged 1 commit into
masterfrom
fix/remove-download-dependency

Conversation

@jrothrock

Copy link
Copy Markdown
Collaborator

Summary

Resolves the transitive-dependency vulnerabilities reported in #373 by removing the download package entirely and replacing it with a small, dependency-light downloader.

The core-agent downloader previously used download, which is effectively unmaintained and pulls in a large transitive tree that accounts for all the reported findings:

  • decompress — critical (Zip-Slip / arbitrary file write via archive extraction)
  • got@8 — high (SSRF via redirect to a UNIX socket)
  • http-cache-semantics@3 — high (ReDoS)
  • plus tmp@0.2.6 — high (path traversal / symlink write), which was mis-declared as a runtime dependency but is only used by tests

Changes

  • New lib/agent-downloaders/fetch-extract.ts — replaces download(url, dir, {extract}) using Node built-ins (https with redirect handling, zlib gunzip) plus tar-stream for extraction. It:
    • preserves archived file modes (the core-agent binary stays executable), and
    • adds path-traversal ("zip slip") protection — refusing any entry that resolves outside the target dir — which the old decompress path did not have. So this fixes the CVE class rather than just swapping libraries.
    • throws a typed HTTPError (with statusCode) on non-2xx responses.
  • web.ts — both download(...) call sites now use downloadAndMaybeExtract(...); removed dead imports.
  • package.json — dropped download + @types/download; added tar-stream + @types/tar-stream; moved tmpdevDependencies and bumped to 0.2.7.
  • Regenerated yarn.lock (drops ~2,300 transitive packages).

Verification

  • npm audit --omit=dev0 vulnerabilities (was 5). download, decompress, got, http-cache-semantics are gone from the tree.
  • tsc build clean, lint clean.
  • Downloader e2e suite: 9/9 pass against real S3 releases (ENABLE_BINARY_TESTS=true) — fresh download, cache populate/reuse, custom URL, and 404 handling.
  • Direct checks: real download+extract (binary runs, mode 755) and a malicious ../ tar entry correctly rejected.
  • End-to-end app run: scout.install() → real download → extract → core-agent daemon launched → live HTTP request instrumented.

Fixes #373

🤖 Generated with Claude Code

Replace the `download` package (and its `decompress`/`got`/
`http-cache-semantics` transitive tree) with a small built-in
downloader over Node's `https` + `zlib` and `tar-stream` for
extraction. This removes all five vulnerabilities reported in #373
and adds path-traversal ("zip slip") protection during extraction,
which the previous `decompress`-based path lacked.

Also moves `tmp` (test-only) to devDependencies and bumps it to
0.2.7, since it was mis-declared as a runtime dependency.

`npm audit --omit=dev` now reports 0 vulnerabilities. The core-agent
download/extract path is verified against real releases via the
existing agent-downloaders e2e suite (9/9) and an end-to-end app run.

Fixes #373

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jrothrock added a commit that referenced this pull request Aug 26, 2026
Patch release covering the removal of the `download` dependency and its
vulnerable transitive tree (decompress/got/http-cache-semantics), plus
moving the test-only `tmp` dependency out of production installs.

Syncs the yarn.lock self-reference to 2.1.1 so the release workflow's
`yarn install --frozen-lockfile` stays consistent.

See #374.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jrothrock jrothrock mentioned this pull request Aug 26, 2026
@jrothrock
jrothrock merged commit f281789 into master Aug 26, 2026
14 checks passed
@jrothrock
jrothrock deleted the fix/remove-download-dependency branch August 26, 2026 19:34
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.

Security findings in transitive dependencies of scout-apm 2.1.0

2 participants