Skip to content
OpenAdvisories
High · 8.2 CVE-2021-39134 EUVD-2021-1513GHSA-2h3h-q99f-3fhc

UNIX Symbolic Link (Symlink) Following in @npmcli/arborist

Published Aug 31, 2021 · Updated Aug 4, 2024 · Assigned by GitHub_M

Description

`@npmcli/arborist`, the library that calculates dependency trees and manages the `node_modules` folder hierarchy for the npm command line interface, aims to guarantee that package dependency contracts will be met, and the extraction of package contents will always be performed into the expected folder. This is, in part, accomplished by resolving dependency specifiers defined in `package.json` manifests for dependencies with a specific name, and nesting folders to resolve conflicting dependencies. When multiple dependencies differ only in the case of their name, Arborist's internal data structure saw them as separate items that could coexist within the same level in the `node_modules` hierarchy. However, on case-insensitive file systems (such as macOS and Windows), this is not the case. Combined with a symlink dependency such as `file:/some/path`, this allowed an attacker to create a situation in which arbitrary contents could be written to any location on the filesystem. For example, a package `pwn-a` could define a dependency in their `package.json` file such as `"foo": "file:/some/path"`. Another package, `pwn-b` could define a dependency such as `FOO: "file:foo.tgz"`. On case-insensitive file systems, if `pwn-a` was installed, and then `pwn-b` was installed afterwards, the contents of `foo.tgz` would be written to `/some/path`, and any existing contents of `/some/path` would be removed. Anyone using npm v7.20.6 or earlier on a case-insensitive filesystem is potentially affected. This is patched in @npmcli/arborist 2.8.2 which is included in npm v7.20.7 and above.

Affected products

VendorProductAffectedFixed
npm arborist < 2.8.2 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 npm 7.24.0+ds-2 —
Debian 13 npm 7.24.0+ds-2 —
Debian 12 npm 7.24.0+ds-2 —
ReleasePackageFixed inAdvisory
Ubuntu 20.04 LTS npm No fix yet —
Ubuntu 14.04 LTS npm No fix yet —
Show 2 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 18.04 LTS npm No fix yet —
Ubuntu Pro 16.04 LTS npm No fix yet —
ReleasePackageFixed inAdvisory
SLES 15 SP3 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP3 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 15 SP2 nodejs12 12.22.7-4.22.1 SUSE-SU-2021:3940-1
SLES 15 SP2 nodejs14 14.18.1-15.21.2 SUSE-SU-2021:3964-1
SLES 12 nodejs12 12.22.9-1.38.1 SUSE-SU-2022:0101-1
SLES 12 nodejs14 14.18.1-6.18.2 SUSE-SU-2021:3886-1
ReleasePackageFixed inAdvisory
openSUSE Leap 15.3 nodejs12 12.22.7-4.22.1 openSUSE-SU-2021:3940-1
openSUSE Leap 15.3 nodejs14 14.18.1-15.21.2 openSUSE-SU-2021:3964-1
openSUSE Leap 15.2 nodejs12 12.22.7-lp152.3.21.1 openSUSE-SU-2021:1574-1
openSUSE Leap 15.2 nodejs14 14.18.1-lp152.17.1 openSUSE-SU-2021:1552-1
ReleasePackageFixed inAdvisory
Alpine v3.24 nodejs 14.17.6-r0 —
Alpine v3.23 nodejs 14.17.6-r0 —
Alpine v3.22 nodejs 14.17.6-r0 —
Alpine v3.21 nodejs 14.17.6-r0 —
Alpine v3.20 nodejs 14.17.6-r0 —
Show 9 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Alpine v3.19 nodejs 14.17.6-r0 —
Alpine v3.18 nodejs 14.17.6-r0 —
Alpine v3.17 nodejs 14.17.6-r0 —
Alpine v3.16 nodejs 14.17.6-r0 —
Alpine v3.15 nodejs 14.17.6-r0 —
Alpine v3.14 nodejs 14.17.6-r0 —
Alpine v3.13 nodejs 14.17.6-r0 —
Alpine v3.12 nodejs 12.22.6-r0 —
Alpine v3.11 nodejs 12.22.6-r0 —

Affected packages

EcosystemPackageAffectedFixedRecord
npm @npmcli/arborist < 2.8.2 2.8.2 GHSA-2h3h-q99f-3fhc

Advisories 12

References