🔍 CVE-2026-118905

7.0
CVSS Score
HIGH
2026-10-29
2026-11-05 21:18
✅ 완료

🇰🇷 한글 설명

Node Version Manager(nvm) 0.31.2~0.40.5 버전에서 nvm_ls 함수가 버전 문자열을 sed 프로그램에 삽입할 때 '#' 및 백슬래시를 제대로 이스케이프하지 않아, 악의적인 버전 문자열이 sed 명령으로 해석되어 임의의 셸 명령이 실행될 수 있습니다. 특히 .nvmrc 파일을 자동 전환하는 cdnvm, load-nvmrc 후크 사용 시 악성 .nvmrc가 있는 디렉터리로 이동하는 것만으로도 공격이 성립합니다.

💡 쉬운 설명

nvm이라는 Node.js 버전 관리 도구의 입력 처리 결함으로, 프로젝트 폴더의 .nvmrc 파일에 악성 코드가 숨겨져 있으면 그 폴더에 들어가는 것만으로 사용자 권한으로 명령이 실행될 수 있습니다. 자동 전환 기능을 쓰는 사용자는 특히 주의해야 합니다.

🇺🇸 원문 (English)

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.

📍 영향받는 시스템

nvm 0.31.2 ~ 0.40.5 (0.40.6 미만 전체, 0.40.4 이상은 # 이스케이프 일부 적용되나 백슬래시 문제 잔존 가능)

⚔️ 공격 벡터

악성 버전 문자열(#, \# 포함)이 담긴 .nvmrc 파일이 있는 디렉터리 진입 시 cdnvm/load-nvmrc 자동 후크 또는 nvm use "$(cat .nvmrc)" 실행으로 sed의 e 명령을 통해 임의 셸 명령 실행

🛡️ 대응 방법

nvm을 0.40.6 이상으로 업그레이드하고, 신뢰할 수 없는 .nvmrc 파일에 대해 자동 전환 후크를 비활성화하세요.

🔧 검증 코드

출력된 버전이 0.40.6 미만(0.31.2~0.40.5 범위)이면 취약하므로 0.40.6 이상으로 업데이트가 필요하며, 명령이 실패하면 nvm이 설치되지 않은 것입니다.

Shell / Script
nvm --version 2>/dev/null || (. "${NVM_DIR:-$HOME/.nvm}/nvm.sh" >/dev/null 2>&1 && nvm --version)

📊 CVSS Vector String

CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H

💻 영향받는 소프트웨어

Bash Node.js