# CVE-2021-39134: UNIX Symbolic Link (Symlink) Following in @npmcli/arborist

> Attackers can write arbitrary files to any filesystem location via symlink confusion on case-insensitive systems, affecting npm users.

- **Severity:** High 8.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 31 Aug 2021
- **Updated:** 4 Aug 2024
- **Also known as:** ALPINE-CVE-2021-39134, CLEANSTART-2026-IC69554, CLEANSTART-2026-OW30917, DEBIAN-CVE-2021-39134, GHSA-2h3h-q99f-3fhc, UBUNTU-CVE-2021-39134

## What is CVE-2021-39134?

CVE-2021-39134 is a high-severity path traversal vulnerability in Oracle Graalvm, published on 31 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

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

Weakness: CWE-178 (Improper Handling of Case Sensitivity), CWE-61 (UNIX Symbolic Link (Symlink) Following)

## Which versions are affected by CVE-2021-39134?

2 open source packages ship an affected version, including @npmcli/arborist. It affects 3 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@npmcli/arborist` | npm | All versions | 2.8.2 |
| `@npmcli/arborist` | npm | All versions | 2.8.2 |

Products: Npmjs Arborist, Oracle Graalvm, Siemens Sinec Infrastructure Network Services.

## How do I fix CVE-2021-39134?

Upgrade @npmcli/arborist to 2.8.2 or later.

## Is CVE-2021-39134 being exploited?

There is no known exploitation of CVE-2021-39134 in the wild and no public exploit code.

## Other vulnerabilities in Oracle Graalvm

- [CVE-2021-39135](https://insights.sbomify.com/CVE-2021-39135/): UNIX Symbolic Link (Symlink) Following in @npmcli/arborist (high 8.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-39134 and fix it if it is affected.

What it is: CVE-2021-39134 is a high-severity path traversal vulnerability in Oracle Graalvm, published on 31 Aug 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2021-39134 in the wild and no public exploit code.

Affected packages and fixed versions:
- @npmcli/arborist (npm): affected all versions; fixed in 2.8.2
- @npmcli/arborist (npm): affected all versions; fixed in 2.8.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-39134/ (Markdown: https://insights.sbomify.com/CVE-2021-39134/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-39134
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-39134
- OSV: https://osv.dev/vulnerability/CVE-2021-39134

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-39134/
Summaries are generated and may contain mistakes; the official description above is the record.
