fix: prefer exact PATH during trusted executable resolution - #128
Open
GautamSharma99 wants to merge 1 commit into
Open
fix: prefer exact PATH during trusted executable resolution#128GautamSharma99 wants to merge 1 commit into
GautamSharma99 wants to merge 1 commit into
Conversation
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.
Summary
Prefer the exact
PATHenvironment variable when resolving trusted executables, while retaining the existing case-insensitive fallback for environments such as Windows that commonly expose the variable asPathor another casing.Fixes #41.
Problem
resolveTrustedExecutablepreviously searched all environment entries case-insensitively and selected the first name whose uppercase form wasPATH.On POSIX, environment names are case-sensitive.
pathandPATHare separate variables, and process execution consultsPATH. If a lowercasepathentry appeared earlier in the supplied environment object, trusted executable resolution searched that value instead of the real POSIXPATH.This made resolution depend on object insertion order. It could select a different Git or Python executable, or report that no trusted executable was available even though the actual
PATHcontained one. The selected value was also published as the sanitized childPATH.Changes
environment["PATH"]first.PATHvalue is unavailable.PATH.pathdecoy inserted before the realPATH.PATH, the decoy is ignored, both original casing variants are removed, and the child receives only the sanitized canonicalPATH.Compatibility
Windows compatibility is preserved. Existing coverage continues to verify that mixed-case variables such as
PathandpAtHare accepted when an exactPATHentry is not present.An explicitly empty
PATHalso remains authoritative instead of unexpectedly falling back to a differently cased POSIX variable.Security impact
This keeps the trusted-executable boundary aligned with POSIX environment semantics. A lowercase variable supplied by an SDK embedder or inherited from local tooling can no longer redirect Git or Python resolution when a valid exact
PATHis present.The change does not expand the existing trust boundary or alter executable canonicalization, protected-root rejection, executable permission checks, or child-environment sanitization.
Verification
pnpm run formatpnpm run typespnpm run buildgit diff --check