CVE-2026-118905
published high CVSS 4.0 · 7.1nvm_ls lets an untrusted version string inject sed commands, executing arbitrary commands with GNU sed
Package status and fixes
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| nvm-sh | — | nvm0.31.2 to < 0.40.6 · Other versions: unaffected | Affected | Not stated | 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.
Related advisories
Vendor advisories explicitly linked to this CVE.
No linked advisories were found for this CVE.
Assessment
CVSS risk assessment and additional context for this vulnerability.
- CVSS version
- 4.0
- Base score
- 7.1 / 10
- Severity
- high
- Provider
- harborist · cna
- Vector string
- CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
- Scenarios
- en: GENERAL
Additional Assessments
| Version | Score | Severity | Provider | Vector | Scenarios |
|---|---|---|---|---|---|
| 3.1 | 7.0 | high | harborist · cna | CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H | en: GENERAL |
Publisher product statements
Version ranges and default statuses as reported by each provider.
| Vendor | Product | Version status | Source |
|---|---|---|---|
| nvm-sh | nvm | 0.31.2 to < 0.40.6 (affected · semver)Default: unaffected | harborist · cna |
Weaknesses
2- CWE-78 CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- CWE-94 CWE-94 Improper Control of Generation of Code ('Code Injection')
References
4- Fix commit 82315e2b https://github.com/nvm-sh/nvm/commit/82315e2b189528a006da6701eac30e8c364ffd22
- nvm-sh/nvm#3854 https://github.com/nvm-sh/nvm/pull/3854
- v0.40.6 https://github.com/nvm-sh/nvm/releases/tag/v0.40.6
- GHSA-vgqf-vc3m-4wv3 https://github.com/nvm-sh/nvm/security/advisories/GHSA-vgqf-vc3m-4wv3
Provider assertions
2harborist · cna
nvm_ls lets an untrusted version string inject sed commands, executing arbitrary commands with GNU sed
CISA-ADP · adp
CISA ADP Vulnrichment
Provenance
- Schema
- 5.2
- Searchable
- yes
- Content hash
- 5903e7e593029c944bb7e90c68336c7eec0f6511f02f65c787d47ee57822845f
- Ingested
- 07 Nov 2026, 23:39:08 UTC
- Source record
- Official CVE record