Files
nvm/test/fast/Unit tests
Jordan Harband 391a1ccde9 [Fix] nvm_process_nvmrc: check that the file read is the regular file at the path
`nvm_process_nvmrc` tested `[ ! -L ]` and then opened the path again with `cat`,
so another local user who can write the directory
could rename a symlink over `.nvmrc` in between (timed by `cat`'s exec),
and the target's content was printed and passed to `find` and `sed` as a version,
where that user could read it from the process list (67268ebc's check, bypassed).

sh can't open without following symlinks,
so read the file once, from one open,
and when its content is not a version or an existing alias,
show it or pass it on only if one `lstat` (`find -prune -type f -links 1 -inum`)
finds a regular file at the path with the open file's inode and no other links.
Anything else is handled as a symlink.
A hard link to another user's file, where the OS allows one, is refused the same way.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-WJUJDPM2.
2026-11-16 15:12:18 -08:00
..