CVE-2026-118905
Received Received - Intake

Command Injection in Node Version Manager

Vulnerability report for CVE-2026-118905, including description, CVSS score, EPSS score, affected products, exploitability, helpful resources, and attack-flow context.

Publication date: 2026-10-29

Last updated on: 2026-10-29

Assigner: harborist

Description

Node Version Manager (nvm) is a POSIX-compliant shell function for managing multiple node.js versions. In versions 0.31.2 through 0.40.5, `nvm_ls` filters installed versions with a sed program that embeds the requested version pattern in a `\#...#` address, escaping `.` (and, since 0.40.4, `#`) but not backslash. A version string containing `#` (or `\#`) therefore closes the address early, and the rest of it is parsed as sed commands: with GNU sed, the `e` command runs a shell command as the user; with BSD sed, the `w` and `r` commands write and read files. This is reachable whenever an attacker-influenced version string is passed to `nvm use`, `nvm which`, `nvm ls`, `nvm version`, `nvm run`, or `nvm exec`, or to `nvm-exec` via `NODE_VERSION`, and at least one version is installed. nvm's own `.nvmrc` parser strips comments, so a bare `nvm use` is not affected; however, the bash `cdnvm` and zsh `load-nvmrc` auto-switch hooks documented in the README read `.nvmrc` as-is and pass it to `nvm ls` and `nvm version`, so a user with one of those hooks installed runs the attacker's command just by changing into a directory under a malicious `.nvmrc`; scripts that run `nvm use "$(cat .nvmrc)"` are affected the same way. Version 0.40.6 passes any version pattern containing `#` or a newline through the `.nvmrc` content parser first, so no `#` reaches the sed program.

CVSS Scores

EPSS Scores

Probability:
Percentile:

Meta Information

Published
2026-10-29
Last Modified
2026-10-29
Generated
2026-10-29
AI Q&A
2026-10-29
EPSS Evaluated
N/A
NVD
EUVD

Affected Vendors & Products

Showing 1 associated CPE
Vendor Product Version / Range
nvm-sh nvm 0.31.2

Helpful Resources

Exploitability

CWE
CWE Icon
KEV
KEV Icon
CWE ID Description
CWE-78 The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
CWE-94 The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.

Attack-Flow Graph

AI Quick Actions

Instant insights powered by AI
Executive Summary

This vulnerability in Node Version Manager (nvm) versions 0.31.2 through 0.40.5 allows an attacker to inject malicious sed commands via version strings containing special characters like # or backslash. The nvm_ls function uses sed with improperly escaped patterns, enabling early address closure and command execution.

Detection Guidance

Check nvm version with nvm --version. If between 0.31.2 and 0.40.5, the system is vulnerable. Inspect .nvmrc files for malicious content like # or \#. Test with commands like nvm use "$(cat .nvmrc)" or nvm ls to see if arbitrary commands execute.

Impact Analysis

An attacker could execute arbitrary commands on your system by tricking you into changing into a directory with a malicious .nvmrc file. This happens if you use bash zsh auto-switch hooks or scripts that pass raw .nvmrc content to nvm commands like nvm use or nvm ls.

Compliance Impact

This vulnerability allows arbitrary command execution via sed command injection when processing attacker-controlled version strings in nvm commands. For GDPR, this could lead to unauthorized data access or processing, violating Article 5 (lawfulness) and Article 32 (security). For HIPAA, it risks exposing protected health information through command execution, violating the Security Rule's integrity and confidentiality requirements.

Mitigation Strategies

Upgrade nvm to version 0.40.6 or later immediately. Remove or sanitize .nvmrc files from untrusted sources. Disable auto-switch hooks like bash cdnvm or zsh load-nvmrc if they pass raw .nvmrc content to nvm commands.

Chat Assistant

Ask questions about this CVE
Hi! I’m here to help you understand CVE-2026-118905. Ask me anything about the vulnerability, its impact, or mitigation strategies.
0/70

EPSS Chart