Skip to content

Remove vulnerable node-tar dependency from the npm downloader - #39

Merged
cfallin merged 2 commits into
bytecodealliance:mainfrom
vados-cosmonic:fix/npm-downloader-package
Dec 2, 2026
Merged

cfallin merged 2 commits into
bytecodealliance:mainfrom
vados-cosmonic:fix/npm-downloader-package

Conversation

@vados-cosmonic

@vados-cosmonic vados-cosmonic commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The npm wrapper in 0.5.1 installs node-tar 7, which is affected by archive extraction advisories including GHSA-6wwr-g865-f46r and GHSA-25mm-r35j-6hgm.

Use @napi-rs/tar 1.1.3 to read the Linux and macOS release archives. It handles both XZ decompression and tar parsing, so the wrapper can drop the separate LZMA dependency. Windows continues to use fflate for ZIP archives.

The downloader accepts regular and contiguous file entries, writes the executable to a temporary directory, and moves the completed file into the cache. It also cleans up stale download directories.

Verified all five official release archives under Node 22 and ran the downloaded Linux binary. A clean npm install reported zero known vulnerabilities. A 0.5.2 npm release would let downstream consumers drop their temporary pins.

Extract the binary from tar.xz releases with tar-stream (and
@napi-rs/lzma for the xz layer) instead of node-tar.

- Write the binary to a temporary directory and rename it into place, so
  a partially written executable is never published.
- Accept regular and contiguous tar entries for the binary, and report
  the entry type when it is a link instead of claiming it is missing.
- Remove download-* temp dirs left by interrupted installs. Only dirs
  older than an hour are removed, so concurrent installs are left alone.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
@vados-cosmonic
vados-cosmonic force-pushed the fix/npm-downloader-package branch from 000a774 to 27023fe Compare December 2, 2026 10:12
@vados-cosmonic

Copy link
Copy Markdown
Contributor Author

If this goes in, it would be great to also get a 0.5.2 release out. Bots also found some pre-existing issues which I may open another PR for as well.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
@cfallin
cfallin merged commit ae1d9b6 into bytecodealliance:main Dec 2, 2026
11 checks passed
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.

2 participants