Skip to content

fix(security): the subprocess environment guard accepts the ssh keys that make an ssh child run a program #2633

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 (#2205, #2433, #2429; the git keys follow in #2483). It accepts the ssh keys that make an ssh child run a program that its caller did not choose:

  • SSH_ASKPASS names a program that ssh, ssh-add and ssh-keygen start to ask for a passphrase.
  • SSH_ASKPASS_REQUIRE=force makes ssh start that program also when a terminal is present.

A git child that opens an SSH connection starts ssh, so a caller override of these keys reaches it too. The same class holds the keys that name a program for gh and kubectl, for example GH_EDITOR, GH_BROWSER, KUBE_EDITOR and KUBECTL_EXTERNAL_DIFF. This issue does not claim them: no probe of them ran.

Reproduction Steps

  1. Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(sorted(k for k in b(env={"SSH_ASKPASS": "x", "SSH_ASKPASS_REQUIRE": "force"}) if k.startswith("SSH_")))'.
  2. In a temporary directory <dir>, run ssh-keygen -q -t ed25519 -N pw -f <dir>/k, and write an executable <dir>/askpass that runs echo SSH-ASKPASS-RAN >&2; echo pw.
  3. Run env -i PATH=/usr/bin:/bin HOME=<dir> SSH_ASKPASS=<dir>/askpass SSH_ASKPASS_REQUIRE=force ssh-agent sh -c 'ssh-add <dir>/k </dev/null'.

Expected vs Actual Behavior

Expected: build_subprocess_env raises SecurityError for a caller override of an ssh key that makes ssh run a program, 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 3 prints SSH-ASKPASS-RAN, so ssh-add runs the program of the override.

Environment Diagnostics

  • DevOps CLI Version: main at a3eb41f
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64 (WSL2)
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

$ env -i PATH=/usr/bin:/bin HOME=<dir> SSH_ASKPASS=<dir>/askpass SSH_ASKPASS_REQUIRE=force ssh-agent sh -c 'ssh-add <dir>/k </dev/null'   # OpenSSH 10.6p1
SSH-ASKPASS-RAN
Identity added: <dir>/k

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: #2483

Proposed design

Problem statement

The guard in build_subprocess_env accepts caller overrides of SSH_ASKPASS and SSH_ASKPASS_REQUIRE. These keys make an ssh child run a program that the caller chose. A git child that opens an SSH connection starts ssh, so the override reaches it. The guard must refuse these two keys.

Acceptance criteria

Requirement: Refuse SSH_ASKPASS override

build_subprocess_env SHALL raise SecurityError when a caller override sets SSH_ASKPASS.

Scenario: Caller sets SSH_ASKPASS

  • WHEN A caller passes env={'SSH_ASKPASS': '/path/to/program'} to build_subprocess_env
  • THEN build_subprocess_env raises SecurityError

Requirement: Refuse SSH_ASKPASS_REQUIRE override

build_subprocess_env SHALL raise SecurityError when a caller override sets SSH_ASKPASS_REQUIRE.

Scenario: Caller sets SSH_ASKPASS_REQUIRE

  • WHEN A caller passes env={'SSH_ASKPASS_REQUIRE': 'force'} to build_subprocess_env
  • THEN build_subprocess_env raises SecurityError

Existing Tool Considered

The project builds its own guard. No open library covers this need. The mechanism is CONST_CODE_LOADING_ENV_PATTERNS in src/devops_cli/config/constants.py, matched by _is_env_override_refused in src/devops_cli/core/process.py. The cost is two entries in a tuple and one test.

Key questions

  • Where to add the refused keys?: Add SSH_ASKPASS and SSH_ASKPASS_REQUIRE to CONST_CODE_LOADING_ENV_PATTERNS in src/devops_cli/config/constants.py. (best practice) [sources: src/devops_cli/core/process.py, openspec/changes/archive/2026-10-28-2205-refuse-code-loading-env-keys/design.md]
    • Chosen: Add to CONST_CODE_LOADING_ENV_PATTERNS. The existing mechanism for refusing code-loading keys. The guard already matches this constant via _is_env_override_refused.
    • Rejected: Add to DEFAULT_DENIED_ENV_PATTERNS. That tuple holds credential patterns. SSH_ASKPASS is a program path, not a credential.
    • Rejected: Create a new constant. The existing constant and guard handle this. A new constant adds no value.
  • Does the ambient filter already strip SSH_ASKPASS from the environment?: Yes. SSH_ASKPASS is not in DEFAULT_ALLOWED_ENV_VARS and does not match any entry in DEFAULT_ALLOWED_ENV_PREFIXES, so the ambient filter already removes it. [sources: src/devops_cli/core/process.py]

Open questions

  • Which SSH keys make an ssh child run a caller-chosen program? (missing verified source)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/high
    effort/low
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 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 candidate reports that the guard accepts keys that let an ssh child run a caller-chosen program, which is a security defect.
    • Priority: P1-High. A caller can make an ssh child execute an arbitrary program via SSH_ASKPASS, which is a code-execution path.
    • Value: High. Closing this gap removes a path where a subprocess can run a program the caller did not choose.
    • Effort: Low. The fix adds two known key names to the existing guard pattern or blocklist in one function.
    • Related: fix(security): the subprocess environment guard accepts the library keys that make a child load a module, for example OPENSSL_CONF #2503, which asks for a different change. Both fix the same guard in build_subprocess_env for keys that let a child run code, but this candidate targets SSH_ASKPASS keys while #2503 targets library-loading keys like OPENSSL_CONF.
  3. added
    priority/p1-high
    on Oct 29, 2026
  4. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 8036e7e until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Which SSH keys make an ssh child run a caller-chosen program? (missing verified source)
  5. removed
    status/new
    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/lowpriority/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