mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-06-07 06:47:08 +08:00
[Fix] nvm_download_artifact: reject version strings with disallowed characters
The mirror-supplied (untrusted) version flows into download URLs, filesystem paths, and the checksum awk match. Reject any version outside the node/io.js grammar (`[0-9A-Za-z._+-]`) before it is used. A blocklist of metacharacters is used rather than a strict semver allowlist so RCs, nightlies, v8-canary, and io.js versions still install. Completes the remediation of GHSA-3c52-35h2-gfmm.
This commit is contained in:
14
nvm.sh
14
nvm.sh
@@ -2506,10 +2506,16 @@ nvm_download_artifact() {
|
||||
local VERSION
|
||||
VERSION="${4}"
|
||||
|
||||
if [ -z "${VERSION}" ]; then
|
||||
nvm_err 'A version number is required.'
|
||||
return 3
|
||||
fi
|
||||
case "${VERSION}" in
|
||||
'')
|
||||
nvm_err 'A version number is required.'
|
||||
return 3
|
||||
;;
|
||||
*[!0-9A-Za-z._+-]*)
|
||||
nvm_err 'Invalid version: contains disallowed characters'
|
||||
return 3
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${KIND}" = 'binary' ] && ! nvm_binary_available "${VERSION}"; then
|
||||
nvm_err "No precompiled binary available for ${VERSION}."
|
||||
|
||||
Reference in New Issue
Block a user