Skip to content

fix(security): refuse the gh and kubectl keys that run a program - #2732

Merged
dan-petty merged 4 commits into
mainfrom
fix/2672-refuse-gh-kubectl-code-env-keys
Oct 30, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/2672-refuse-gh-kubectl-code-env-keys

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

build_subprocess_env now refuses a caller override of the keys that make gh or kubectl run a program that the caller names: GH_BROWSER, BROWSER, GH_EDITOR, GH_PAGER, GH_PATH, KUBE_EDITOR and KUBECTL_EXTERNAL_DIFF. Each raises the usual SecurityError, with isolation on and off. An isolated child gets none of them from the environment.

Why: probes with gh 2.103.3 and kubectl v1.37.1 (temporary HOME, marker program, loopback only) ran the marker for each key. GH_PATH works in two steps: gh auth setup-git writes it as the git credential helper, and git then starts it. #2633 left these keys open because no probe of them had run.

GH_CONFIG_DIR, KUBECONFIG and XDG_DATA_HOME stay accepted. Callers set them on purpose and name a file that they control, as for HOME and XDG_CONFIG_HOME in #2483. The design and ARCHITECTURE.md record the risk: a gh alias or an exec credential plug-in in such a file starts a program.

The seven names sit in a block of their own in CONST_CODE_LOADING_ENV_PATTERNS. The Purpose of the subprocess-environment spec names gh and kubectl.

Change: openspec/changes/archive/2026-10-30-2672-refuse-gh-kubectl-code-env-keys/

Closes #2672

@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 30, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Targeted tests on the rebased branch (test_subprocess_env_gh_kubectl.py, test_subprocess_env_boundary.py, test_openspec_gate.py): 583 passed.

Fail-to-pass, devops ci fail-to-pass --base origin/main, run on the test commit before the fix:

29 failed on base (29 failed and 4 passed in tests/test_subprocess_env_gh_kubectl.py; 0 errored).
  failed on base: tests.test_subprocess_env_gh_kubectl::test_run_subprocess_starts_no_child_for_a_refused_gh_key (Failed: DID NOT RAISE SecurityError)
29 failed on base (29 failed and 4 passed in tests/test_subprocess_env_gh_kubectl.py; 0 errored).
failed on base: 28 cases of test_a_caller_override_that_makes_gh_or_kubectl_run_a_program_is_refused (7 keys x upper and lower case x isolated and not isolated: DID NOT RAISE SecurityError)

@dan-petty
dan-petty marked this pull request as ready for review October 30, 2026 01:31
@dan-petty
dan-petty merged commit ad0bdf1 into main Oct 30, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2672-refuse-gh-kubectl-code-env-keys branch October 30, 2026 01:31
dan-petty pushed a commit that referenced this pull request Oct 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.21.4](v0.21.3...v0.21.4)
(2026-10-30)


### Bug Fixes

* **ai:** name each prewarm server by host and port
([#2737](#2737))
([2e2e4fa](2e2e4fa)),
closes [#2676](#2676)
* **ai:** the mcp benchmark tool takes no file path
([#2738](#2738))
([5d5da15](5d5da15)),
closes [#2704](#2704)
* **config:** redact a removed credential in the config copies
([#2734](#2734))
([f663344](f663344)),
closes [#2645](#2645)
* **rag:** name the Qdrant server by host and port
([#2733](#2733))
([39aca9d](39aca9d)),
closes [#2709](#2709)
* **roadmap:** tick turn and kept diff for implement steps
([#2744](#2744))
([890d2a6](890d2a6)),
closes [#2721](#2721)
* **security:** refuse the gh and kubectl keys that run a program
([#2732](#2732))
([ad0bdf1](ad0bdf1)),
closes [#2672](#2672)
* **security:** refuse the keys that make a child write a file
([#2746](#2746))
([1cd187e](1cd187e)),
closes [#2674](#2674)

---
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): the subprocess environment guard accepts the gh and kubectl keys that make a child run a program

1 participant