Repository navigation
Description
Problem Description
build_subprocess_env in src/devops_cli/core/process.py refuses a caller override that CONST_CODE_LOADING_ENV_PATTERNS matches. #2674 (pull request #2746) adds the keys that make curl, git, Python, Node.js and the glibc loader write a file that the caller names. The guard accepts more keys of the same kind in two other tools. A review of #2674 probed them with the real tools:
PYTEST_ADDOPTSwith the value--junitxml=<path>: pytest 9.1.1 wrote a JUnit file at the path. The key gives pytest any option, so it can also make pytest write other files or load a plug-in with-p.npm_config_logs_dir: npm wrote a debug log into the directory that the key names, when it rannpm ls.npm_config_cache: npm wrote a cache file into the directory that the key names, when it rannpm ls.
These keys belong with the keys of #2674 (keys that write a file) and with the keys of #2673 (the uv and npm keys that run a program). npm_config_* is a family: npm reads each npm setting from a key with this prefix, so the fix has to decide between the family and the single keys.
Not claimed: the reviewer did not reproduce GNUTLS_KEYLOGFILE, PERLIO_DEBUG, MALLOC_TRACE or LOCPATH. No probe ran for ruby, go, java, dotnet or cargo. The fix issue must probe each key it claims.
Reproduction Steps
- Run
uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(sorted(k for k in b(env={"PYTEST_ADDOPTS": "x", "npm_config_logs_dir": "x", "npm_config_cache": "x"}) if k in ("PYTEST_ADDOPTS", "npm_config_logs_dir", "npm_config_cache")))'. - In a temporary directory
<dir>, runenv -i PATH=<path> HOME=<dir> PYTEST_ADDOPTS=--junitxml=<dir>/junit.xml pytest <a test file in <dir>>. Read<dir>/junit.xml. - Run
env -i PATH=<path> HOME=<dir> npm_config_logs_dir=<dir>/logs npm_config_cache=<dir>/cache npm lsin a directory with apackage.json. List<dir>/logsand<dir>/cache.
Expected vs Actual Behavior
Expected: build_subprocess_env raises SecurityError for a caller override of a key that makes a child write a file that the caller names, or the design of the guard names each such key that it accepts and the reason.
Actual: step 1 returns all three keys with no SecurityError. Steps 2 and 3 show the files that the keys name.
Environment Diagnostics
- DevOps CLI Version: main after fix(ai): the mcp benchmark tool takes no file path #2738, with fix(security): refuse the keys that make a child write a file #2746 open
- OS & Architecture: Linux x86_64 (WSL2)
- Execution Environment: DevContainer
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate. fix(security): the subprocess environment guard accepts the uv and npm keys that make a child run a program #2673 asks for the uv and npm keys that run a program, and fix(security): the subprocess environment guard accepts the keys that make a child write TLS secrets or a log to a file that the caller names #2674 asks for the keys of other tools that write a file.
Proposed design
Problem statement
The subprocess environment guard in build_subprocess_env accepts three caller-provided keys that make a child process write a file the caller names. PYTEST_ADDOPTS lets pytest write a JUnit file or load a plugin. npm_config_logs_dir and npm_config_cache let npm write a log or a cache file. The guard must refuse these keys, as it already refuses the keys of #2674.
Acceptance criteria
Requirement: Refuse PYTEST_ADDOPTS override
build_subprocess_env SHALL raise SecurityError when a caller override sets PYTEST_ADDOPTS.
Scenario: Caller sets PYTEST_ADDOPTS
- WHEN A caller passes PYTEST_ADDOPTS in the env dict to build_subprocess_env
- THEN build_subprocess_env raises SecurityError
Requirement: Refuse npm_config family overrides
build_subprocess_env SHALL raise SecurityError when a caller override sets any key matching the npm_config_* family.
Scenario: Caller sets npm_config_logs_dir
- WHEN A caller passes npm_config_logs_dir in the env dict to build_subprocess_env
- THEN build_subprocess_env raises SecurityError
Requirement: Existing refusals unchanged
build_subprocess_env SHALL continue to raise SecurityError for every key already in CONST_CODE_LOADING_ENV_PATTERNS.
Scenario: Caller sets LD_PRELOAD
- WHEN A caller passes LD_PRELOAD in the env dict to build_subprocess_env
- THEN build_subprocess_env raises SecurityError
Existing Tool Considered
No check has run. No open, maintained tool or library covers this need. The project builds its own guard in src/devops_cli/core/process.py. The written cost is 3 pattern entries and a comment in src/devops_cli/config/constants.py, plus 6 test cases in tests/test_subprocess_env_boundary.py. The cost to keep and fix is zero: the patterns are static and no update is needed until a new tool is added. The elapsed time to build is under 10 minutes.
Key questions
- Does the npm fix deny the npm_config_ family or only the two probed keys?*: Deny the family with the pattern NPM_CONFIG_. The existing guard already uses family patterns for dangerous families: DYLD_ and BASH_FUNC_*. The issue states that npm reads each npm setting from a key with this prefix, so any member of the family can direct a file write. A single-key list would miss future or unprobed members. (best practice) [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md]
- Chosen: Deny the NPM_CONFIG_* family. Consistent with the existing DYLD_* and BASH_FUNC_* family patterns. npm reads every setting from a key with this prefix, so any member can direct a file write. A single-key list would miss unprobed members.
- Rejected: Deny only npm_config_logs_dir and npm_config_cache. Narrower scope, but npm's config system is open-ended. A future or unprobed npm_config_* key could also direct a file write. The existing design uses family patterns for this case.
- Is PYTEST_ADDOPTS a code-loading key, a file-writing key, or both?: Both. The value --junitxml= makes pytest write a JUnit file. The value -p makes pytest load a plugin, which runs code. The guard refuses it under the same constant as the other keys. [sources: src/devops_cli/core/process.py]
- Must the fix probe each key it claims before adding it to the guard?: Yes. The issue states: 'The fix issue must probe each key it claims.' The reviewer probed PYTEST_ADDOPTS, npm_config_logs_dir and npm_config_cache with the real tools. The implementation must include a probe for each key it adds. [sources: src/devops_cli/core/process.py]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Oct 30, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(security)scope of the title gives the scope.A caller can make a child write files to arbitrary paths, which is a real security gap.Closing the gap prevents unauthorized file writes in spawned child processes.The fix must probe each key and decide the npm_config_* family scope, not just add three names.Both target the same guard in build_subprocess_env for keys that make a child write a file, but they name different keys and different tools.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 07fb4c2 (see proposed design in issue body).
devops-cli-service commentedon Oct 30, 2026
The stage job stopped. The inputs of the step of the task group "Add PYTEST_ADDOPTS to the subprocess environment guard" hold 48286 tokens, over the budget of 40000 tokens, also after the model split the groups once. A person decides how to split the item. The job stages the item again when a person runs it with --item 2747.
The task groups:
fix(roadmap): measure a task group by the files its step reads (#2847)
devops-cli-service commentedon Oct 31, 2026
Staged: branch
fix/2747-the-subprocess-environment-guard-accepts-the, draft pull request #2870. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
docs(openspec): plan #2747 refuse pytest and npm env keys in guard (#…
6 remaining items
fix(roadmap): show the cause of a model call stop in the Job comment (#…
docs(openspec): fix plan #2747 refuse two probed keys (#3079)
dan-petty commentedon Nov 1, 2026
implement: retry
devops-cli-service commentedon Nov 1, 2026
Cleared the stop at group 1 by the rule
retry: a person commentedimplement: retry. The item is Planned again, and the Service takes it in the next round.chore(ci): keep the per-test times and skip reasons of CI (#5006)
fix(roadmap): the strength check sets a denied env key (#5892)