🇰🇷 한글 설명
nvm 0.40.3 이하 버전의 nvm_download() 함수에서 eval을 사용하여 wget 명령을 실행할 때 NVM_AUTH_HEADER 환경 변수가 충분히 새니타이즈되지 않아 발생하는 커맨드 인젝션 취약점입니다. 공격자가 환경 변수를 조작하면 nvm install이나 nvm ls-remote 같은 명령 실행 시 임의의 쉘 명령을 주입할 수 있습니다.
💡 쉬운 설명
nvm 도구에서 다운로드 할 때 환경 변수를 제대로 검사하지 않아서, 나쁜 사람이 환경 변수를 조작하면 원치 않는 명령어를 실행시킬 수 있습니다. CI/CD 설정, dotfiles, Docker 이미지를 통해 환경 변수를 미리 설정해두면 피해자의 컴퓨터에서 자동으로 악의적인 코드가 실행됩니다.
🇺🇸 원문 (English)
A command injection vulnerability exists in nvm (Node Version Manager) versions 0.40.3 and below. The nvm_download() function uses eval to execute wget commands, and the NVM_AUTH_HEADER environment variable was not sanitized in the wget code path (though it was sanitized in the curl code path). An attacker who can set environment variables in a victim's shell environment (e.g., via malicious CI/CD configurations, compromised dotfiles, or Docker images) can inject arbitrary shell commands that execute when the victim runs nvm commands that trigger downloads, such as 'nvm install' or 'nvm ls-remote'.
📍 영향받는 시스템
nvm (Node Version Manager) 0.40.3 및 이하 버전
⚔️ 공격 벡터
CI/CD 설정, 손상된 dotfiles, Docker 이미지 등을 통해 NVM_AUTH_HEADER 환경 변수에 악의적 쉘 명령어를 주입
🛡️ 대응 방법
nvm을 최신 버전으로 업그레이드하거나 환경 변수 검증을 강화하고 eval 사용을 제거한 패치 적용
🔧 검증 코드
nvm 버전이 0.30~0.43 범위면 VULNERABLE 출력, 0.44 이상이면 OK 출력됨
nvm --version 2>/dev/null | grep -E '0\.(3[0-9]|4[0-3])\.' && echo 'VULNERABLE' || echo 'OK'