Skip to content

fix(security): refuse the uv and npm keys that run a program - #2749

Merged
dan-petty merged 7 commits into
mainfrom
fix/2673-refuse-uv-npm-program-env-keys
Oct 30, 2026
Merged

dan-petty merged 7 commits into
mainfrom
fix/2673-refuse-uv-npm-program-env-keys

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Decision for the owner

The issue asks for "Block UV_PYTHON from the ambient environment". This change does not do that. It refuses UV_PYTHON and UV_PYTHON_INSTALL_DIR from a caller, and it still passes both from the environment of the person to an isolated child. Reason: CI speed is P0, and #1735 shows that the gate's uv run on a runner rebuilds its environment, with every wheel downloaded again, when it loses these two keys. Facts: the ambient value comes from the shell of the person, from setup-uv on the runner, or from the Dockerfile; whoever controls the ambient environment also controls PATH, which decides what a child starts. The project still drops ambient LD_PRELOAD and PYTHONPATH, so "the ambient environment is trusted" is not its general rule, only the rule for these two keys. UV_PROJECT_ENVIRONMENT has no such need and is dropped from the ambient environment.

What and why

build_subprocess_env now refuses a caller override of the keys that make uv or npm start a program that the caller names: UV_PYTHON, UV_PYTHON_INSTALL_DIR, UV_PROJECT_ENVIRONMENT, VIRTUAL_ENV, npm_config_script_shell, npm_config_node_options, npm_config_git, npm_config_editor, npm_config_init_module, npm_config_shell, npm_config_python and PYTHON. Each raises the usual SecurityError, with isolation on and off. The npm names with two words also match the spelling with a hyphen, which npm reads as the same setting.

  • VIRTUAL_ENV leaves the ambient allowlist. No child of devops-cli reads it.
  • UV_PROJECT_ENVIRONMENT joins the denied patterns, so an isolated child does not get it from the environment. No file of the repository sets it.
  • npm_config_userconfig, npm_config_globalconfig and UV_CONFIG_FILE stay accepted. devops install-tools sets the first two, and each key names a file that the caller controls, as GH_CONFIG_DIR does (fix(security): the subprocess environment guard accepts the gh and kubectl keys that make a child run a program #2672).
  • devops install-tools runs npm ci, which can build a native package, so npm_config_python and PYTHON matter for it.

Why: probes with uv 0.13.6, npm 11.19.1 and node 24.22.2 (offline, temporary HOME, marker program, a control run without the key) ran the marker for each refused key. The change claims only probed keys. GOFLAGS is not claimed, because go is not installed here.

Change: openspec/changes/archive/2026-10-30-2673-refuse-uv-npm-program-env-keys/

Closes #2673

…re refused

Failing tests for #2673, with the OpenSpec change that plans the fix.
…gram

build_subprocess_env now refuses a caller override of UV_PYTHON, UV_PYTHON_INSTALL_DIR, UV_PROJECT_ENVIRONMENT, VIRTUAL_ENV, npm_config_script_shell, npm_config_node_options, npm_config_git, npm_config_editor and npm_config_init_module, with isolation on and off. The npm names also match the spelling with a hyphen, which npm reads as the same setting. VIRTUAL_ENV leaves the ambient allowlist, so an isolated child no longer gets it.

Why: probes with uv 0.13.6, npm 11.19.1 and node 24.22.2 (temporary HOME, marker program, offline, loopback only) ran the marker for each key. The prefix UV_ stays in the allowlist: the gate on a CI runner needs UV_PYTHON and UV_PYTHON_INSTALL_DIR from the environment to keep its built environment (#1735). npm_config_userconfig, npm_config_globalconfig and UV_CONFIG_FILE stay accepted: callers set them and name a file that they control. GOFLAGS is not claimed, because go is not installed and no probe ran.

Change: openspec/changes/2673-refuse-uv-npm-program-env-keys/
…ENVIRONMENT

build_subprocess_env also refuses npm_config_shell, npm_config_python and PYTHON from a caller: probes ran the marker for each (npm explore, and node-gyp through npm install). UV_PROJECT_ENVIRONMENT joins the denied patterns, so an isolated child no longer gets it from the environment: no file of the repository sets it. UV_PYTHON and UV_PYTHON_INSTALL_DIR still reach an isolated child, as the gate on a CI runner needs them (#1735).
@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

Test results (after the merge of origin/main, which holds #2746):

  • devops ci test on tests/test_subprocess_env_uv_npm.py, test_subprocess_env_boundary.py, test_subprocess_env_gh_kubectl.py, test_subprocess_env_file_write.py and test_install_tools.py: 711 passed.
  • devops docs check: clean. The pre-commit hooks and the pre-push gate passed.

Fail-to-pass (devops ci fail-to-pass --base origin/main), last line: 64 failed on base (64 failed and 536 passed in tests/test_subprocess_env_boundary.py, tests/test_subprocess_env_uv_npm.py; 0 errored).

Probes (uv 0.13.6, npm 11.19.1, node 24.22.2; offline, temporary HOME, marker program, a control without the key) are in the proposal, section Feasibility. Not claimed: GOFLAGS (go is not installed).

@dan-petty
dan-petty marked this pull request as ready for review October 30, 2026 02:00
@dan-petty
dan-petty merged commit c5a4596 into main Oct 30, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2673-refuse-uv-npm-program-env-keys branch October 30, 2026 02:00
dan-petty pushed a commit that referenced this pull request Oct 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.22.0](v0.21.4...v0.22.0)
(2026-10-30)


### Features

* **k8s:** admission policy for the Service Jobs
([#2730](#2730))
([4be83c2](4be83c2)),
closes [#2696](#2696)


### Bug Fixes

* **security:** refuse the uv and npm keys that run a program
([#2749](#2749))
([c5a4596](c5a4596)),
closes [#2673](#2673)

---
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 uv and npm keys that make a child run a program

1 participant