CVE-2023-37478: pnpm incorrectly parses tar archives relative to specification

Published Aug 1, 2023
·
Updated

Summary It is possible to construct a tarball that, when installed via npm or parsed by the registry is safe, but when installed via pnpm is malicious, due to how pnpm parses tar archives.

Details The TAR format is an append-only archive format, and as such, the specification for how to update a file is to add a new record to the end with the updated version of the file. This means that it is completely valid for an archive to contain multiple copies of, say, package.json, and the expected behavior when extracting is that all versions other than the last get ignored.

This is further complicated by that during tarball extraction, all package managers are configured to drop the first path component, so collisions can be created simply by using multiple root folders in the archive, even without performing updates.

When pnpm extracts a tar archive via tar-stream, it appears to extract only the first file of a given name and discards all subsequent files with the same name.

PoC Create a root folder with the following layout: - a/package.json - package/package.json - z/package.json

File contents: a/package.json json { "name": "test-package", "version": "0.1.0", "description": "This is a bad version of a test package", "dependencies": { "react": "^15" } } package/package.json json { "name": "test-package", "version": "0.1.0", "description": "This is a bad version of a test package", "dependencies": { "react": "^16" } } z/package.json json { "name": "test-package", "version": "0.1.0", "description": "This is the good version of a test package", "dependencies": { "react": "^17" } }

Then use the tar binary to produce a tarball (working directory is the root folder): tar -c -z --format ustar -f package.tgz a package z The order of the folders at the end matters; whichever one is last will end up being the package.json that wins when extracted by npm; the one that is first will be the one that wins when extracted by pnpm.

Install the tarball via the file: protocol.

Observe that with npm, the lockfile has react@17, while with pnpm it has react@15.

Impact This can result in a package that appears safe on the npm registry or when installed via npm being replaced with a compromised or malicious version when installed via pnpm.

Other sources

pnpm is a package manager. It is possible to construct a tarball that, when installed via npm or parsed by the registry is safe, but when installed via pnpm is malicious, due to how pnpm parses tar archives. This can result in a package that appears safe on the npm registry or when installed via npm being replaced with a compromised or malicious version when installed via pnpm. This issue has been patched in version(s) 7.33.4 and 8.6.8.

Affected Software

19 affected componentsFixes available
npm/@pnpm/win-x64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/macos-x64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/macos-arm64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/linuxstatic-arm64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/linux-x64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/linux-arm64>=8.0.0<8.6.8
8.6.8
npm/@pnpm/exe>=8.0.0<8.6.8
8.6.8
npm/pnpm>=8.0.0<8.6.8
8.6.8
npm/@pnpm/cafs<7.0.5
7.0.5
npm/@pnpm/win-x64<7.33.4
7.33.4
npm/@pnpm/macos-x64<7.33.4
7.33.4
npm/@pnpm/macos-arm64<7.33.4
7.33.4
npm/@pnpm/linuxstatic-arm64<7.33.4
7.33.4
npm/@pnpm/linux-x64<7.33.4
7.33.4
npm/@pnpm/linux-arm64<7.33.4
7.33.4
npm/@pnpm/exe<7.33.4
7.33.4
npm/pnpm<7.33.4
7.33.4
PNPM Pnpm Node.js<7.33.4
PNPM Pnpm Node.js>=8.0.0<8.6.8

Event History

Aug 1, 2023
CVE Published
via MITRE·11:43 AM
Data Sourced
via MITRE·11:43 AM
DescriptionSeverityWeakness
Advisory Published
05:00 PM
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is CVE-2023-37478?

CVE-2023-37478 is a vulnerability in the pnpm package manager that allows the installation of a malicious tarball.

2

How does CVE-2023-37478 work?

CVE-2023-37478 works by exploiting the way pnpm parses tar archives, allowing a tarball to be installed that is safe via npm but malicious via pnpm.

3

What is the severity of CVE-2023-37478?

CVE-2023-37478 has a severity rating of 9.8 (Critical).

4

Which versions of pnpm are affected by CVE-2023-37478?

Versions of pnpm up to and including 7.33.4 are affected by CVE-2023-37478.

5

How can I fix CVE-2023-37478?

To fix CVE-2023-37478, update pnpm to version 8.6.8 or later.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203