Security: Shell command injection risk from package directory name in execSync#1907
Security: Shell command injection risk from package directory name in execSync#1907
Conversation
The script interpolates `type` into a shell command: ``execSync(`git ls-files --others --deleted --exclude-standard --directory ed/${type}`)``. `type` comes from directory names under `packages`, which can be influenced by repository content. A crafted folder name containing shell metacharacters could execute arbitrary commands when this script runs.
Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
|
While this is indeed a security risk, is there any real viability to it, given that the file in question is not a part of any public API and is never exposed to userland code or input? Maybe a maintainer could chime in here (and please correct me if I'm mistaken!), but my initial read on this is that code in the |
|
Great question—you're right that this isn’t a public API/input path, so the risk depends on who can influence repo contents where the script runs. The viable scenario is CI or a maintainer running the tool on a branch/PR (including forks) where a crafted package directory name is present; in that context, repo files are effectively untrusted input. So this is mostly a hardening/supply-chain fix: low likelihood in normal use, but high impact if triggered, and |
2 similar comments
|
Great question—you're right that this isn’t a public API/input path, so the risk depends on who can influence repo contents where the script runs. The viable scenario is CI or a maintainer running the tool on a branch/PR (including forks) where a crafted package directory name is present; in that context, repo files are effectively untrusted input. So this is mostly a hardening/supply-chain fix: low likelihood in normal use, but high impact if triggered, and |
|
Great question—you're right that this isn’t a public API/input path, so the risk depends on who can influence repo contents where the script runs. The viable scenario is CI or a maintainer running the tool on a branch/PR (including forks) where a crafted package directory name is present; in that context, repo files are effectively untrusted input. So this is mostly a hardening/supply-chain fix: low likelihood in normal use, but high impact if triggered, and |
Summary
Security: Shell command injection risk from package directory name in execSync
Problem
Severity:
High| File:tools/bump-packages-minor.js:L54The script interpolates
typeinto a shell command:execSync(`git ls-files --others --deleted --exclude-standard --directory ed/${type}`).typecomes from directory names underpackages, which can be influenced by repository content. A crafted folder name containing shell metacharacters could execute arbitrary commands when this script runs.Solution
Use
execFileSync('git', ['ls-files', '--others', '--deleted', '--exclude-standard', '--directory',ed/${type}])instead of shell strings. Also validatetypeagainst expected package names (e.g.,['css','css6','elements','events','idl']).Changes
tools/bump-packages-minor.js(modified)