Skip to content

fix(security): the guard refuses the ssh keys and SHELL - #2678

Merged
dan-petty merged 6 commits into
mainfrom
fix/2633-refuse-ssh-code-env-keys
Oct 29, 2026
Merged

dan-petty merged 6 commits into
mainfrom
fix/2633-refuse-ssh-code-env-keys

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The environment guard refuses each SSH_ key and SHELL as a caller override of a child environment.

Why: build_subprocess_env accepted keys that make an ssh child run a program that its caller chose. SSH_ASKPASS made ssh, ssh-add, ssh-keygen and git start the program of the caller. SSH_SK_PROVIDER, SSH_SK_HELPER and SSH_PKCS11_HELPER load a library or start a helper. SHELL names the program that ssh starts for a ProxyCommand.

What changes:

  • CONST_CODE_LOADING_ENV_PATTERNS holds SSH_* and SHELL, in a block of their own. Two helper keys are in no manual page, so the guard refuses each SSH_ key until a person reviews it.
  • DEFAULT_ALLOWED_ENV_VARS no longer holds SHELL. Thus no refused key reaches an isolated child from the environment.
  • SSH_AUTH_SOCK is refused, because a caller socket gets the private key from ssh-add. No caller sets an SSH_ key, so the guard keeps no exception.
  • DISPLAY, HOME, XAUTHORITY, TMPDIR and LANG stay accepted. The design records each accepted key with its reason.
  • ARCHITECTURE.md and the subprocess-environment spec describe the refusal.

Follow-up issues: #2503 (library keys), #2672 (keys of gh and kubectl) and #2674 (keys that write a file, and the open LD_ keys).

Change: openspec/changes/archive/2026-10-29-2633-refuse-ssh-code-env-keys/

Closes #2633

Plan the change for #2633 as an OpenSpec change. Add the failing tests.

- A caller override of an `SSH_` key or of `SHELL` must raise `SecurityError`.
- An isolated child must get none of these keys from the environment.
- `DISPLAY`, `HOME`, `TMPDIR` and similar keys must still reach the child.
The guard refused no key of OpenSSH. A caller override of `SSH_ASKPASS` made
`ssh`, `ssh-add`, `ssh-keygen` and git run a program of the caller. The keys
`SSH_SK_PROVIDER`, `SSH_SK_HELPER` and `SSH_PKCS11_HELPER` did the same with a
library or a helper. `SHELL` names the program that `ssh` starts to run a
`ProxyCommand`.

- Add the pattern `SSH_*` and the key `SHELL` to `CONST_CODE_LOADING_ENV_PATTERNS`,
  in a block of their own. Two helper keys are in no manual page, so the
  guard refuses each `SSH_` key until a person reviews it.
- Remove `SHELL` from `DEFAULT_ALLOWED_ENV_VARS`. No refused key then reaches
  an isolated child from the environment.
`ARCHITECTURE.md` gets a bullet for the ssh child environment. The purpose
of the `subprocess-environment` spec names ssh with the other programs.
The docstring had one sentence of 42 words. The limit is 25.
- Keep each sentence and each paragraph of the ssh text inside the STE limits.
- Record that an isolated child has no `SHELL`. `claude install` exits 0 without it.
- State the open `HOME` case: git reads `$HOME/.gitconfig` (#2483).
- Name #2674 for the keys that write a file, and the open `LD_` keys.
…t guard

Archive 2633-refuse-ssh-code-env-keys and merge its requirements into the
`subprocess-environment` spec.
@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

dan-petty commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner Author

Test results for the head of this branch.

  • Targeted tests passed: 712 tests in tests/test_subprocess_env_boundary.py, tests/test_review_rules_pack.py, tests/test_process.py, tests/test_process_contract.py, tests/test_ssh.py, tests/test_agents_md_claims.py, tests/test_k8s_argocd_overrides.py and tests/test_devcontainer.py.
  • tests/test_sandbox_lifecycle.py and tests/test_host_sandbox.py passed: 212 tests.
  • ruff check, ruff format --check and mypy pass on the changed modules. devops openspec check and devops docs check pass.
  • Probes with real OpenSSH 10.6p1 and git 2.55.0 (temporary home, markers) confirmed each refused key. claude install in a temporary home with no SHELL exits 0.

Fail-to-pass, with devops ci fail-to-pass --base origin/main:

41 failed on base (41 failed and 410 passed in tests/test_subprocess_env_boundary.py; 0 errored).
test_a_caller_override_that_loads_code_into_the_child_is_refused[ssh_original_command-not-isolated] (Failed: D
test_a_caller_override_that_loads_code_into_the_child_is_refused[SSH_PKCS11_HELPER-isolated] (Failed: DID NOT 
test_a_caller_override_that_loads_code_into_the_child_is_refused[SSH_SK_HELPER-isolated] (Failed: DID NOT RAIS
test_a_caller_override_that_loads_code_into_the_child_is_refused[ssh_askpass-isolated] (Failed: DID NOT RAISE 
test_a_caller_override_that_loads_code_into_the_child_is_refused[SHELL-isolated] (Failed: DID NOT RAISE Securi
test_a_caller_override_that_loads_code_into_the_child_is_refused[ssh_sk_helper-isolated] (Failed: DID NOT RAIS
test_a_caller_override_that_loads_code_into_the_child_is_refused[SSH_SK_PROVIDER-not-isolated] (Failed: DID NO
test_a_caller_override_that_loads_code_into_the_child_is_refused[SSH_SK_HELPER-not-isolated] (Failed: DID NOT 
...

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 15:59
@dan-petty
dan-petty merged commit 7f85930 into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2633-refuse-ssh-code-env-keys branch October 29, 2026 16:01
dan-petty-release Bot added a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.16.7](v0.16.6...v0.16.7)
(2026-10-29)


### Bug Fixes

* **security:** the guard refuses the ssh keys and SHELL
([#2678](#2678))
([7f85930](7f85930)),
closes [#2633](#2633)

---
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 ssh keys that make an ssh child run a program

1 participant