Skip to content
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

Changes when calling .cmd/.bat files on Windows (EINVAL) #987

Closed
ehmicky opened this issue Apr 26, 2024 · 0 comments
Closed

Changes when calling .cmd/.bat files on Windows (EINVAL) #987

ehmicky opened this issue Apr 26, 2024 · 0 comments

Comments

@ehmicky
Copy link
Collaborator

ehmicky commented Apr 26, 2024

On Windows, .cmd/.bat files must be interpreted by cmd.exe. Windows CreateProcess syscall (which is used under-the-hood by child_process.spawn()) automatically does this.

However, when cmd.exe is used, arguments are not escaped by Node.js. This leads to a potential shell injection. Therefore, Node.js just disallowed that behavior in Node 18.20.2, 20.12.2, 21.17.3 and 22.0.0.

This means that users calling .cmd/.bat files will now experience EINVAL errors, and must now use the shell: true option to fix this. This is quite a breaking change, so I am creating this issue for users to find the workaround. Also, I am expecting issues being created, which we can redirect to this issue.

We could potentially automatically add shell: true when detecting a .cmd/.bat file is being executed. This means resolving the executable full path (since those file extensions are usually omitted), which node-cross-spawn already does. However, doing so might create the vulnerability mentioned above, so we probably should not do anything there.

@ehmicky ehmicky closed this as completed Apr 26, 2024
@ehmicky ehmicky changed the title Changes when calling .cmd/.bat files Changes when calling .cmd/.bat files on Windows Apr 26, 2024
@ehmicky ehmicky changed the title Changes when calling .cmd/.bat files on Windows Changes when calling .cmd/.bat files on Windows (EINVAL) Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant