fix(subprocess): resolve executables against PATH not cwd on Windows; reject %VAR% paths - #1905
Draft
iankhou wants to merge 2 commits into
Draft
fix(subprocess): resolve executables against PATH not cwd on Windows; reject %VAR% paths#1905iankhou wants to merge 2 commits into
iankhou wants to merge 2 commits into
Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
…s; reject %VAR% paths Two Windows-specific hardening fixes to the shared subprocess module, plus a test that actually exercises the .cmd path. 1. resolveExecutable(): on Windows a bare program name spawned without a shell is searched for in the cwd *before* PATH, so a file planted in a handed-over cloud assembly (e.g. docker.bat) could shadow the real binary. run()/runSync() now resolve the executable to an absolute PATH hit up front and refuse a name that is not on PATH rather than let the cwd satisfy it. POSIX is unchanged (execvp already searches PATH only); explicit paths are honored verbatim. 2. quoteShellPart() (toolkit-lib): cmd.exe expands %VAR% even inside double quotes and a `cmd /c` line cannot reliably escape a percent, so a discovered path carrying a %...% reference is now refused loudly instead of being silently rewritten. 3. Adds a Windows-only test that runs a real .cmd shim with hostile arguments — the one path where cross-spawn's cmd.exe escaping is exercised (a plain .exe never is). NOTE: items 1 and 3 change Windows spawn behavior and must be validated by the Windows integ tests; the resolveExecutable logic is unit-tested cross-platform via a `platform` parameter.
iankhou
force-pushed
the
iankhou-windows-exec-resolution
branch
from
August 26, 2026 20:27
b334c08 to
9f440cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requires windows integ test verification
Follow-up to #1763 / #1849. Two Windows-specific hardening fixes to the shared subprocess module, plus a test that exercises the
.cmdpath.Summary
resolveExecutable()— on Windows a bare program name spawned without a shell is searched for in the working directory before PATH, so a file planted in a handed-over cloud assembly (e.g.docker.bat) could shadow the real binary.run()/runSync()now resolve the executable to an absolute PATH hit up front and refuse a name that is not on PATH rather than let the cwd satisfy it. POSIX is unchanged (execvp already searches PATH only); an explicit path (absolute or containing a separator) is honored verbatim.quoteShellPart()(toolkit-lib) — cmd.exe expands%VAR%even inside double quotes, and acmd /ccommand line cannot reliably escape a percent (doubling only works in batch files). A discovered path carrying a%...%reference is now refused loudly instead of being silently rewritten (an env var spliced into the path).A Windows-only test that runs a
.cmdshim with hostile arguments — the one path where cross-spawn's cmd.exe escaping is exercised (a plain.exe, as in every existing test, never is).Testing
resolveExecutable.cmdhostile-args test that will be run with the Windows integ workflow.%VAR%detection was verified in isolation;environment.test.tsruns in CI's Linux jest.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.