Skip to content

node-tar patches a Windows RCE bug triggered by npm install

A newline-injection flaw in node-tar let a crafted archive forge its own file paths and run code during npm install on Windows. The fix landed in a string of releases up to 8.1.0 on 2 December.

node-tar, the package npm install itself uses to unpack every tarball it downloads, has spent the past week patching a run of archive-parsing bugs. The worst, CVE-2026-140238, is a newline-injection flaw in how it reads PAX extended headers: the parser splits records on newlines instead of enforcing their declared byte length, so a filename with a newline hidden inside it lets an attacker forge a separate path record for that entry. On Windows, that was enough to overwrite package.json inside an installed package and get its postinstall script to run, full code execution from extracting a crafted archive.

Version 8.0.0, a rewrite released on 28 November, fixed that bug along with several symlink-escape issues. More parsing edge cases turned up afterwards, and the fixes kept landing through 8.0.5, reaching 8.1.0 on 2 December. tar isn’t a niche dependency: npm’s own download stats show 115,381,961 downloads for the week of 25 November, almost entirely pulled in transitively through npm itself rather than installed directly.

npm ls tar   # check you are on 8.1.0 or later

Why it matters: this is a dependency most projects never pin directly, and plenty of tooling extracts archives, including ones fetched from a compromised or malicious package, without a second thought. 8.0.0 is a breaking major version too: callback-style methods and the sync API are gone, and Node below 22 is no longer supported, so bumping past it isn’t a drop-in patch.

The caveat: most of the other bugs in this run are lower-severity parsing-correctness issues. The Windows RCE path still needs an attacker to get you to extract a crafted archive in the first place.

Share

Related reading

More from The Wire

All briefs