Repository navigation
fix(security): refuse the git keys that make git run a program - #2641
Merged
Merged
Conversation
…ogram (#2483) The tests fail on main for the right reason: the guard accepts each git key, and an isolated child gets the ambient GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_EXEC_PATH, EDITOR and PAGER. Two tests pin what the fix must keep: the SSH option of the Argo CD fetch, and the global git file of git config --global.
build_subprocess_env refused no git key, so a caller override of GIT_CONFIG_COUNT with its pairs, GIT_SSH_COMMAND, GIT_CONFIG_GLOBAL or GIT_EXEC_PATH made a git child run a program. The guard now refuses these keys and the other keys that git documents as a program, a configuration file or a directory of hooks. - An isolated child no longer gets GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM, GIT_EXEC_PATH, EDITOR or PAGER from the environment. - The Argo CD fetch gets its SSH option as git -c core.sshCommand, and its environment keeps only GIT_TERMINAL_PROMPT. - The git config --global calls name GIT_CONFIG_GLOBAL in extra_allowed_env, so they write the file that the person set. Closes #2483
The test imported the private _run_cmd of the cluster runtime. It now starts git with the public run_subprocess, and the recorder types its env parameter, so it needs no type ignore.
…not set (#2483) A review found keys that run a program and that the list of names missed: GIT_TEST_FSMONITOR, GIT_TEST_MAINT_SCHEDULER, GIT_ALLOW_PROTOCOL, GIT_DIFFTOOL_EXTCMD, MERGE_TOOLS_DIR, LESSOPEN and LESSCLOSE, and the GIT_TRACE keys that write a file of the caller. The tests refuse each one, with a key that no page lists, GIT_EXAMPLE_KEY, to pin the rule that a GIT_ key is refused unless the guard accepts it. A new test pins that no key of the ambient allowlist is refused.
…ot set (#2483) A list of names missed keys that run a program: GIT_TEST_FSMONITOR, GIT_TEST_MAINT_SCHEDULER, GIT_ALLOW_PROTOCOL, GIT_DIFFTOOL_EXTCMD and MERGE_TOOLS_DIR. It also let GIT_TRACE write a file that the caller names, and it missed LESSOPEN, which makes the pager of git run a program. - CONST_CODE_LOADING_ENV_PATTERNS holds GIT_*, and CONST_GIT_ACCEPTED_ENV names the five keys that callers set and that run no program. - The guard also refuses MERGE_TOOLS_DIR, LESSOPEN and LESSCLOSE. - XDG_CONFIG_HOME stays accepted, because devops openspec sets it.
…sentences (#2483) The design records the rule, the accepted keys, XDG_CONFIG_HOME, the trace keys and the replacement of criterion 3 of the issue. The evidence of the rejected pin names the code that acts on every git child. ARCHITECTURE.md has a bullet for the git child environment.
Owner
Author
|
Test results of the branch, on git 2.55.0.
Examples of the failures on the base tree: Two tests pass on the base tree, and they pin what the fix keeps: the SSH option of the Argo CD fetch reaches |
…#2483) Bandit B108 flagged two /tmp paths in the test of the accepted git keys, and the Static Analysis check failed. The paths now come from tmp_path.
dan-petty
marked this pull request as ready for review
October 29, 2026 14:22
dan-petty-release Bot
added a commit
that referenced
this pull request
Oct 29, 2026
🤖 I have created a release *beep* *boop* --- ## [0.16.2](v0.16.1...v0.16.2) (2026-10-29) ### Bug Fixes * **security:** refuse the git keys that make git run a program ([#2641](#2641)) ([b4b1277](b4b1277)), closes [#2483](#2483) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.
build_subprocess_envrefused no git key. A caller override ofGIT_CONFIG_COUNTwith its pairs,GIT_SSH_COMMAND,GIT_CONFIG_GLOBALorGIT_EXEC_PATHmade a git child run a program that the caller did not choose. The ambient allowlist also passedGIT_CONFIG_GLOBAL,GIT_CONFIG_SYSTEM,GIT_EXEC_PATH,EDITORandPAGERto an isolated child.GIT_key of a caller, but the five keys that callers set and that run no program:GIT_TERMINAL_PROMPT,GIT_AUTHOR_NAME,GIT_AUTHOR_EMAIL,GIT_COMMITTER_NAMEandGIT_COMMITTER_EMAIL. A list of names missed keys that run a program, for exampleGIT_TEST_FSMONITOR,GIT_ALLOW_PROTOCOLandGIT_DIFFTOOL_EXTCMD. A key that git adds later stays refused until a person reviews it.EDITOR,VISUAL,PAGER,LESSOPEN,LESSCLOSEandMERGE_TOOLS_DIR.XDG_CONFIG_HOMEstays accepted, becausedevops openspecsets it.DEFAULT_ALLOWED_ENV_VARSno longer holdsGIT_CONFIG_GLOBAL,GIT_CONFIG_SYSTEM,GIT_EXEC_PATH,EDITORandPAGER. Thus no refused key reaches an isolated child from the environment.render_at_revisiongets its SSH option asgit -c core.sshCommand=ssh -o BatchMode=yes. Its environment keeps onlyGIT_TERMINAL_PROMPT=0. This replaces the post-guardGIT_SSH_COMMANDstep of criterion 3 of the issue, because the result is the same and the guard keeps no exception.git config --globalcalls nameGIT_CONFIG_GLOBALinextra_allowed_env, so that they write the file that the person set.ARCHITECTURE.mdand thesubprocess-environmentspec describe the git keys. Follow-up for the SSH keys: fix(security): the subprocess environment guard accepts the ssh keys that make an ssh child run a program #2633.Change: openspec/changes/archive/2026-10-29-2483-refuse-git-code-env-keys/
Closes #2483