Claude blocks' MCP tokens are on claude's command line (readable through /proc) #128

Closed
opened 2026-10-04 01:31:53 +00:00 by jhgaylor · 2 comments
Owner

Found in the M44 review (2026-10-03). claude-agent-sdk (under claude-agent-acp) starts claude with --mcp-config <JSON> built from session/new's mcpServers. illogical's own server entry (agent/mod.rs Inner::servers()) carries the block's MCP token, as an Authorization: Bearer header or as ILLOGICAL_MCP_TOKEN in env. So any local user can read every running Claude block's token from /proc/<pid>/cmdline. Mounting /proc with hidepid would stop it, but Ubuntu doesn't by default.

That mattered little on a single-user machine. Since M45 it does: geek runs Fountain sandboxes as the fountain user, and a sandbox agent can read any block token and drive that block's tab through the daemon. (Checked: sudo -u fountain reads jake's processes' cmdlines.)

Fixes:

  • Defence in depth: M45b adds ProtectProc=invisible and ProcSubset=pid to the runner's unit; Jake re-runs the setup script.
  • The real fix, with M44's worn servers: pass values through the adapter's environment and send ${VAR} references in mcpServers, which Claude Code expands. M44's builder is checking that expansion works for --mcp-config.
  • Test: no token in any agent process's argv.
Found in the M44 review (2026-10-03). claude-agent-sdk (under claude-agent-acp) starts `claude` with `--mcp-config <JSON>` built from session/new's `mcpServers`. illogical's own server entry (`agent/mod.rs` `Inner::servers()`) carries the block's MCP token, as an `Authorization: Bearer` header or as `ILLOGICAL_MCP_TOKEN` in env. So any local user can read every running Claude block's token from `/proc/<pid>/cmdline`. Mounting /proc with hidepid would stop it, but Ubuntu doesn't by default. That mattered little on a single-user machine. Since M45 it does: geek runs Fountain sandboxes as the `fountain` user, and a sandbox agent can read any block token and drive that block's tab through the daemon. (Checked: `sudo -u fountain` reads jake's processes' cmdlines.) Fixes: - **Defence in depth:** M45b adds `ProtectProc=invisible` and `ProcSubset=pid` to the runner's unit; Jake re-runs the setup script. - **The real fix,** with M44's worn servers: pass values through the adapter's environment and send `${VAR}` references in mcpServers, which Claude Code expands. M44's builder is checking that expansion works for `--mcp-config`. - Test: no token in any agent process's argv.
Author
Owner

Interim mitigation on geek, 2026-10-03: a drop-in gives fountain-runner ProtectProc=invisible; Jake ran it with sudo. Checked from inside a runner sandbox (a hud-playground conversation): ls /proc shows 9 PIDs, all the sandbox's own, and ps users are fountain only. /home/jake, ~/.ssh, /run/user/1000 and illogical's state dir aren't listable. A sudo -u fountain shell outside the unit still sees everything, as expected. M45b makes the setting part of the unit. The real fix (no tokens in argv) is in M44's fixes.

Interim mitigation on geek, 2026-10-03: a drop-in gives `fountain-runner` `ProtectProc=invisible`; Jake ran it with sudo. Checked from inside a runner sandbox (a hud-playground conversation): `ls /proc` shows 9 PIDs, all the sandbox's own, and `ps` users are fountain only. `/home/jake`, `~/.ssh`, `/run/user/1000` and illogical's state dir aren't listable. A `sudo -u fountain` shell outside the unit still sees everything, as expected. M45b makes the setting part of the unit. The real fix (no tokens in argv) is in M44's fixes.
Author
Owner

Fixed in M44's merge (5110bb6). For every local Claude block, illogical's MCP entry is Bearer ${ILLOGICAL_MCP_BLOCK_TOKEN}, and worn servers' values are ${ILLOGICAL_FTN_…}. The values sit in the adapter's environment, and Claude Code expands them; the builder checked this against a real claude for headers, URLs and stdio env. Stdio args with variables, and values containing ${, are left out rather than put on a command line. A sampled ps during a worn pr-reviewer session showed no token. Adapters started by an older daemon are restarted on takeover. Codex and other ACP agents still get literal values (codex-acp passes config in-process). The runner unit's ProtectProc=invisible stays as defence in depth.

Fixed in M44's merge (5110bb6). For every local Claude block, illogical's MCP entry is `Bearer ${ILLOGICAL_MCP_BLOCK_TOKEN}`, and worn servers' values are `${ILLOGICAL_FTN_…}`. The values sit in the adapter's environment, and Claude Code expands them; the builder checked this against a real claude for headers, URLs and stdio env. Stdio args with variables, and values containing `${`, are left out rather than put on a command line. A sampled `ps` during a worn pr-reviewer session showed no token. Adapters started by an older daemon are restarted on takeover. Codex and other ACP agents still get literal values (codex-acp passes config in-process). The runner unit's ProtectProc=invisible stays as defence in depth.
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jhgaylor/illogical#128
No description provided.