fix: Windows env-var deny/mask matching must fold name case - #477
Open
ig-ant wants to merge 2 commits into
Open
Conversation
Windows environment-variable names are case-insensitive, but credential env-var matching compared names byte-for-byte, so a host spelling like GiThUb_ToKeN escaped a mask of GITHUB_TOKEN and case-variant duplicates could reach the sandboxed child's env block. - mask lookups (buildMaskedEnvVars), AWS pair linking (registerAwsPairs), and awsPairs config validation now compare env names with an ordinal ASCII case fold on win32 (new windowsEnvNameKey / envNameComparisonKey / readEnvCaseAware helpers); POSIX comparisons stay exact, where names really are case-sensitive - the Windows --env overlay dedupes case-variant spellings on the same fold srt-win's build_env_block uses: different values collapse to the later writer so the documented setEnvVars -> generated -> gitCfg precedence holds across spellings, while same-value case twins (HTTP_PROXY/http_proxy) are kept for case-sensitive POSIX-ported tools - mode:'deny' names now also filter the overlay's ambient PATH/PATHEXT forwards case-insensitively (deny is otherwise structural on Windows: the child starts from a fresh profile env); masks and the sandbox's own plumbing still win over a deny, matching the POSIX env -u ordering - regression tests: mixed-case host key vs mask entry (win32) with the exact-spelling preference, case-variant overlay dedupe and deny filtering, AWS pair case-fold linking and validation, and POSIX pins that mixed-case spellings stay distinct there
… rule - config validation now rejects credentials.envVars entries whose names collide under the platform fold (case-variants on Windows, exact duplicates everywhere): duplicates mint conflicting mask values for one variable and silently break AWS SigV4 re-signing when the registry binds a sentinel the child never holds - new shared findByEnvName helper is the one entry-matching rule used by both config validation and registerAwsPairs; the pair layer now matches the FIRST fold-equal entry and reads its sentinel under that entry's own spelling, so validation and runtime cannot diverge even on unvalidated input (a non-whole-value first match registers no pair instead of borrowing a fold-twin's sentinel) - windowsEnvNameKey: same ASCII-only fold, expressed as toUpperCase inside the [a-z] replace instead of char-code arithmetic - winsrt overlay tests now compare names with the production fold - tests: fold-duplicate config rejected on win32 / accepted as distinct on POSIX, exact duplicates rejected everywhere, and a runtime pin that a fold-twin's sentinel is never picked up
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
GiThUb_ToKeNescaped a mask ofGITHUB_TOKENwindowsEnvNameKey(ASCII-ordinal fold, same as srt-win'sto_ascii_uppercase),envNameComparisonKey,readEnvCaseAware(exact key wins, then first case-insensitive match — deterministic),findByEnvName(one matching rule shared by config validation and runtime)credentials.envVarsnames on win32 (two case-variant mask entries would mint conflicting sentinels and silently break SigV4 re-signing); AWS pair registration reads the matched entry's own spelling so validation and runtime cannot diverge--envoverlay dedupes case-variant spellings (later writer wins when values differ; same-valueHTTP_PROXY/http_proxytwins kept for case-sensitive POSIX-ported tools) and filters ambient PATH/PATHEXT forwards againstmode:'deny'names case-insensitivelymode:'deny'remains structurally enforced on Windows (fresh profile env); the overlay filter closes the case-variant hole for anything the overlay forwardsTest plan
pAtHdeny drops PATH; mask beats deny; fold-duplicate config rejected (accepted as distinct on POSIX); fold-twin extract entry registers no AWS pair