Skip to content

fix(security): the subprocess environment guard accepts the library keys that make a child load a module, for example OPENSSL_CONF #2503

Description

@dan-petty

Problem Description

build_subprocess_env in src/devops_cli/core/process.py refuses a caller override that CONST_CODE_LOADING_ENV_PATTERNS matches: the loader keys of glibc and macOS, GCONV_PATH, the bash and zsh keys, and the interpreter keys of #2429. It accepts the keys that make a shared library in the child load a module from a place that the caller chooses:

  • OPENSSL_CONF: OpenSSL reads this configuration file when it starts in the child. The file can name a provider or an engine module, which is a shared library. Each program that uses OpenSSL reads the key, for example node, curl, the ssl module of Python and git over HTTPS. node(1) lists the key.
  • OPENSSL_CONF_INCLUDE, OPENSSL_MODULES and OPENSSL_ENGINES: the directory of the included configuration files, of the provider modules and of the dynamic engines. openssl-env(7) calls OPENSSL_CONF, OPENSSL_CONF_INCLUDE and OPENSSL_ENGINES security-sensitive.
  • Other libraries have keys of the same kind. For example, the env_delete table of sudo removes KRB5_CONFIG* when sudo has Kerberos support, and a Kerberos configuration file can name plug-in modules.

The design of #2429 records these keys as a non-goal, because #2429 asks only for the shell and interpreter keys. A library key has an effect in each program that links the library, not in one interpreter. Thus the fix must find the libraries that devops-cli children use and the keys of each library that load a module.

Reproduction Steps

  1. Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(sorted(b(env={"OPENSSL_CONF": "x", "OPENSSL_MODULES": "x", "OPENSSL_ENGINES": "x"})))'.
  2. In a temporary directory <dir>, compile p.so from a C file with a constructor that writes a marker to the standard output (gcc -shared -fPIC -o <dir>/p.so p.c).
  3. In <dir>, write o.cnf with openssl_conf = c, nodejs_conf = c, a section [c] with providers = p, a section [p] with x = px, and a section [px] with module = <dir>/p.so and activate = 1.
  4. Run env -i PATH=<node dir>:/usr/bin:/bin OPENSSL_CONF=<dir>/o.cnf node -e 0. Then run the same environment with curl --version and with python3 -c 'import ssl; ssl.create_default_context()'.

Expected vs Actual Behavior

Expected: build_subprocess_env raises SecurityError for a caller override that makes a library of the child load a module from a place that the caller chooses, or the design of the guard names each such key that it accepts and the reason.

Actual: step 1 returns the three keys with no SecurityError. Each command of step 4 prints the marker, so the child runs code from <dir> before the requested command.

Environment Diagnostics

Logs, Traces, or Terminal Output

$ env -i PATH=<node dir>:/usr/bin:/bin OPENSSL_CONF=<dir>/o.cnf node -e 0   # node v24.22.1, OpenSSL 3.5.9
OPENSSL-CONF-MODULE-RAN
$ env -i PATH=/usr/bin:/bin OPENSSL_CONF=<dir>/o.cnf curl --version        # OpenSSL 3.6.5
OPENSSL-CONF-MODULE-RAN
$ env -i PATH=/usr/bin:/bin OPENSSL_CONF=<dir>/o.cnf python3 -c 'import ssl; ssl.create_default_context()'
OPENSSL-CONF-MODULE-RAN

The adversary review of the change of #2429 found the OPENSSL_CONF case. With isolate_env=True, no allowed key or prefix of DEFAULT_ALLOWED_ENV_VARS or DEFAULT_ALLOWED_ENV_PREFIXES lets an ambient OpenSSL key reach an isolated child. Thus the defect is the caller override only.

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.

Source: #2429

Proposed design

Problem statement

The subprocess environment guard in build_subprocess_env accepts caller overrides for library-level code-loading keys such as OPENSSL_CONF. A caller can set these keys to make a shared library in the child process load a module from an attacker-chosen path. The child runs attacker code before the requested command. The guard currently refuses only loader, shell, and interpreter keys. It does not refuse the keys that make a linked library load a module.

Acceptance criteria

  • Criterion 1: build_subprocess_env raises SecurityError when a caller override sets OPENSSL_CONF.
    Verification: Run: uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"OPENSSL_CONF": "x"})' and confirm it raises SecurityError.
  • Criterion 2: build_subprocess_env raises SecurityError when a caller override sets OPENSSL_CONF_INCLUDE.
    Verification: Run: uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"OPENSSL_CONF_INCLUDE": "x"})' and confirm it raises SecurityError.
  • Criterion 3: build_subprocess_env raises SecurityError when a caller override sets OPENSSL_MODULES.
    Verification: Run: uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"OPENSSL_MODULES": "x"})' and confirm it raises SecurityError.
  • Criterion 4: build_subprocess_env raises SecurityError when a caller override sets OPENSSL_ENGINES.
    Verification: Run: uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"OPENSSL_ENGINES": "x"})' and confirm it raises SecurityError.
  • Criterion 5: build_subprocess_env raises SecurityError when a caller override sets KRB5_CONFIG.
    Verification: Run: uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"KRB5_CONFIG": "x"})' and confirm it raises SecurityError.
  • Criterion 6: The constant comment names the source manual page for each new key.
    Verification: Read the comment above the new entries in src/devops_cli/config/constants.py and confirm each key has its manual page named.
  • Criterion 7: No key in DEFAULT_ALLOWED_ENV_VARS or DEFAULT_ALLOWED_ENV_PREFIXES matches a new refused pattern.
    Verification: Run the existing test suite in tests/test_subprocess_env_boundary.py and confirm all tests pass.

Key questions

  • Which environment variable keys make a shared library in a child process load a module from a caller-chosen path?: OPENSSL_CONF, OPENSSL_CONF_INCLUDE, OPENSSL_MODULES, OPENSSL_ENGINES (OpenSSL), and KRB5_CONFIG (Kerberos). The body names these keys and cites openssl-env(7) and the sudo env_delete table as sources. [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2429-refuse-interpreter-code-env-keys/design.md]
  • Should the new keys be added as exact names or as fnmatch patterns in CONST_CODE_LOADING_ENV_PATTERNS?: Exact names. The design of fix(security): the subprocess environment guard refuses the zsh and interpreter keys that make a child run code #2429 chose exact names over family patterns to avoid refusing keys that load no code, such as PYTHONUNBUFFERED or NODE_ENV. The same rule applies here: OPENSSL_CONF is one key, not a family. (best practice) [sources: openspec/changes/archive/2026-10-28-2429-refuse-interpreter-code-env-keys/design.md, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md]
  • Should the fix cover only the OpenSSL keys or also other library keys such as KRB5_CONFIG?: Add the four OpenSSL keys and KRB5_CONFIG. The body names all five and cites their sources. The body says the fix must find the libraries devops-cli children use and the keys of each library that load a module. OpenSSL is linked by node, curl, Python ssl, and git over HTTPS. Kerberos is linked by sudo and other tools. Both are named in the body with their sources. (best practice) [sources: src/devops_cli/core/process.py, ARCHITECTURE.md]
    • Chosen: Add the four OpenSSL keys and KRB5_CONFIG. The body names all five keys and cites their sources. Both OpenSSL and Kerberos are libraries that devops-cli children link. Adding both closes the named code-loading paths.
    • Rejected: Add only the four OpenSSL keys. Rejected because the body explicitly names KRB5_CONFIG and the sudo env_delete table as evidence of the same kind of key. Leaving it out leaves a known code-loading path open.
    • Rejected: Add a broad pattern for all library keys. Rejected because the project's design uses exact names. A broad pattern would refuse keys that do not load code and would be hard to maintain.
  • Where in the code should the new keys be added?: In CONST_CODE_LOADING_ENV_PATTERNS in src/devops_cli/config/constants.py. The existing guard in build_subprocess_env already calls _is_env_var_denied with this constant for caller overrides. Adding the keys to the constant is sufficient; no change to process.py is needed. [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md, openspec/changes/archive/2026-10-28-2429-refuse-interpreter-code-env-keys/design.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/high
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/security. The guard accepts environment keys that let a caller load a shared library into a child process, which is a security gap.
    • Priority: P1-High. A caller can make any child that links OpenSSL run attacker-chosen code before the requested command.
    • Value: High. The fix closes a code-execution path in every subprocess that links a module-loading library.
    • Effort: Medium. The fix must enumerate the module-loading keys of each library devops-cli children link and add them to the guard.
    • Related: fix(security): the subprocess environment guard accepts the git keys that make a git child run a program #2483, which asks for a different change. Both target build_subprocess_env in process.py for unblocked code-loading keys, but each names a different set of variables and a different library or tool.
  3. added
    priority/p1-high
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d156ce7 (see proposed design in issue body).

  6. added a commit that references this issue on Oct 29, 2026
  7. removed
    status/ready
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highsource/agenttype/securityvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions