Skip to content

fix(agent-server): pass the VS Code connection token through a file - #6195

Draft
enyst wants to merge 3 commits into
mainfrom
claude/vscode-token-file-2026-10-24
Draft

enyst wants to merge 3 commits into
mainfrom
claude/vscode-token-file-2026-10-24

Conversation

@enyst

@enyst enyst commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

HUMAN:


AGENT:

I'm an AI agent helping Engel Nyst (@enyst) with project work.

Why

The agent-server launches openvscode-server with --connection-token <token>, and in keyed deployments that token is session_api_keys[0], the session API key. Both the sh launcher and its node .../server-main.js child keep it in argv, and /proc/<pid>/cmdline is world-readable (mode 444). In the Agent Canvas Docker image (agent-server 1.58.1, openvscode-server 1.109.5), host user nobody could read the full session key from either process. Agent Canvas already moved its own static-server off argv (OpenHands/OpenHands#16420, issue OpenHands/OpenHands#16383); this is the same leak on the SDK side.

Summary

  • Write the connection token to a 0600 file in a per-launch private 0700 directory (tempfile.mkdtemp) and launch openvscode-server with --connection-token-file instead of --connection-token. The path is shell-quoted, and the token is no longer interpolated into the shell command.
  • set_connection_token restarts write a fresh file; stop() and a failed start() remove it. get_vscode_url() is unchanged.
  • Unit tests for the command, file mode, content, restart rewrite and cleanup, plus a Linux test that inspects a real launched process's /proc/<pid>/cmdline.

Issue Number

Fixes #6194

How to Test

  • uv run pytest tests/agent_server/test_vscode_service.py tests/agent_server/test_vscode_router.py → 62 passed. On main 6 of the new or changed tests fail, including the /proc cmdline test, which shows --connection-token\x00<token>. tests/agent_server -k "vscode or init": 140 passed.
  • uv run pre-commit run --files openhands-agent-server/openhands/agent_server/vscode_service.py tests/agent_server/test_vscode_service.py → all hooks pass (ruff, pycodestyle, pyright, import rules).
  • Real binary: in an Agent Canvas image built on agent-server 1.58.1-python (openvscode-server 1.109.5, whose --help lists --connection-token-file), the patched VSCodeService was started as openhands with the container's session key. From the host, /proc/<pid>/cmdline of both the sh and node processes had --connection-token-file, no --connection-token and no key literal, and nobody found 0 lines with the key. The token file was 0600 (directory 0700, uid 10001), ?tkn=<key> answered 302 and a wrong token 403, and stop() removed the directory. Before the change, the same image's processes had --connection-token <key> readable by host user nobody. The image's own agent-server is a PyInstaller binary, so the shipped image needs an SDK release with this change.

Video/Screenshots

N/A (process argv change). Reproduction evidence is in #6194.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

--connection-token-file has been in openvscode-server since 1.62; the image pins 1.109.5. The token file lives under the system temp dir, in a 0700 directory owned by the server user; openvscode-server reads it once at startup.


Generated by Claude Code


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:90edfd3-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-90edfd3-python \
  ghcr.io/openhands/agent-server:90edfd3-python

All tags pushed for this build

ghcr.io/openhands/agent-server:90edfd3-golang-amd64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-golang-amd64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-golang-amd64
ghcr.io/openhands/agent-server:90edfd3-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:90edfd3-golang-arm64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-golang-arm64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-golang-arm64
ghcr.io/openhands/agent-server:90edfd3-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:90edfd3-java-amd64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-java-amd64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-java-amd64
ghcr.io/openhands/agent-server:90edfd3-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:90edfd3-java-arm64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-java-arm64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-java-arm64
ghcr.io/openhands/agent-server:90edfd3-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:90edfd3-python-amd64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-amd64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-amd64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-amd64
ghcr.io/openhands/agent-server:90edfd3-python-arm64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-arm64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-arm64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-arm64
ghcr.io/openhands/agent-server:90edfd3-python-minimal-amd64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-minimal-amd64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:90edfd3-python-minimal-arm64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-minimal-arm64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:90edfd3-python-slim-amd64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-slim-amd64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-slim-amd64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:90edfd3-python-slim-arm64
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-slim-arm64
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-slim-arm64
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:90edfd3-golang
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-golang
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-golang
ghcr.io/openhands/agent-server:90edfd3-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:90edfd3-java
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-java
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-java
ghcr.io/openhands/agent-server:90edfd3-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:90edfd3-python-minimal
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-minimal
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-minimal
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-minimal
ghcr.io/openhands/agent-server:90edfd3-python-slim
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python-slim
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python-slim
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime-slim
ghcr.io/openhands/agent-server:90edfd3-python
ghcr.io/openhands/agent-server:90edfd3cad3d6ae6bb501901ae60645ab2964b54-python
ghcr.io/openhands/agent-server:claude-vscode-token-file-2026-10-24-python
ghcr.io/openhands/agent-server:90edfd3-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 90edfd3-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 90edfd3-python-amd64) are also available if needed

openvscode-server was launched with `--connection-token <token>`, and the
token is the session API key in keyed deployments. Both the `sh` launcher
and the `node server-main.js` child kept it in their argv, which any local
user can read from /proc/<pid>/cmdline.

Write the token to a 0600 file in a private 0700 directory created per
launch and pass `--connection-token-file` instead (supported by the
bundled openvscode-server 1.109.5, available since 1.62). A restart via
set_connection_token writes a fresh file; stop() and a failed start remove
it. get_vscode_url() is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BLppvEs62hAsfpCEiRzncq
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor
  ✅ **PR Artifacts Cleaned Up**

  This PR no longer adds or changes files under `.pr/`.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
TOTAL543192119961% 
report-only-changed-files is enabled. No changed files were found in the coverage report :)

The code-server migration supersedes the old token-file launch. Retain regression coverage that the token is delivered through stdin and absent from process arguments.

Co-authored-by: openhands <openhands@all-hands.dev>
@datadog-official

datadog-official Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 90edfd3 | Docs | Give us feedback!

Co-authored-by: openhands <openhands@all-hands.dev>
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.

[Bug]: Agent-server passes the VS Code connection token (the session key) in openvscode-server's argv

1 participant