CVE-2021-39134

8.2 HIGH

📋 TL;DR

This vulnerability in @npmcli/arborist allows attackers to write arbitrary files to any location on case-insensitive filesystems by exploiting case-sensitivity conflicts in dependency names. Anyone using npm v7.20.6 or earlier on macOS, Windows, or other case-insensitive filesystems is potentially affected.

💻 Affected Systems

Products:
  • npm
  • @npmcli/arborist
Versions: npm v7.0.0 through v7.20.6, @npmcli/arborist before 2.8.2
Operating Systems: Windows, macOS, any case-insensitive filesystem
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects case-insensitive filesystems. Linux with case-sensitive filesystems is not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through arbitrary file write to critical system locations, potentially leading to remote code execution or data destruction.

🟠

Likely Case

Local privilege escalation, data corruption, or malicious package installation through file overwrite attacks.

🟢

If Mitigated

Limited impact if proper file permissions and isolation are in place, but still risk of package integrity compromise.

🌐 Internet-Facing: MEDIUM - Requires user to install malicious packages, but npm is widely used for internet-facing applications.
🏢 Internal Only: HIGH - Development environments and CI/CD pipelines often use npm and could be compromised internally.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires creating malicious npm packages with specific dependency naming patterns. Proof-of-concept exists in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: npm v7.20.7 or later, @npmcli/arborist 2.8.2 or later

Vendor Advisory: https://github.com/npm/arborist/security/advisories/GHSA-2h3h-q99f-3fhc

Restart Required: No

Instructions:

1. Update npm globally: npm install -g npm@latest
2. Verify update: npm --version
3. For projects, update package-lock.json and reinstall dependencies

🔧 Temporary Workarounds

Use case-sensitive filesystem

all

Run npm on case-sensitive filesystem (Linux default, macOS APFS case-sensitive, Windows with WSL2)

Audit npm packages

all

Review and audit all npm packages before installation, especially from untrusted sources

npm audit
npm ls

🧯 If You Can't Patch

  • Restrict npm package installation to trusted sources only
  • Implement strict file permissions and isolation for npm operations

🔍 How to Verify

Check if Vulnerable:

Check npm version: npm --version. If version is 7.20.6 or earlier, you are vulnerable on case-insensitive filesystems.

Check Version:

npm --version

Verify Fix Applied:

Verify npm version is 7.20.7 or later: npm --version

📡 Detection & Monitoring

Log Indicators:

  • Unusual npm install patterns with case-variant package names
  • File write operations to unexpected locations during npm install

Network Indicators:

  • npm install requests for suspicious packages with file:// dependencies

SIEM Query:

process.name='npm' AND (command_line CONTAINS 'install' OR command_line CONTAINS 'i') AND (file.path CONTAINS 'file:' OR file.path CONTAINS unusual patterns)

🔗 References

📤 Share & Export