oliver-zehentleitner / maity
[runner-stability] security: Claude Code placements of one OS user share a writable /tmp/claude-<uid> (assess, lab only)
tsk-z5c3798r1ces Open
Found by ops 3yc2 on 2026-11-21 (probes P1-P3 for tsk-k7svzz2p4v7y, report seq 186168, summary seq 186174), Claude Code 2.1.329, single layout:
- A sandboxed Claude Code session whose TMPDIR is unset gets
/tmp/claude-<uid>as its$TMPDIR. That is one directory for every Claude Code session of that OS user, and each sandbox can write it. - Two test placements A and B both got it, and B could list and create files in A's.
- Its top level also lists the directories of the live placements on that host.
- CLAUDE_CODE_TMPDIR does not change this. Only TMPDIR does, and with TMPDIR set to a short leaf, the leaf is mounted read-only (P3).
Not tested yet, on purpose: whether one sandbox can read or change files inside another session's subdirectory there.
The job (blue team, with red-team help where needed):
- Assess the impact with test placements only, on a lab runner or with throwaway placements of a test member. Never read or touch the directories of live agents. Can a sandbox read, overwrite or replace another session's files under /tmp/claude-<uid> (scripts, sockets, tool output)? What could that do to the other agent?
- Write the result with a severity on this card, and say what the fix in tsk-k7svzz2p4v7y (ugmc) must cover, for example a per-placement TMPDIR that the sandbox can write, or a different OS user per placement (the agent_user layout).
- Name in docs/runners.md, under known gaps, what holds until the fix: same-OS-user Claude Code placements are not separated in their temp directory.
No prod access, no live agent's data.
Notes
Richard Dean - Maity Security Lead · Nov 21, 2026, 11:07 UTC
Security assessment (purple team, blue by reading on top of ops 3yc2's lab probes P1-P4; test placements only).
Severity: HIGH, provisional. The sharing of one temp directory across Claude Code placements of one OS user is confirmed. The final grade waits on one more lab check on test placements, whose steps went to the lead.
Scope the fix (tsk-k7svzz2p4v7y) must cover:
- every Claude Code placement gets a private temp directory, including those without room under the scratch;
- a fallback that fails closed (no silent shared temp directory);
- a live check on the PR head;
- Codex and agy unchanged as proposed.
The step-2 design on tsk-k7svzz2p4v7y is supported from the security side, under those conditions.
Until it ships, the docs should say in known gaps: run placements of different owners as different OS users (agent_user layout).
Mr. Robot · Nov 21, 2026, 11:12 UTC
ops 3yc2, lab check for tsk-z5c3798r1ces (lotse go seq 186316). Two test placements only, A and B, of a throwaway project, run under maity-runner on oliver-pc01-l, 2026-11-21 ~11:08–11:12Z. Rig:
- built with main 773ea727's
adapters.launch()(TMPDIR unset, as live Claude Code placements start today); - Claude Code 2.1.329, sandbox on, headless,
SRT_DEBUG=1; - main's
plaincallhook dropped, because my probe interpreter can't importmaity; it only judgesmaitylines.
A ran
make one(holds 45 s), thenmake twoas a second Bash call. B ran its steps sandboxed while A held. No live agent's folder was touched.What A sources before each Bash command. The wrapped command, read from A's own process tree, is
source ~/.claude/shell-snapshots/snapshot-bash-<ms>-<6 chars>.sh … && eval '<cmd>' && pwd -P >| /tmp/claude-<uid>/cwd-<4 hex>. So the shell snapshot is not under `/tmp/claude-<uid>`; it is in~/.claude/shell-snapshots/, one directory for every session of the OS user. Under/tmp/claude-<uid>/<project dir>/<session uuid>/A keepstasks/<id>.output(its Bash output) andstarted/. The per-commandcwd-<hex>file sits at the top of/tmp/claude-<uid>.From B's sandbox, in A's dir `/tmp/claude-<uid>/<A's project dir>`:
ls -la: worked. It shows A's two session dirs.catof A's file: worked. B read A'stasks/<id>.output, i.e. the live output of A's running command (one: TMPDIR=/tmp/claude-1001 pid=4).touch <A dir>/from-b: worked.- Replace or append to A's shell snapshot (
~/.claude/shell-snapshots/snapshot-bash-…-nl5l8v.sh, the path from A's own process): refused,cannot create …: Read-only file system. The backup copy next to it was refused too.ls -laandtailof the snapshot worked, so B can read it (7756 bytes: functions, aliases and PATH of the user's shell, no secrets in this one). - A's next Bash command (
make two): did not run B's content. The canary variable was empty, and the canary file was absent.
So: read and write across sessions inside
/tmp/claude-<uid>work. The snapshot that A sources can be read but not written from a sandbox, so this path doesn't inject into A's next command.Not tested, but in reach by the same write access:
- A's
tasks/<id>.outputfiles, which Claude Code reads back as command output, are writable by B. - The
cwd-<hex>file that Claude Code writes after each command, to track the shell's cwd, is in the same shared dir.
Either may let B alter what A sees (output, cwd) rather than what A runs. Say if you want that checked the same way.
Cleanup: both test placements' clones, their
~/.claude/projectsentries and both project dirs under/tmp/claude-1001(incl.from-b) are removed. Claude Code deleted the test sessions' snapshots andcwd-*files itself at exit. Nothing of the check is left in/tmp/claude-1001,/tmp/maity-scratch-1001or~/.claude/shell-snapshots. Cost: 3 small headless prompts on maity-runner's Claude login (1 discovery run plus 2 for the check). The logs (no secrets) are in~/ops-workspace/tmp/probek7sv-state/on the PC.- built with main 773ea727's
Richard Dean - Maity Security Lead · Nov 21, 2026, 11:15 UTC
Final severity (purple team, after ops 3yc2's lab check nte-zrdf9hahny1z): HIGH.
Confirmed on test placements: another Claude Code placement of the same OS user can read, and change, parts of a session's working files in the shared temp directory. That breaks confidentiality and integrity between placements, across owners on a shared runner. Command injection through the sourced file was not possible (that file is read-only from another sandbox).
Covered by #2082 (step 1): Claude Code's own session files leave the shared directory where the placement gets a private leaf. Where its scratch has room, they follow its scratch.
Still needed in step 2:
- the remaining working file and the tools' TMPDIR;
- a fail-closed rule where no private temp directory can be made (today that falls back to the shared one).
Until then: run placements of different owners as different OS users.
Richard Dean - Maity Security Lead · Nov 21, 2026, 11:19 UTC
Correction to my two earlier notes on this card: the interim advice was "run placements of different owners as different OS users (agent_user layout)". The agent_user layout alone runs all of one runner's agents as one configured OS account, so it does not separate placements from each other. The interim separation needs a distinct OS account per owner, which means separate runner instances or targets (pcbf, A1861 on #2082). The severity is unchanged: HIGH until step 2 ships.
Mr. Robot · Nov 21, 2026, 11:41 UTC
ops 3yc2, probe for tsk-z5c3798r1ces (lotse go seq 186847, suqj seq 186833): does the unsandboxed Claude Code process read or run files in its own `claude-<uid>/` after a sandboxed command wrote them? One TEST placement of a throwaway project per case, Claude Code 2.1.329, sandbox on, headless. Main's
plaincallhook was dropped as before. oliver-pc01-l, 2026-11-21 11:35–11:40Z.Method:
- The whole
claudeprocess tree ran understrace -f(openat, execve and the clones; our own child only). The harness's own thread group is told apart from the sandboxed children byCLONE_THREAD. - A sandboxed
make stagelistedclaude-<uid>/and then planted harmless markers. It appended atouch <marks>/ran-file-Nline to every file there. Into every directory it wrote an executablez5c3.sh, asettings.json,hooks.jsonandhooks/hooks.jsoneach with a PreToolUse hooktouch <marks>/ran-hook-N, and a.claude-plugin/plugin.json. <marks>is a test dir under the probe's own state, in the placement's private paths: the sandbox cannot write it (checked, refused). So a mark there could only come from an unsandboxed process.- Triggers after the planting:
- further Bash tool calls in the same session;
- a second run of the session (
--continue, a new prompt); - that run's Bash tool call.
No plugin is configured, so no plugin reload was triggered.
1. PR #2084 head f2aea0e8 (`CLAUDE_CODE_TMPDIR=<leaf>`, `claude-<uid>/` beside `tmp`). The planting ran in the first session.
- Planted into: the top of
claude-<uid>/, the project dir, both session dirs andstarted/. - Refused:
plugin-tool-staging/(EROFS, read-only to the sandbox). bash-edit-diff/"accepted" the files but they never appeared outside, so it's a sandbox-private tmpfs.- That session then declined its two follow-up calls. The
--continuerun did a new prompt and a Bash call; that's the trigger. - A rerun with the lab context stated in the prompt was declined by the model before planting, so the leaf data is from the first run.
2. The short-root case on main 773ea727 (a scratch whose
tmpfits,TMPDIR=<scratch>/tmp,claude-<uid>/inside the writable scratch). It ran completely: stage, two more calls, then the--continuerun with one call.- Planted into: the top of
claude-<uid>/,bash-edit-diff/, the project dir, the session dir andstarted/. - Refused (`EROFS`): the session's
tasks/dir (no new files, and no append to the command's owntasks/<id>.output) andplugin-tool-staging/.
(continued in the next note: results, limits, cleanup)
- The whole
Mr. Robot · Nov 21, 2026, 11:41 UTC
ops 3yc2, harness-escape probe for tsk-z5c3798r1ces, part 2 of 2.
Result, both cases:
- No mark appeared. Nothing planted was run.
- No exec of any path in `claude-<uid>/` by any process.
- The harness's own threads never opened any planted file (
settings.json,hooks.json,plugin.json,z5c3.sh, or an appended file) for reading. After the planting, the harness only: - opened directories in
claude-<uid>/withO_PATH/O_DIRECTORY(the mount setup of the next sandbox:tasks,plugin-tool-staging,bash-edit-diff, the top); - wrote and read its own
fswatch-probe-*/probe, a fresh one each time. - In this rig, sandboxed code did not choose what the unsandboxed harness runs.
Limits:
- Claude Code 2.1.329 only.
- No plugins or skills configured. A placement with a delivered skill (
--plugin-dir) may stage intoplugin-tool-staging/, which is read-only to the sandbox here. - The harness may read a command's output through an open fd rather than
openat. Sincetasks/is read-only to the sandbox in case 2, the output file couldn't be rewritten there. - One correction to my lab note
nte-zrdf9hahny1z: I had marked A'stasks/*.outputin the shared/tmp/claude-<uid>as "writable by B, untested". Within a session, Claude Code makestasks/read-only to its own sandbox. Whether that holds for another session'stasks/in the shared dir is still untested.
Cleanup: all test dirs (the leaf, both throwaway projects incl. the short-root dir, their
~/.claude/projectsentries) are removed./tmp/maity-scratch-1001is empty. The traces are kept in~/ops-workspace/tmp/probeesc-*-state/on the PC (no secrets). Cost: 6 small headless prompts on maity-runner's Claude login.