# CVE-2018-7408: npm incorrect permission assignment in mkdir

Source: https://junglewise.ai/threats/cve-2018-7408-npm-incorrect-permission-assignment-in-mkdir  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-05-13. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2018-7408 · Severity: low · CVSS 3 · Published 2022-05-13

npm, a widely-used package manager for JavaScript, contained a critical flaw in its directory creation logic that could cause it to unexpectedly change ownership of critical system directories like /etc and /usr when run with elevated privileges. An attacker or unprivileged user running npm with sudo could inadvertently corrupt filesystem permissions and disable key system binaries, requiring a full system reinstall to recover.

Technologies: [npm (npm)](https://junglewise.ai/threats/technologies/npm). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2018-7408 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2018-7408 being exploited in the wild.

**How severe is CVE-2018-7408?** Low severity, with a CVSS score of 3, published 13 May 2022.

**Which products and versions are affected?** npm (npm) SEMVER:introduced=0,fixed=5.7.1.

**Is there a fix for CVE-2018-7408?** Yes. npm (npm): upgrade to 5.7.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2018-7408 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2018-7408?** Check whether you run npm (npm) 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

- npm (npm): upgrade to 5.7.1 or later

  ```sh
  npm install npm@5.7.1
  ```


## Technical details

This is a privilege escalation and arbitrary filesystem modification vulnerability (CWE-732: Incorrect Permission Assignment for Critical Resource) in npm 5.7.0's "correctMkdir" implementation. When npm runs with sudo (elevated privileges) but under a non-root user context, the flawed mkdir logic recursively changes ownership of directories up the filesystem tree, including critical system paths like /etc, /usr, and /boot. The vulnerability requires local access and sudo privilege delegation, but no additional user interaction. An unprivileged user with sudo access can trigger unintended chown operations on system directories, corrupting the filesystem and disabling binaries. The issue was introduced in a pre-release (5.7.0) and fixed in version 5.7.1.

## Affected products

- npm, Inc. npm 5.7.0 (pre-release); fixed in 5.7.1

## Identifiers

- CVE-2018-7408
- GHSA-ph34-pc88-72gc

## Timeline

- 2018-02-22: disclosed: Issue reported on GitHub
- 2018-02-22: patched: Fix committed; version 5.7.1 released
- 2022-05-13: advisory: GHSA-ph34-pc88-72gc published

## References

- [https://github.com/npm/npm/issues/19883](https://github.com/npm/npm/issues/19883)

## Related threats

- [npm cli local privilege escalation via uncontrolled module search path](https://junglewise.ai/threats/cve-2026-0775-npm-cli-local-privilege-escalation-via-uncontrolled-module-search)
- [npm pack root-level ignore file bypass in workspaces](https://junglewise.ai/threats/cve-2022-29244-npm-pack-root-level-ignore-file-bypass-in-workspaces)
- [npm Arborist symlink following on case-insensitive filesystems](https://junglewise.ai/threats/cve-2021-39134-npm-arborist-symlink-following-on-case-insensitive-filesystems)
- [npm public path traversal via symlink navigation](https://junglewise.ai/threats/npm-public-path-traversal-via-symlink-navigation-dd9ade29)
- [npm content denial of service in HTTP header parser](https://junglewise.ai/threats/npm-content-denial-of-service-in-http-header-parser-4db9bd00)
