Repository navigation
Description
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_TOKENandTALE_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:
- The connectors key is on argv for Claude Code.
exec-builder.tspasses Claude's MCP config with--mcp-config '{"mcpServers":{"connectors":{"env":{"TALE_CONNECTORS_TOKEN":"<key>"}}}}'(delivery: config-json-flag)./proc/<pid>/cmdlineis readable by every uid, dumpable or not, and so ispson a raw host. Golden fixture:lib/harnesses/fixtures/exec/claude-code.yml. - 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 wrappertale-pi-run. Only code loaded into the harness itself, before its main, can clear the flag. - Children inherit the keys. The harnesses hand their full environment to their Bash tool, hooks and MCP bridges.
tale-visionreadsTALE_GATEWAY_TOKENthere 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, anenv nodeshebang). - In that program it clears the dumpable flag, reads the keys from the descriptor named by
TALE_HARNESS_KEYS_FD(NAME=VALUEentries, each ended by a NUL), andsetenvs them. - It then removes itself from
LD_PRELOADand drops both variables, so the harness's children start without it. - On any error it exits with 126 and never runs half-protected.
- It acts only in the program named by
- The platform (
exec-builder.ts) names the exec's key variables inTALE_HARNESS_KEYS(names only) and the taker inTALE_HARNESS_KEYS_EXE, from a newkeysGuard: { exe: [...] }inharness.yml:claude.exe/claude,opencode,nodefor 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.
- The names covered are the harness's
- 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-confignames 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
keysGuardkeep the status quo. macOS has no/proc, butps -Eshows 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-configincluded). - Under the image's shim and guard, another process of the uid reading
/proc/<harness pid>/environandmemis refused, andcmdlineholds no key. The harness itself still has every key in its environment. - The wrapper chains work: Pi behind
tale-pi-runandenv 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 withcc, run a stand-in harness (node behindsh) through a realExecManager, and read its/procentries 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
yannickmonney commentedon Dec 2, 2026
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).
fix(sandbox): refuse a traced harness and match Pi by its own entry
test(sandbox): pin the image's guarded harnesses to their keysGuard
fix(sandbox): rebuild the guard's LD_PRELOAD without strcat
fix(sandbox): close an untaken key handover and fail its exec closed