Skip to content

fix(security): refuse the library keys that load a module - #2682

Merged
dan-petty merged 3 commits into
mainfrom
fix/2503-refuse-library-code-env-keys
Oct 29, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/2503-refuse-library-code-env-keys

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

build_subprocess_env refuses the keys that make a library or Python load a module of the caller. It refuses each OPENSSL key and each KRB5 key. It also refuses GSS_MECH_CONFIG, SASL_PATH, PYTHONEXECUTABLE and __PYVENV_LAUNCHER__. Each raises the same SecurityError as the other refused keys, with isolation on and off.

Why: a library key has an effect in each program that links the library. OPENSSL_CONF names a configuration file that can name a provider or an engine, which is a shared library. The four OpenSSL keys OPENSSL_CONF, OPENSSL_CONF_INCLUDE, OPENSSL_MODULES and OPENSSL_ENGINES are security-sensitive in openssl-env(7).

Evidence, from probes with the real programs in a temporary directory:

  • OPENSSL_CONF made node, curl, ssh, openssl and Python load a provider module. git ls-remote ssh:// ran it in its ssh child. git over HTTPS did not, because git of the devcontainer links GnuTLS.
  • OPENSSL_MODULES and OPENSSL_CONF_INCLUDE made openssl load a module when a configuration named a provider or a relative include. OPENSSL_ENGINES did so for openssl engine.
  • GSS_MECH_CONFIG made curl --negotiate and git-remote-http load a library when the server asked for Negotiate.
  • KRB5_CONFIG and SASL_PATH made libkrb5 and libsasl2 load a module in a probe of the library. No child here reached that call without a credential or an LDAP server.
  • PYTHONEXECUTABLE and __PYVENV_LAUNCHER__ made Python run the .pth line of a virtual environment that the key names.

Decisions:

Change: openspec/changes/archive/2026-10-29-2503-refuse-library-code-env-keys/

Closes #2503

…ad a module

Plan the change as openspec/changes/2503-refuse-library-code-env-keys and add the
failing tests for #2503. A caller override of an OpenSSL or Kerberos key, of
GSS_MECH_CONFIG, SASL_PATH, PYTHONEXECUTABLE or __PYVENV_LAUNCHER__ must raise
SecurityError. The keys that load no module must reach the child.
… load a module

build_subprocess_env refuses each OPENSSL and KRB5 key of a caller, and the keys
GSS_MECH_CONFIG, SASL_PATH, PYTHONEXECUTABLE and __PYVENV_LAUNCHER__.

Evidence of the probes, with the real programs:
- OPENSSL_CONF made node, curl, ssh, openssl and Python load a provider module.
  OPENSSL_MODULES and OPENSSL_CONF_INCLUDE did so when a configuration named a
  provider or a relative include. OPENSSL_ENGINES did so for openssl engine.
- GSS_MECH_CONFIG made curl --negotiate and git-remote-http load a library when
  the server asked for Negotiate.
- KRB5_CONFIG and SASL_PATH made libkrb5 and libsasl2 load a module in a probe
  of the library. No child here reached that call without a credential or an
  LDAP server.
- PYTHONEXECUTABLE and __PYVENV_LAUNCHER__ made Python run the .pth line of a
  virtual environment that the key names.

The design names the keys that stay accepted, for example SSL_CERT_FILE, and the
reason. ARCHITECTURE.md and the purpose of the subprocess-environment spec name
the library keys.

Closes #2503
Archive 2503-refuse-library-code-env-keys. The subprocess-environment spec now holds its requirements.
@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 29, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results, run on this branch after the rebase onto main:

  • uv run devops ci test tests/test_subprocess_env_boundary.py tests/test_review_rules_pack.py: 539 passed.
  • Before the rebase, tests/test_architectural_invariants.py, tests/invariants, tests/test_install_tools.py, tests/test_golangci_lint_scanner.py, tests/test_k8s_argocd_overrides.py and tests/test_tool_executor_contract.py passed: 256 tests.
  • ruff check, ruff format --check and mypy pass on src/devops_cli/config/constants.py and tests/test_subprocess_env_boundary.py.
  • uv run devops openspec check and uv run devops docs check pass.

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main):

77 failed on base (77 failed and 455 passed in tests/test_subprocess_env_boundary.py; 0 errored).

Each of the 77 failures is "DID NOT RAISE SecurityError": 19 keys, in upper and lower case, with isolation on and off, and the run_subprocess test.

Two independent reviews found no defect in the guard. Their findings on sentence length, the spec text, the comments of the constant and the commit text are fixed.

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 16:14
@dan-petty
dan-petty merged commit e681884 into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2503-refuse-library-code-env-keys branch October 29, 2026 16:15
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.17.0](v0.16.7...v0.17.0)
(2026-10-29)


### Features

* **repos:** worktrees add takes over a staged branch
([#2675](#2675))
([03eadec](03eadec)),
closes [#2657](#2657)
* **roadmap:** check open items for open alternative tools
([#2681](#2681))
([4f993dc](4f993dc)),
closes [#2650](#2650)


### Bug Fixes

* **security:** refuse the library keys that load a module
([#2682](#2682))
([e681884](e681884)),
closes [#2503](#2503)

---
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 library keys that make a child load a module, for example OPENSSL_CONF

1 participant