CVE-2023-37478: pnpm tar archive parsing bypass vulnerability

CVE-2023-37478 · Severity: low · CVSS 3.1 · Published 2023-08-01

pnpm is a Node.js package manager used by developers to install JavaScript dependencies. The vulnerability allows an attacker to craft a malicious package that appears legitimate when installed via npm but executes compromised code when installed via pnpm, enabling supply chain attacks on development environments. This occurs because pnpm incorrectly handles tar archives with duplicate files, extracting the first occurrence instead of the final one as per the TAR specification.

Technologies: pnpm (npm). Vendors: npm.

Quick answers

Is CVE-2023-37478 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2023-37478 being exploited in the wild.
How severe is CVE-2023-37478?
Low severity, with a CVSS score of 3.1, published 1 August 2023.
Which products and versions are affected?
@pnpm/cafs (npm) SEMVER:introduced=0,fixed=7.0.5; @pnpm/exe (npm) SEMVER:introduced=0,fixed=7.33.4; @pnpm/linux-arm64 (npm) SEMVER:introduced=0,fixed=7.33.4; @pnpm/linux-x64 (npm) SEMVER:introduced=0,fixed=7.33.4; and 5 more.
Is there a fix for CVE-2023-37478?
Yes. @pnpm/cafs (npm): upgrade to 7.0.5 or later; @pnpm/exe (npm): upgrade to 7.33.4 or later; @pnpm/linux-arm64 (npm): upgrade to 7.33.4 or later; @pnpm/linux-x64 (npm): upgrade to 7.33.4 or later; @pnpm/linuxstatic-arm64 (npm): upgrade to 7.33.4 or later; @pnpm/macos-arm64 (npm): upgrade to 7.33.4 or later; @pnpm/macos-x64 (npm): upgrade to 7.33.4 or later; @pnpm/win-x64 (npm): upgrade to 7.33.4 or later; pnpm (npm): upgrade to 7.33.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2023-37478 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2023-37478?
Check whether you run @pnpm/cafs (npm), @pnpm/exe (npm), @pnpm/linux-arm64 (npm) or one of the others listed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • @pnpm/cafs (npm): upgrade to 7.0.5 or later
    npm install @pnpm/cafs@7.0.5
  • @pnpm/exe (npm): upgrade to 7.33.4 or later
    npm install @pnpm/exe@7.33.4
  • @pnpm/linux-arm64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/linux-arm64@7.33.4
  • @pnpm/linux-x64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/linux-x64@7.33.4
  • @pnpm/linuxstatic-arm64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/linuxstatic-arm64@7.33.4
  • @pnpm/macos-arm64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/macos-arm64@7.33.4
  • @pnpm/macos-x64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/macos-x64@7.33.4
  • @pnpm/win-x64 (npm): upgrade to 7.33.4 or later
    npm install @pnpm/win-x64@7.33.4
  • pnpm (npm): upgrade to 7.33.4 or later
    npm install pnpm@7.33.4

Technical details

The vulnerability stems from pnpm's tar-stream extraction logic not conforming to TAR format specification. The TAR format is append-only; when a file appears multiple times, the last occurrence should be extracted. pnpm instead uses the first occurrence, allowing attackers to create tarballs with multiple root directories (e.g., a/, package/, z/) each containing different package.json files. After stripping the first path component (standard practice), the payload depends on extraction order: npm uses the last file (spec-compliant), while pnpm uses the first. This enables supply chain attacks where a package passes registry inspection but executes malicious dependencies when installed via pnpm. The issue affects pnpm versions before 7.33.4 and 8.0.0–8.6.7. Patches are available in v7.33.4 and v8.6.8.

Affected products

  • pnpm pnpm <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/cafs <7.0.5
  • pnpm @pnpm/exe <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/linux-arm64 <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/linux-x64 <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/linuxstatic-arm64 <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/macos-arm64 <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/macos-x64 <7.33.4 or >=8.0.0 <8.6.8
  • pnpm @pnpm/win-x64 <7.33.4 or >=8.0.0 <8.6.8

Identifiers

  • CVE-2023-37478
  • GHSA-5r98-f33j-g8h7

Timeline

  • 2023-08-01: disclosed: Vulnerability disclosed via GHSA-5r98-f33j-g8h7
  • 2023-07-17: patched: Patches released in v7.33.4 and v8.6.8

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.