Vulnerabilities in pkg:npm/@pnpm/cafs

PACKAGE
Advisory Identifier: GHSA-5r98-f33j-g8h7
Advisory Summary

CVE-2023-37478 is a HIGH (CVSS 7.5) pnpm incorrectly parses tar archives vulnerability (CWE-284: Improper Access Control) affecting @pnpm/macos arm64 libraries in the npm ecosystem. The issue involves pnpm incorrectly parses tar archives relative to specification. Remediation is available by upgrading affected packages to version 7.33.4, 7.0.5, 8.6.8.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@pnpm/cafs

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@pnpm/cafs. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-5r98-f33j-g8h7 CVE-2023-37478 HIGH pnpm incorrectly parses tar archives relative to specification

CVE-2023-37478 at a Glance

CVE Identifier CVE-2023-37478
GHSA Identifier GHSA-5r98-f33j-g8h7
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-284: Improper Access Control
Affected Product @pnpm/macos arm64
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2023-37478

To remediate this vulnerability, upgrade all affected @pnpm/macos arm64 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@pnpm/macos-arm64 fixed: 7.33.4
npm install @pnpm/macos-arm64@7.33.4
@pnpm/linux-arm64 fixed: 7.33.4
npm install @pnpm/linux-arm64@7.33.4
@pnpm/linux-x64 fixed: 7.33.4
npm install @pnpm/linux-x64@7.33.4
@pnpm/linuxstatic-arm64 fixed: 7.33.4
npm install @pnpm/linuxstatic-arm64@7.33.4
@pnpm/macos-x64 fixed: 7.33.4
npm install @pnpm/macos-x64@7.33.4
@pnpm/win-x64 fixed: 7.33.4
npm install @pnpm/win-x64@7.33.4
@pnpm/cafs fixed: 7.0.5
npm install @pnpm/cafs@7.0.5
pnpm fixed: 8.6.8
npm install pnpm@8.6.8
@pnpm/exe fixed: 8.6.8
npm install @pnpm/exe@8.6.8
@pnpm/linux-arm64 fixed: 8.6.8
npm install @pnpm/linux-arm64@8.6.8
@pnpm/linux-x64 fixed: 8.6.8
npm install @pnpm/linux-x64@8.6.8
@pnpm/linuxstatic-arm64 fixed: 8.6.8
npm install @pnpm/linuxstatic-arm64@8.6.8
@pnpm/macos-arm64 fixed: 8.6.8
npm install @pnpm/macos-arm64@8.6.8
@pnpm/macos-x64 fixed: 8.6.8
npm install @pnpm/macos-x64@8.6.8
@pnpm/win-x64 fixed: 8.6.8
npm install @pnpm/win-x64@8.6.8
pnpm fixed: 7.33.4
npm install pnpm@7.33.4
@pnpm/exe fixed: 7.33.4
npm install @pnpm/exe@7.33.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @pnpm/macos-arm64

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2023-37478, inspect your project dependencies using npm:

npm ls @pnpm/macos-arm64

Analyze the terminal output to locate any version of @pnpm/macos arm64 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.33.4), your application is affected.

Note: The npm ls @pnpm/macos-arm64 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In @pnpm/macos arm64, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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.

CVE-2023-37478 Affected @pnpm/macos arm64 Versions

17 component(s)
Fixed Versions:
7.33.47.0.58.6.8
Product / Package Ecosystem Affected Versions Fixed Version
@pnpm/macos-arm64
npm
< 7.33.4
7.33.4
@pnpm/linux-arm64
npm
< 7.33.4
7.33.4
@pnpm/linux-x64
npm
< 7.33.4
7.33.4
@pnpm/linuxstatic-arm64
npm
< 7.33.4
7.33.4
@pnpm/macos-x64
npm
< 7.33.4
7.33.4
@pnpm/win-x64
npm
< 7.33.4
7.33.4
@pnpm/cafs
npm
< 7.0.5
7.0.5
pnpm
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/exe
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/linux-arm64
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/linux-x64
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/linuxstatic-arm64
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/macos-arm64
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/macos-x64
npm
≥ 8.0.0
< 8.6.8
8.6.8
@pnpm/win-x64
npm
≥ 8.0.0
< 8.6.8
8.6.8
pnpm
npm
< 7.33.4
7.33.4
@pnpm/exe
npm
< 7.33.4
7.33.4

References

Frequently Asked Questions

What is CVE-2023-37478?
CVE-2023-37478 is a security vulnerability in @pnpm/macos arm64 involving pnpm incorrectly parses tar archives relative to specification under CWE-284: Improper Access Control.
Which @pnpm/macos arm64 versions are affected?
Affected versions include releases prior to 7.33.4, 7.0.5, 8.6.8 across affected packages: @pnpm/macos-arm64, @pnpm/linux-arm64, @pnpm/linux-x64, @pnpm/linuxstatic-arm64, @pnpm/macos-x64, @pnpm/win-x64, @pnpm/cafs, pnpm, @pnpm/exe.
What version fixes CVE-2023-37478?
Upgrading to 7.33.4, 7.0.5, 8.6.8 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @pnpm/macos-arm64 affected?
Yes, @pnpm/macos-arm64 is affected in releases prior to 7.33.4, 8.6.8. Upgrade your dependency to 7.33.4, 8.6.8 or later.
Is @pnpm/linux-arm64 affected?
Yes, @pnpm/linux-arm64 is affected in releases prior to 7.33.4, 8.6.8. Upgrade your dependency to 7.33.4, 8.6.8 or later.
What is the CVSS score of CVE-2023-37478?
CVE-2023-37478 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2023-37478?
CVE-2023-37478 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check npm dependencies for CVE-2023-37478?
Run the dependency tree command: 'npm ls @pnpm/macos-arm64'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5r98-f33j-g8h7",
  "modified" : "2023-08-01T17:00:55Z",
  "published" : "2023-08-01T17:00:55Z",
  "aliases" : [ "CVE-2023-37478" ],
  "summary" : "pnpm incorrectly parses tar archives relative to specification",
  "details" : "### Summary\nIt 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.\n\n### Details\nThe 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.\n\nThis 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.\n\nWhen 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.\n\n### PoC\nCreate a root folder with the following layout:\n- `a/package.json`\n- `package/package.json`\n- `z/package.json`\n\nFile contents:\n#### a/package.json\n```json\n{\n    \"name\": \"test-package\",\n    \"version\": \"0.1.0\",\n    \"description\": \"This is a bad version of a test package\",\n    \"dependencies\": {\n        \"react\": \"^15\"\n    }\n}\n```\n#### package/package.json\n```json\n{\n    \"name\": \"test-package\",\n    \"version\": \"0.1.0\",\n    \"description\": \"This is a bad version of a test package\",\n    \"dependencies\": {\n        \"react\": \"^16\"\n    }\n}\n```\n#### z/package.json\n```json\n{\n    \"name\": \"test-package\",\n    \"version\": \"0.1.0\",\n    \"description\": \"This is the good version of a test package\",\n    \"dependencies\": {\n        \"react\": \"^17\"\n    }\n}\n```\n\nThen use the tar binary to produce a tarball (working directory is the root folder):\n`tar -c -z --format ustar -f package.tgz a package z`\nThe 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.\n\nInstall the tarball via the `file:` protocol.\n\nObserve that with npm, the lockfile has `react@17`, while with pnpm it has `react@15`.\n\n### Impact\nThis 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "pnpm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/exe"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linux-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linux-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linuxstatic-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/macos-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/macos-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/win-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.33.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/cafs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.0.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "pnpm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/exe"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linux-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linux-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/linuxstatic-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/macos-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/macos-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pnpm/win-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "8.6.8"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pnpm/pnpm/security/advisories/GHSA-5r98-f33j-g8h7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-37478"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pnpm/pnpm"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pnpm/pnpm/releases/tag/v7.33.4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pnpm/pnpm/releases/tag/v8.6.8"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-284" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-01T17:00:55Z",
    "nvd_published_at" : "2023-08-01T12:15:09Z"
  }
}