-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: spawn EINVAL on Windows with script-shell configured #42
Conversation
Making sure this actually works and fixes pnpm's CI jobs on my fork here: https://github.com/gluxon/pnpm/actions/runs/8690981281 |
Oh, this is similar to the overrated Rust vulnerability. Anyway, what are the possible ways a malicious actor could attack the user? From the developer's POV. He already run arbitrary script when installing packages from npm. This means that npm packages can already inject malicious command without command line argument injection. It is the developer's responsibility to audit the package before installing them. For the end user, it's hard to imagine an end user would use pnpm lifecycle to invoke a command. |
I'll update it in pnpm |
We might need to make more changes. 😞 My test above failed due to arguments parsing differently now.
|
I'll look at the problem above now. Sorry, I should have left this PR in draft while testing it. |
Wow, I didn't see that. It looks like this vulnerability hit many programming languages. The Node.js fix mentioned that the underlying argument parsing logic on Windows isn't standardized and hard to get right.
This sounds right. Appreciate the second thoughts on attack vectors. I was worried about setting |
Problem
Configuring
script-shell
in.npmrc
on Windows to a.bat
or.cmd
file,will result in:
This previously worked, but changed after the Node.js security release on April 10th, 2024.
What does npm do?
More modern versions of npm take the
script-shell
option and configure it as theshell
option to pass tospawn
directly.This repo currently executes
script-shell
directly instead of setting theshell
spawn config:Changes
I thought through a few options on how to fix this:
@npm/run-script
package and use that in pnpm.@npm/run-script
usesspawn
and pass{ shell: scriptShell }
as an option.{ shell: true }
on Windows whenscriptShell
is a batch file.I went with option 3 for now since:
EINVAL
issue.shell
option totrue
.