Skip to content

fix(security): refuse the keys that make a child write a file - #2746

Merged
dan-petty merged 3 commits into
mainfrom
fix/2674-refuse-file-write-env-keys
Oct 30, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/2674-refuse-file-write-env-keys

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

build_subprocess_env now refuses a caller override of the keys that make a child write a file that the caller names: SSLKEYLOGFILE, QLOGDIR, NODE_V8_COVERAGE, NODE_REDIRECT_WARNINGS and each LD_ key. Each raises the usual SecurityError, with isolation on and off. An isolated child gets none of them from the environment.

Why: probes with curl 8.23.0, git 2.55.0, Python 3.14.10, Node.js v24.22.2 and glibc 2.43 (temporary HOME, loopback only, a scratch directory) made each child write a file. SSLKEYLOGFILE made curl, git over HTTPS and the Python ssl module write the TLS secrets of the connection, and a person who reads the file can decrypt the recorded traffic. QLOGDIR made curl write a QUIC log. NODE_V8_COVERAGE made Node.js write a coverage file, and NODE_REDIRECT_WARNINGS made it write its warning to the named file. LD_DEBUG_OUTPUT and LD_PROFILE_OUTPUT made the glibc loader write debug text and a profile, with LD_DEBUG and LD_PROFILE.

The guard refuses the whole LD_ family with the pattern LD_*, as the sudo env_delete list does and as the guard does for GIT_ and SSH_. It replaces the four exact LD_ names. No code of the repository sets an LD_ key.

PYTHONDUMPREFSFILE and GPGRT_TRACE_FILE stay accepted. No probe made a child write a file with them. The four new names sit in a block of their own in CONST_CODE_LOADING_ENV_PATTERNS. The Purpose of the subprocess-environment spec names the new kind of key.

Change: openspec/changes/archive/2026-10-30-2674-refuse-file-write-env-keys/

Closes #2674

Plan the change for #2674 and add the tests that fail on main: a caller
override of SSLKEYLOGFILE, QLOGDIR, NODE_V8_COVERAGE,
NODE_REDIRECT_WARNINGS or an LD_ key is not refused yet.
build_subprocess_env now refuses a caller override of SSLKEYLOGFILE,
QLOGDIR, NODE_V8_COVERAGE, NODE_REDIRECT_WARNINGS and each LD_ key. Each
raises the usual SecurityError, with isolation on and off.

Why: probes with curl 8.23.0, git 2.55.0, Python 3.14, Node.js 24 and
glibc 2.43 (temporary HOME, loopback only) made each child write a file
that the caller names. SSLKEYLOGFILE wrote the TLS secrets of the
connection. PYTHONDUMPREFSFILE and GPGRT_TRACE_FILE wrote no file in a
probe, so they stay accepted.

Plans #2674
@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 (tests/test_subprocess_env_file_write.py, tests/test_subprocess_env_boundary.py, tests/test_subprocess_env_gh_kubectl.py): 610 passed. devops docs check is clean.

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

41 failed on base (41 failed and 4 passed in tests/test_subprocess_env_file_write.py; 0 errored).
failed on base: 40 cases of test_a_caller_override_that_makes_a_child_write_a_file_is_refused (10 keys x upper and lower case x isolated and not isolated: DID NOT RAISE SecurityError)
failed on base: test_run_subprocess_starts_no_child_for_a_refused_file_write_key (DID NOT RAISE SecurityError)

The 4 tests that pass on base pin the accepted behavior: an isolated child gets none of the keys from the environment, a child without isolation gets them, and similar keys such as SSL_CERT_FILE still reach the child (isolated and not isolated).

@dan-petty
dan-petty marked this pull request as ready for review October 30, 2026 01:50
@dan-petty
dan-petty merged commit 1cd187e into main Oct 30, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2674-refuse-file-write-env-keys branch October 30, 2026 01:50
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 keys that make a child write TLS secrets or a log to a file that the caller names

1 participant