mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-11-22 17:11:29 +03:00
The symlink check and the `tee` were two steps, so anyone who can write `$PWD` could rename a symlink over `.nvmrc` in between, and `nvm use --save`/`nvm install --save` would truncate any file the user can write. Write the version in a private `mktemp -d` dir instead, and rename it into `$PWD/`: a rename replaces a symlink rather than following it, and moving into the directory (not onto `.nvmrc`) avoids landing inside a symlinked directory. An existing `.nvmrc` must be a writable regular file, since a rename would also replace a read-only one. `.nvmrc` is now a new file whose mode comes from the umask. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-EXZRTATX.