Skip to content
Threat Feed
high advisory

Node Version Manager: Command injection in nvm_ls (CVE-2026-118905)

Node Version Manager (nvm) versions 0.31.2 through 0.40.5 are vulnerable to command injection via malicious version strings due to improper sanitization in the nvm_ls function when invoked with tools like nvm use or automated shell hooks.

CVE search metadata

CVE search record: CVE-2026-118905. Severity: high. CVSS: 7.0. KEV: no. Product: Node Version Manager (0.31.2 <= 0.40.5). Brief: Node Version Manager: Command injection in nvm_ls (CVE-2026-118905). Brief link: https://feed.craftedsignal.io/briefs/2026-10-nvm-command-injection/

Triage facts

Revision 1
Applicability
Node Version Manager (0.31.2 <= 0.40.5)
Evidence
Unknown
Severity
High
Action
Elevated
Sources
1 public source
Freshness
Revision 1Oct 29, 07:09 UTC
Vulnerabilities
1 CVE
Source quality
A1Likely

CVE-2026-118905 describes a command injection vulnerability in nvm (Node Version Manager) versions 0.31.2 through 0.40.5. The nvm_ls function uses an improperly sanitized sed program to filter installed versions. By providing a version string containing specific characters such as #, an attacker can escape the intended sed address context and inject arbitrary commands.

The vulnerability is triggered when an attacker-controlled version string is passed to commands like nvm use, nvm which, nvm ls, nvm version, nvm run, or nvm exec, or via the NODE_VERSION environment variable. Users employing auto-switching hooks (e.g., cdnvm or load-nvmrc) or scripts that pass raw .nvmrc contents to nvm commands are at particular risk, as changing to a directory containing a malicious .nvmrc file can trigger execution. The issue is resolved in version 0.40.6.

Impact

Successful exploitation allows arbitrary command execution as the user running the nvm command or the shell hook. Using GNU sed, this can lead to direct shell command execution; using BSD sed, this can lead to unauthorized file read and write operations.

Recommendation

  • Patch nvm to version 0.40.6 or later immediately.
  • Audit environments for scripts that pass file contents or environment variables directly to nvm commands without validation.
  • Audit shell initialization files (.bashrc, .zshrc) for cdnvm or load-nvmrc hooks that automatically process .nvmrc files without sanitization.

Immediate actions

Upgrade nvm to version 0.40.6 or later on all developer workstations and CI/CD agents.

IT Operations 48h

Threat Hunt

Identify .nvmrc files containing shell metacharacters or newline characters.

T1059.004 medium medium confidence hunt now

Data: File system metadata and content scanning