Skip to content

fix(ssh): send no Origin header on the /colab/ssh upgrade - #325

Open
Zhong-fan wants to merge 1 commit into
googlecolab:mainfrom
Zhong-fan:fix/ssh-suppress-origin
Open

Zhong-fan wants to merge 1 commit into
googlecolab:mainfrom
Zhong-fan:fix/ssh-suppress-origin

Conversation

@Zhong-fan

@Zhong-fan Zhong-fan commented Dec 4, 2026 •

Copy link
Copy Markdown

Summary

  • _connect_websocket now passes suppress_origin=True, so the /colab/ssh
    upgrade no longer carries Origin: https://<runtime-host>.
  • tests/test_ssh_wire_contract.py asserts that the header never reaches the
    loopback server.
  • docs/06_ssh_access.md: log entry for the behavior change.

Why (fixes #320)

Since 2026-12-02 the runtime rejects a /colab/ssh upgrade that carries an
Origin header with HTTP 403. websocket-client sends that header by default,
so colab ssh failed on every fresh runtime while colab exec still worked.
The runtime-proxy token is not the problem: the same token succeeds against
/api/kernels, and the 403 response echoes the sent Origin in
access-control-allow-origin, which points at a runtime-side origin check.
A CLI is not a browser, so it has no reason to send the header at all.

Changes

  • src/colab_cli/commands/ssh.py: one-line connect change plus a comment
    explaining why the header must not be sent.
  • tests/test_ssh_wire_contract.py: the shared wire-contract assertion now
    requires origin to be absent from the captured upgrade request.
  • docs/06_ssh_access.md: design-doc log entry.

Verification

Offline:

  • The new wire assertion fails on main with the captured
    Origin: http://127.0.0.1:<port> header and passes with the fix (14 passed).
    The one failure in that file,
    test_proxy_command_child_reads_the_parent_config, is a pre-existing
    Windows PermissionError that fails identically on main.
  • tests/test_ssh.py: the same 12 pre-existing Windows failures before and
    after this change; no new failures.
  • uv run ruff check . and uv run ruff format --check . pass.

Live (CPU runtime created and stopped during testing):

  • colab ssh -s <session> -- "echo hello-from-colab; uname -a" prints the
    remote output and exits 0.
  • Direct probe against the same runtime with the same token and pubkey header:
    with Origin → 403 {"message":"Forbidden"}; with suppress_origin=True →
    101 Switching Protocols.
  • colab stop, then colab sessions → no active sessions (no orphan).

Thanks to @krunal-shah for the diagnosis and workaround in #320.

Since 2026-12-02 the runtime rejects an upgrade that carries an Origin header with HTTP 403, so colab ssh failed on every fresh runtime while colab exec still worked. websocket-client sends Origin by default; pass suppress_origin=True and assert in the wire-contract test that the header never reaches the server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

colab ssh: HTTP 403 Forbidden on every fresh runtime since 2026-12-02 (exec still works)

1 participant