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. #2483 refuses GIT_TRACE, GIT_TRACE2 and GIT_TRACE_CURL, because git appends to a file that the caller names. The guard accepts keys of the same kind in other tools and libraries:
SSLKEYLOGFILEmakescurl,gitover HTTPS and thesslmodule of Python write the TLS secrets of each connection to the file that the key names. A person who reads the file can decrypt the recorded traffic of the child. The pagecurl(1)lists the key.QLOGDIRmakescurlwrite QUIC logs to a directory (curl(1)).NODE_V8_COVERAGEandNODE_REDIRECT_WARNINGSmake Node.js write coverage data and warnings to a place of the caller (node(1)).PYTHONDUMPREFSFILE,LD_DEBUG_OUTPUT,LD_PROFILE_OUTPUTandGPGRT_TRACE_FILEname an output file of Python, of the glibc loader and of libgpg-error.
Only SSLKEYLOGFILE ran in a probe. The other keys come from the manual pages and the strings of the libraries.
The change for #2503 refuses the keys that load a module. It does not claim these keys, because they write a file and load no code.
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={"SSLKEYLOGFILE": "x", "QLOGDIR": "x"}) if k in ("SSLKEYLOGFILE", "QLOGDIR")))'. - In a temporary directory
<dir>, start an HTTPS server on 127.0.0.1 with a certificate that it made for the test. - Run
env -i PATH=/usr/bin:/bin HOME=<dir> SSLKEYLOGFILE=<dir>/keys.log curl -sk https://127.0.0.1:<port>/. Run the same environment withgit ls-remote https://127.0.0.1:<port>/x.gitand withpython3 -c 'import ssl, urllib.request; urllib.request.urlopen("https://127.0.0.1:<port>/", context=ssl.create_default_context())'. - Read
<dir>/keys.log.
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 both keys with no SecurityError. Step 4 shows the lines CLIENT_TRAFFIC_SECRET_0 and SERVER_TRAFFIC_SECRET_0 for curl and for git, and the handshake secrets for Python.
Environment Diagnostics
- DevOps CLI Version: main at 5bb1ed0
- Python Version: 3.14.9 (/usr/bin/python3) and 3.14.10 (uv)
- OS & Architecture: Linux x86_64 (WSL2)
- Execution Environment: DevContainer
Logs, Traces, or Terminal Output
$ env -i ... SSLKEYLOGFILE=<dir>/keys.log curl -sk https://127.0.0.1:<port>/ # curl 8.23.0
$ cut -d' ' -f1 <dir>/keys.log | sort -u
CLIENT_HANDSHAKE_TRAFFIC_SECRET
CLIENT_TRAFFIC_SECRET_0
EXPORTER_SECRET
SERVER_HANDSHAKE_TRAFFIC_SECRET
SERVER_TRAFFIC_SECRET_0Pre-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.
Proposed design
Problem statement
build_subprocess_env refuses caller overrides that match CONST_CODE_LOADING_ENV_PATTERNS, but it accepts keys that make a child write TLS secrets or logs to a file the caller names. A caller can set SSLKEYLOGFILE, QLOGDIR, LD_DEBUG_OUTPUT, or other keys and the child writes sensitive data to a path the caller controls. The guard needs a refusal list for file-writing keys, the same way #2483 added one for git trace keys.
Acceptance criteria
Requirement: Refuse SSLKEYLOGFILE override
build_subprocess_env SHALL raise SecurityError when a caller override sets SSLKEYLOGFILE.
Scenario: Caller sets SSLKEYLOGFILE
- WHEN A caller passes env={"SSLKEYLOGFILE": "/tmp/keys.log"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Refuse QLOGDIR override
build_subprocess_env SHALL raise SecurityError when a caller override sets QLOGDIR.
Scenario: Caller sets QLOGDIR
- WHEN A caller passes env={"QLOGDIR": "/tmp/qlog"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Refuse LD_ family overrides
build_subprocess_env SHALL raise SecurityError when a caller override sets any key matching the LD_ family pattern.
Scenario: Caller sets LD_DEBUG_OUTPUT
- WHEN A caller passes env={"LD_DEBUG_OUTPUT": "/tmp/dbg"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Refuse Node.js file-writing overrides
build_subprocess_env SHALL raise SecurityError when a caller override sets NODE_V8_COVERAGE or NODE_REDIRECT_WARNINGS.
Scenario: Caller sets NODE_V8_COVERAGE
- WHEN A caller passes env={"NODE_V8_COVERAGE": "/tmp/cov"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Refuse PYTHONDUMPREFSFILE override
build_subprocess_env SHALL raise SecurityError when a caller override sets PYTHONDUMPREFSFILE.
Scenario: Caller sets PYTHONDUMPREFSFILE
- WHEN A caller passes env={"PYTHONDUMPREFSFILE": "/tmp/refs"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Refuse GPGRT_TRACE_FILE override
build_subprocess_env SHALL raise SecurityError when a caller override sets GPGRT_TRACE_FILE.
Scenario: Caller sets GPGRT_TRACE_FILE
- WHEN A caller passes env={"GPGRT_TRACE_FILE": "/tmp/gpg"} to build_subprocess_env
- THEN SecurityError is raised with the key name in the message
Requirement: Case-insensitive refusal
The refusal of file-writing keys SHALL be case-insensitive.
Scenario: Caller sets lowercase sslkeylogfile
- WHEN A caller passes env={"sslkeylogfile": "/tmp/keys.log"} to build_subprocess_env
- THEN SecurityError is raised
Requirement: Safe keys still accepted
build_subprocess_env SHALL accept caller overrides of keys that do not match any refused pattern.
Scenario: Caller sets a safe key
- WHEN A caller passes env={"MY_SAFE_VAR": "value"} to build_subprocess_env
- THEN MY_SAFE_VAR is present in the returned environment with the value "value"
Existing Tool Considered
No open, maintained Python library provides a curated list of dangerous environment variable keys for selective subprocess isolation. The env command and sudo env_delete are all-or-nothing or privilege-escalation scoped. The project builds its own guard. Written cost: about 400 tokens to add the constant, extend the check, and write tests; about 50 tokens per new key added later; about 50 tokens per false-positive fix.
Key questions
- Which environment variable keys make a child write a file that the caller names?: SSLKEYLOGFILE (curl, git, Python ssl), QLOGDIR (curl), NODE_V8_COVERAGE and NODE_REDIRECT_WARNINGS (Node.js), PYTHONDUMPREFSFILE (Python), LD_DEBUG, LD_PROFILE, LD_DEBUG_OUTPUT, LD_PROFILE_OUTPUT (glibc), GPGRT_TRACE_FILE (libgpg-error). [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-29-2483-refuse-git-code-env-keys/design.md]
- Should the guard refuse the whole LD_ family or only the specific keys named in the issue?: Refuse the whole LD_ family with the pattern LD_. No safe LD_ key appears in DEFAULT_ALLOWED_ENV_VARS, and the existing DYLD_ pattern in CONST_CODE_LOADING_ENV_PATTERNS shows the project already uses family patterns for loader keys. (best practice) [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md]
- Chosen: LD_ family pattern. Covers all current and future LD_ keys. Consistent with DYLD_* already in the code. No safe LD_ key is in the allowed list.
- Rejected: Specific LD_ keys only. Requires updating the list for each new LD_ key. Misses future keys. The existing specific LD_ keys in CONST_CODE_LOADING_ENV_PATTERNS show this approach was used before, but the family pattern is broader and safer.
- Should the file-writing patterns be a new constant or added to CONST_CODE_LOADING_ENV_PATTERNS?: A new constant, because the security concern is different: file writing to a caller-named path versus loading code. Keeping them separate makes the intent of each list clear and lets a future change adjust one without affecting the other. (best practice) [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md]
- Chosen: New constant CONST_FILE_WRITING_ENV_PATTERNS. Clear semantic separation. The check function tests both lists. A reader sees two distinct security concerns.
- Rejected: Extend CONST_CODE_LOADING_ENV_PATTERNS. Conflates file writing with code loading. The name of the constant would no longer describe its contents. A future reader might miss the file-writing keys when looking for code-loading keys.
- Is the existing override check case-insensitive?: Yes. _is_env_override_refused uppercases the key before matching, and _is_env_var_denied uppercases the key before fnmatch. The new check inherits this behavior. [sources: src/devops_cli/core/process.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The guard accepts environment keys that let a caller exfiltrate TLS secrets or redirect logs to an arbitrary path.A caller can make a child write TLS secrets to a file it controls, enabling decryption of recorded traffic.Exfiltration of TLS handshake secrets breaks the confidentiality of recorded connections.The refusal-list pattern is established by #2483 and #2503, but multiple keys across curl, Node, Python, glibc, and libgpg-error need identification and verification.Both harden build_subprocess_env in the same file, but #2503 refuses keys that load a module while the candidate refuses keys that write output to a caller-named file.dan-petty commentedon Oct 29, 2026
Probe for the glibc loader keys that this issue names. It came from the review of #2633. Each probe ran in a temporary directory with
env -i PATH=/usr/bin:/bin HOME=<dir>andssh -V(OpenSSH 10.6p1).LD_DEBUG=fileswithLD_DEBUG_OUTPUT=<dir>/dbgwrote the file<dir>/dbg.<pid>. It holds loader debug text. The pid is part of the file name.LD_PROFILE=libc.so.6withLD_PROFILE_OUTPUT=<dir>wrote the file<dir>/libc.so.6.profile.build_subprocess_envaccepts all four keys. It refuses onlyLD_AUDIT,LD_LIBRARY_PATH,LD_ORIGIN_PATHandLD_PRELOAD.The trigger keys
LD_DEBUGandLD_PROFILEare accepted too. The defaultenv_deletetable of sudo listsLD_*. The fix can refuse the wholeLD_family, as #2483 did forGIT_.fix(security): the guard refuses the ssh keys and SHELL (#2678)
fix(security): refuse the library keys that load a module (#2682)
devops-cli-service commentedon Oct 29, 2026
Status set to Ready at c462318 (see proposed design in issue body).
chore(main): release 0.21.4 (#2741)
fix(security): refuse PYTEST_ADDOPTS and npm_config_logs_dir overrides (