Skip to content

fix(security): a sandbox workspace never holds the user's ssh agent or X11 socket #1384

Closed

Description

@dan-petty

Problem

#1115 refuses a sandbox workspace that holds the container engine socket (including the directory a symlinked socket resolves to) or the user's runtime directory (XDG_RUNTIME_DIR, with its session bus). Other user sockets that give a container the user's authority are not covered (review of #1115, 2026-10-08):

  • the SSH agent socket, /tmp/ssh-*/agent.N (SSH_AUTH_SOCK);
  • VS Code's SSH-auth socket, /tmp/vscode-ssh-auth-*.sock;
  • the X11 socket directory, /tmp/.X11-unix.

/tmp itself is refused only when XDG_RUNTIME_DIR lies under it. A workspace of /tmp/ssh-XXXX is accepted today, which hands the sandbox the user's SSH agent. A socket file given as the workspace is not exploitable, because both runners set working_dir=/workspace and the container fails to start.

Acceptance criteria

Strategic alignment


Found on 2026-10-08 while delivering #1115. Filed directly with no priority; the roadmap service's intake sets Priority, Value and Effort.

Activity

  1. added
    type/security
    scope/security
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P1-High. A sandbox container holding the user's SSH agent socket can authenticate as the user to any remote host, making this a high-severity security gap in an existing protection mechanism.
    • Value: High. Preventing a container from silently inheriting the user's full SSH identity and X11 session is critical to the sandbox's trust model.
    • Effort: Medium. The pattern already exists in #1115 for the engine socket and XDG_RUNTIME_DIR; extending it to SSH_AUTH_SOCK and /tmp/.X11-unix across four entry points plus tests is bounded but non-trivial.
  3. added this to the v0.2.30 milestone on Oct 8, 2026
  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.30 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: P1 secret and sandbox-boundary fixes, the review tools lock, kube-linter finding identity and a faster gate. Position 4 of 10 in the release's planned merge order. Its board Status is set to Ready, so the release-start fill keeps it.

  5. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #1117, which maps rootless sandboxes to the host user; after that only this item's refusal keeps the SSH agent's directory out, so #1117 lands after this item. Found by the 2026-10-08 backlog review.

  6. dan-petty-bot commented on Oct 9, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1463, merged into release/v0.2.30 as 97c0f6b.

    Summary

    • validate_sandbox_workspace (src/devops_cli/sandbox/engine.py) now also refuses a workspace that is, or holds, /tmp/.X11-unix or the directory of the socket SSH_AUTH_SOCK names. It also refuses the directory a symlinked agent socket leads to. This covers VS Code's /tmp/vscode-ssh-auth-*.sock when VS Code sets SSH_AUTH_SOCK. The refusal names the workspace and the protected directory.
    • Each directory is checked both as named and resolved, so /tmp is always refused, including where /tmp/.X11-unix is itself a symlink.
    • The rule is one-way: a workspace under the agent's directory is still mounted. An unset, empty or relative SSH_AUTH_SOCK adds no rule, the same way fix(security): a sandbox workspace can never expose the container engine socket or the user's runtime directory and its session bus #1115 treats XDG_RUNTIME_DIR. The check reads one environment variable, resolves paths and makes no requests.
    • No entry point changes. devops docker sandbox, devops test sandbox, devops sandbox deploy and the MCP tools docker_sandbox and sandbox_deploy already run the shared check.
    • New constants CONST_SSH_AUTH_SOCK_ENV_VAR and CONST_X11_SOCKET_DIR (with # nosec B108). A new autouse fixture, isolate_ssh_agent, keeps tests off the developer's own agent.
    • In the tests, each _REFUSED_WORKSPACES case now carries the environment it runs under. Six new refused cases are added, one new MCP case, and a new test covering four SSH_AUTH_SOCK settings under which the workspace is still mounted.
    • Adds changelog.d/1384.md under ### Security and the task file `docs/agent…

    6 file(s) changed.

    How it was verified

    Check runs at 85aff68:

    • Prune PR DevContainer Images: pending
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • Analyze (actions): pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1384-sandbox-workspace-never-holds-ssh-agent-or-x11-socket.md:

    • Refused paths. test_a_workspace_overlapping_a_socket_directory_is_refused_before_any_engine_call (tests/test_sandbox_lifecycle.py), parametrised over both runners, refuses each new case before any engine call, and the client mock records no call: the SSH_AUTH_SOCK directory, the directory that holds it, the directory a symlinked agent socket leads to, a tmp_path holding a VS Code-style vscode-ssh-auth-*.sock, /tmp/.X11-unix, and /tmp.
    • The refusal names the workspace and the protected directory in every new case.
    • Accepted paths. test_a_workspace_beside_the_ssh_agent_directory_is_mounted mounts a workspace under the agent's directory with both runners, and mounts it with SSH_AUTH_SOCK unset, empty and relative (agent.1, with the workspace as the working directory).
    • MCP. With workspace set to the SSH agent's directory, docker_sandbox and sandbox_deploy raise SandboxValidationError and _run_mcp_cmd is not called.
    • Request-free and shared. The rule lives in validate_sandbox_workspace, which every entry point already runs; it reads SSH_AUTH_SOCK and resolves paths only.
    • Release. changelog.d/1384.md lists the newly refused workspaces. The tests are offline, start no container, and each call phase stays under 1 s.
    • Pending a person: in a VS Code devcontainer terminal where SSH_AUTH_SOCK is set, on a build with this fix, run devops docker sandbox --workspace "$(dirname "$SSH_AUTH_SOCK")" -- true and devops docker sandbox --workspace /tmp -- true. Confirm that both are refused before any container is created, and record the results on the issue.
  7. added a commit that references this issue on Oct 9, 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

    scope/securitysource/agenttype/security

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions