Skip to content

fix(ssh): keep session tokens out of OpenSSH process arguments - #5944

Open
alangou wants to merge 13 commits into
mainfrom
fix/ssh-session-handoff/alangou
Open

alangou wants to merge 13 commits into
mainfrom
fix/ssh-session-handoff/alangou

Conversation

@alangou

@alangou alangou commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Why

Keep SSH session credentials out of the process arguments used for sandbox connections, file transfers and port forwards.

What changed

A gateway can advertise direct SSH on an authenticated GetSandbox response. The proxy opens ForwardTcp with its gateway credential and the immutable sandbox ID from that lookup. The gateway checks workspace access, the ID and the SSH connection limit at admission, and records the sandbox and channel in the audit log. This path creates no SSH session record.

Clients use the original session-token flow when the gateway does not advertise direct SSH. This includes older gateways, local-development identities and deployments whose interceptors observe or control SSH session creation or revocation. Older clients can still use their existing token flow. A released v0.1.9 CLI was also tested against the new gateway. A command that has selected direct SSH keeps that mode across reconnects. A definitive refusal stops automatic retries, including when it arrives in the gRPC trailers.

For launches initiated by the CLI or TUI, OpenSSH receives a one-use local handle. The proxy obtains its connection context over a same-account Unix socket or Windows named pipe. On legacy connections this channel also carries the session grant. The issuer attempts revocation after relay admission, failure or cancellation. Saved SSH configurations resolve their named profiles on invocation. File transfers retain the selected identity across retries and across uploads in one create request.

Scope

For regular CLI commands, a direct gateway endpoint selects the destination. When the profile and endpoint come from different sources (command line and environment), the CLI uses credentials registered for the endpoint. For a tunnel, pass both --gateway and --gateway-endpoint explicitly to pair the profile with the tunnel address. A saved SSH profile continues to select its own gateway when the editor inherits another endpoint.

Generate saved SSH configuration from a named profile if the URL includes credentials, a path, a query, or a fragment. Regenerate custom proxy commands that passed the old hidden --token option. Direct Rust callers of the changed openshell-core and openshell-cli SSH helpers may also need to update their calls.

On Unix the proxy checks the account of the socket peer and the issuer PID. The Windows named pipe restricts access to the issuing account. Revocation is best effort if the issuer dies or the gateway is unavailable.

Verification

  • Exercised modern and mixed client/gateway versions with system OpenSSH, mTLS, an isolated gateway and a fixture supervisor on Linux. Checked the SQLite SSH-session writes, stale sandbox IDs, OIDC access, direct recovery and definitive refusals during transfers.
  • Checked protobuf compatibility and lint with Buf, generated TypeScript bindings, and ran the SDK type checks, tests and build.
  • Verified the ordinary CLI destination and credentials against two local gateways. Checked private HTTP(S) URLs with lowercase, uppercase, and mixed-case schemes. With two accounts registered on the same gateway, verified the selected identity for whoami, SSH session creation and relay admission. The test used distinct client certificates and real OpenSSH.
  • Ran CLI, core, TUI, forwarding and proxy tests. Verified all 13 Cargo workspaces resolve their checked-in dependencies with --locked.
  • Compared the base and patched binaries against the same local mTLS gateway with OpenSSH. Inspected the arguments of both OpenSSH and its proxy against the actual session values. The base exposed the values and the patched processes did not.
  • Exercised interactive attach, saved SSH configuration, binary upload/download and simultaneous foreground/background forwards. Stopping one forward left the other usable.
  • On Linux, a different account knowing the handle received zero bytes. The Unix backend also compiled for Apple Silicon, and the named-pipe backend compiled for both x64 and ARM64 Windows. Native macOS and Windows execution were not covered.

Continues #5826 from a branch in this repository with the same commits.

Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
…SSH URLs

Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
Signed-off-by: Adrien Langou <alangou@nvidia.com>
TcpForwardInit adds tag 8 to its public target oneof. The durable schema and public/durable overlap retain their existing fingerprints.

Signed-off-by: Adrien Langou <alangou@nvidia.com>
@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

@alangou alangou added the test:e2e Requires end-to-end coverage label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. cli — No explicit risk acceptance found

openshell ssh-proxy --gateway URL --sandbox S --token T --gateway-name G previously relayed a pre-created session, but now rejects --token.

  • Impact: Custom OpenSSH ProxyCommands and external launchers using token mode fail during argument parsing before forwarding any SSH bytes.
  • Action: Preserve token-mode compatibility for this branch; consumers able to self-mint can migrate to openshell ssh-proxy --server URL --gateway-name G --name S with registered credentials.
  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944

2. configuration — No explicit risk acceptance found

OPENSHELL_GATEWAY=prod openshell --gateway-endpoint URL sandbox list previously retained prod's credentials, but now discards that profile when its registered endpoint differs from URL.

  • Impact: Existing tunnel scripts combining an environment-selected profile with an endpoint flag lose their mTLS/OIDC credentials or select another endpoint-matched identity.
  • Action: Preserve mixed-source profile binding for this no-break branch; the documented workaround is openshell --gateway prod --gateway-endpoint URL sandbox list.
  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944

3. rust-sdk — No explicit risk acceptance found

openshell_sdk::raw::proto::tcp_forward_init::Target changes from the exhaustive Ssh/Tcp enum to one also containing DirectSshSandboxId(String).

  • Impact: Downstream exhaustive matches, including forwarding mock/server implementations, fail to compile with a missing match arm, although existing RPC signatures remain unchanged.
  • Action: Defer the new oneof variant to a break-allowing release and document adding a DirectSshSandboxId match arm.
  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944
Review details
  • Execution: complete
  • Candidate: PR #5944 (ac17a78e60271fca35831f770d1ae98aaed5a9dd)
  • Baseline: 9551cbada4babd38aa03f8948474cdc5bd206acc (9551cbada4babd38aa03f8948474cdc5bd206acc)
  • Reviewed: rust-sdk, python-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

TaylorMutch
TaylorMutch previously approved these changes Nov 24, 2026

@TaylorMutch TaylorMutch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly accepting the three compatibility changes identified in #5944 (comment) for this release: removal of hidden ssh-proxy --token mode requires custom ProxyCommands and launchers to migrate; mixed environment/flag gateway selection requires tunnel scripts to pass both --gateway and --gateway-endpoint explicitly to retain their chosen identity; downstream exhaustive Rust matches on tcp_forward_init::Target must add DirectSshSandboxId. These migration costs are accepted in exchange for keeping SSH session tokens out of process arguments. No additional security or correctness defect was established by the review. Both originally failing E2E lanes passed reruns on this unchanged commit: 77/77 Kubernetes tests and 77/77 rootless Podman tests. The aggregate E2E gate is now successful. The original failures remain intermittent with exact root causes unproven; the missing-provider-variable symptom also occurred without this SSH change. Two isolated native macOS IPC checks passed; full native Windows execution was not independently validated.

Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. cli — Risk explicitly accepted

openshell ssh-proxy --gateway URL --sandbox S --token T --gateway-name G previously relayed a pre-created session but now rejects --token.

  • Impact: Custom OpenSSH ProxyCommands and external launchers using token mode fail argument parsing before relaying any SSH bytes.

  • Action: This no-break branch still needs a compatible token-input path; consumers with gateway credentials can migrate to openshell ssh-proxy --server URL --gateway-name G --name S, but token-only launchers cannot.

  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944

  • Acceptance: comment

2. configuration — Risk explicitly accepted

OPENSHELL_GATEWAY=prod openshell --gateway-endpoint URL sandbox list previously retained prod's profile but now drops it when URL differs from its registered endpoint.

  • Impact: Existing tunnel scripts combining environment-selected profiles with endpoint flags lose their mTLS/OIDC credentials or use another endpoint-matched identity.

  • Action: This no-break branch still needs the old mixed-source binding; the documented consumer migration is openshell --gateway prod --gateway-endpoint URL sandbox list with both selectors explicit.

  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944

  • Acceptance: comment

3. rust-sdk — Risk explicitly accepted

openshell_sdk::raw::proto::tcp_forward_init::Target changes from an exhaustive Ssh/Tcp enum to one also containing DirectSshSandboxId(String).

  • Impact: Downstream exhaustive matches, including forwarding mock/server implementations, fail to compile, while ordinary client calls and generated server-trait signatures remain unchanged.

  • Action: Defer the exhaustive enum expansion to a break-allowing train and add SDK migration guidance showing the required DirectSshSandboxId match arm.

  • PR: fix(ssh): keep session tokens out of OpenSSH process arguments #5944

  • Acceptance: comment

Review details
  • Execution: complete
  • Candidate: PR #5944 (63ccf9cffb895f54821c16f07bd6d382abf6e820)
  • Baseline: 7f399d34a6e79a88879e4ba3824adca7af0a4c73 (7f399d34a6e79a88879e4ba3824adca7af0a4c73)
  • Reviewed: rust-sdk, python-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants