Repository navigation
fix(security): refuse the uv and npm keys that run a program - #2749
Merged
Merged
Conversation
…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).
Owner
Author
|
Test results (after the merge of origin/main, which holds #2746):
Fail-to-pass ( 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
marked this pull request as ready for review
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>
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.
Decision for the owner
The issue asks for "Block UV_PYTHON from the ambient environment". This change does not do that. It refuses
UV_PYTHONandUV_PYTHON_INSTALL_DIRfrom 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'suv runon 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, fromsetup-uvon the runner, or from theDockerfile; whoever controls the ambient environment also controlsPATH, which decides what a child starts. The project still drops ambientLD_PRELOADandPYTHONPATH, so "the ambient environment is trusted" is not its general rule, only the rule for these two keys.UV_PROJECT_ENVIRONMENThas no such need and is dropped from the ambient environment.What and why
build_subprocess_envnow refuses a caller override of the keys that makeuvornpmstart 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_pythonandPYTHON. Each raises the usualSecurityError, 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_ENVleaves the ambient allowlist. No child of devops-cli reads it.UV_PROJECT_ENVIRONMENTjoins 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_globalconfigandUV_CONFIG_FILEstay accepted.devops install-toolssets the first two, and each key names a file that the caller controls, asGH_CONFIG_DIRdoes (fix(security): the subprocess environment guard accepts the gh and kubectl keys that make a child run a program #2672).devops install-toolsrunsnpm ci, which can build a native package, sonpm_config_pythonandPYTHONmatter 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.
GOFLAGSis not claimed, becausegois not installed here.Change: openspec/changes/archive/2026-10-30-2673-refuse-uv-npm-program-env-keys/
Closes #2673