Skip to content

fix(sandbox): keep a harness's keys out of other processes' /proc reach #5549

Backlog

Description

@yannickmonney

Problem

Every exec of a sandbox runs at runnerd's uid. Any process of a uid may read the /proc/<pid>/environ, mem and fd/ entries of a dumpable process of the same uid. Only runnerd is non-dumpable (services/sandbox-runtime/daemon/nondumpable/tale-nondumpable.c), and its token arrives on a descriptor (runnerd-token.ts).

The harness processes are different. OpenCode, Pi and Claude Code, and the MCP bridges they start, carry the turn's keys in their environment:

  • TALE_GATEWAY_TOKEN, ANTHROPIC_AUTH_TOKEN and TALE_CONNECTORS_TOKEN: the session's gateway key;
  • CLAUDE_CODE_OAUTH_TOKEN: a person's subscription token;
  • a person's own provider keys on the BYO lane.

So any other process of the uid can read them, for example a dependency's install script, a dev server left running by an earlier turn, or another task's commands in a shared standing workspace.

Reading v0.5.112 found three more facts that shape the fix:

  1. The connectors key is on argv for Claude Code. exec-builder.ts passes Claude's MCP config with --mcp-config '{"mcpServers":{"connectors":{"env":{"TALE_CONNECTORS_TOKEN":"<key>"}}}}' (delivery: config-json-flag). /proc/<pid>/cmdline is readable by every uid, dumpable or not, and so is ps on a raw host. Golden fixture: lib/harnesses/fixtures/exec/claude-code.yml.
  2. The flag cannot be cleared from outside. The kernel makes a process dumpable again at every execve, so runnerd's approach (the process clears the flag itself) does not carry over. The harness CLIs are third-party builds: Claude Code 2.1.285 and OpenCode 1.18.34 are native bun binaries, and Pi runs on node behind the Python wrapper tale-pi-run. Only code loaded into the harness itself, before its main, can clear the flag.
  3. Children inherit the keys. The harnesses hand their full environment to their Bash tool, hooks and MCP bridges. tale-vision reads TALE_GATEWAY_TOKEN there by design (claude-code/harness.yml: "Env, not MCP: the hook and the tools inherit it"). A command the agent runs therefore has the keys in its own environment. The shell between it and the harness also holds them in its own dumpable environment, so even a command started without them (the ops side's $U) can read them one process up.

Why

These keys spend the organization's model budget. A person's subscription token is theirs alone, and a BYO key is a person's own credential. A same-uid process is exactly what a malicious dependency or a prompt-injected command gets.

Design

There are two phases. This issue covers phase 1 and the overall design. Phase 2 is its own issue (T14b, #5550), because it changes the runtime's privilege model.

Phase 1 (this issue): the harness process itself

  • The harness guard is daemon/harness-guard/tale-harness-guard.c, a library runnerd preloads (LD_PRELOAD) into a harness exec.
    • It acts only in the program named by TALE_HARNESS_KEYS_EXE, the executable basename (/proc/self/exe). Every wrapper before it passes the variables through untouched (tale-pi-run, an env node shebang).
    • In that program it clears the dumpable flag, reads the keys from the descriptor named by TALE_HARNESS_KEYS_FD (NAME=VALUE entries, each ended by a NUL), and setenvs them.
    • It then removes itself from LD_PRELOAD and drops both variables, so the harness's children start without it.
    • On any error it exits with 126 and never runs half-protected.
  • The platform (exec-builder.ts) names the exec's key variables in TALE_HARNESS_KEYS (names only) and the taker in TALE_HARNESS_KEYS_EXE, from a new keysGuard: { exe: [...] } in harness.yml: claude.exe/claude, opencode, node for Pi.
    • The names covered are the harness's credentialEnvKeys, the session key variables, the subscription token variable and a BYO credential's variables.
    • An emptied variable stays in the environment, because it overrides one the session carries.
  • runnerd (harness-keys.ts, exec-manager.ts) applies this under the shim, where the image ships the guard. It moves those values out of the exec's environment onto fd 4 and preloads the guard.
  • The shim closes every descriptor past its status pipe, so fd 4 is the harness's alone.
  • Claude Code's --mcp-config names the bridge key as ${TALE_CONNECTORS_TOKEN}. The CLI expands it from its own environment (verified on 2.1.285 and 2.1.322), and its stdio servers inherit it.
  • Raw hosts and harnesses without keysGuard keep the status quo. macOS has no /proc, but ps -E shows the environment to the same uid there; that is left for T14b.

Phase 2 (T14b, #5550): workspace commands at a uid of their own

Only a separate uid ends inheritance (fact 3). A command the agent runs then neither inherits the keys nor can read the harness's or the intermediate shell's /proc entries.

Acceptance criteria (phase 1)

  • No guarded harness's exec carries a key on argv (Claude's --mcp-config included).
  • Under the image's shim and guard, another process of the uid reading /proc/<harness pid>/environ and mem is refused, and cmdline holds no key. The harness itself still has every key in its environment.
  • The wrapper chains work: Pi behind tale-pi-run and env node. Claude Code (claude.exe) and OpenCode take their keys directly.
  • The shim keeps no descriptor past fd 3.
  • A raw host, an image without the guard, and an unguarded harness run exactly as before.
  • Docs (the sandbox-runtime README) say plainly that children still inherit the keys until T14b lands.

Tests

  • daemon (bun test, real processes): build the shim and the guard with cc, run a stand-in harness (node behind sh) through a real ExecManager, and read its /proc entries from a separate same-uid process.
    • Without the guard (before), the key is readable from its environ.
    • With it (after), environ and mem are refused, cmdline is clean, the key arrived, and the shim's fds are exactly 0 to 3.
  • Unit: takeHarnessKeys.
  • platform:
    • an exec-builder guard over every guarded harness and the whole golden battery: no key on argv, and every key variable is named;
    • the golden fixtures refrozen for claude-code, opencode and pi.
  • Manual / end-to-end: the pinned Claude Code 2.1.285 under the guard, with the key on fd 4, starts its MCP server with the expanded key. That server, at the same uid, is refused /proc/<claude>/environ.

Not done here

Inheritance by the harness's children (fact 3) stays open until #5550 (T14b) lands. Phase 1 is not the complete fix.

Activity

  1. added
    service: platform
    agent-ready
    on Dec 2, 2026
  2. yannickmonney commented on Dec 2, 2026

    @yannickmonney
    ContributorAuthor

    Follow-up for the harnesses that phase 1 (#5551) leaves exposed, with their keys still in their environment: #5552 (Codex, Gemini, Qwen Code, Hermes, OpenClaw, and Cursor).

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

    agent-readysecurityservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions