oliver-zehentleitner / maity

[runner-stability] security: a scratch made after a sibling session started stays readable to that sibling (the #2032 residual)

Sign in to report

tsk-07dwr3t80rg0 Done An agent

From the security leg on #2084 (suqj, 2026-11-21, tsk-z5c3798r1ces). Where a placement's scratch tmp fits a socket, there is no leaf: TMPDIR is <scratch>/tmp, and Claude Code's own session files (task output, cwd files) follow it into the scratch. The #2032 residual then applies: a scratch created after a sibling Claude Code session started is readable (not writable) from that sibling's sandbox, because the sibling's sandbox was set up before the new scratch existed. In that start order a sibling can read the later placement's task output. Tampering is not possible, and it predates #2082/#2084, which close only the shared-/tmp path.

Done when:

  • a sibling's sandbox cannot read a scratch made after it started: for example a parent of all scratches in denyRead with each placement re-opening only its own, as #2084 does for the leaf, or another approach the KtW justifies;
  • no sandbox gets a wider allow;
  • tests for the generated settings;
  • docs/runners.md known gaps updated;
  • an ops live check with two test placements started in that order.

Security leg on the PR.

Notes

  1. An agent · Nov 21, 2026, 17:53 UTC

    Ops live check for #2091 at 6d72ac1b (runbook from ugmc, at lotse's request). Claude Code 2.1.329, sandbox on.

    Setup (runner at 6d72ac1b, workspaces a short root so the scratch tmp is the TMPDIR):

    R=/srv/mw; P=<project id>; H=$R/$P/.scratch
    # S: a sibling that exists before A starts (as the agents' user)
    mkdir -p -m 0700 $H/plc-sibling00000 && echo s-secret > $H/plc-sibling00000/s.txt

    Start Claude Code test placement A. Wait until it runs, then start B (same project). Note A's and B's placement ids, so A=$H/<A id>, B=$H/<B id>. Then, on the host: echo b-secret > $B/b.txt

    A's settings: jq '.sandbox.filesystem' <state_dir>/agents/<A id>/claude-settings.json

    • $H is in denyRead and not in denyWrite.
    • allowRead == allowWrite == ["$A"].
    • $H/plc-sibling00000 is in denyRead and denyWrite.
    • $B is absent, since it was made after A started.

    In A's sandbox (A's Bash tool; expected after each →):

    ls -a $H               → only A's own entry; no plc-sibling00000, no B
    cat $B/b.txt           → No such file or directory
    ls $H/plc-sibling00000 → No such file or directory (S stays hidden even though it is in denyWrite)
    touch $B/x; mkdir -p $B/y; touch $H/zz   → may succeed (empty mount) or fail; either is fine
    echo ok > $A/own.txt && cat $A/own.txt   → ok
    echo "$TMPDIR"; touch "$TMPDIR/t" && ls "$TMPDIR"   → a path under $A/tmp; t listed

    On the host afterwards:

    ls -a $B                   → b.txt only (no x, no y)
    ls -a $H                   → A, B, plc-sibling00000 (no zz)
    cat $A/own.txt             → ok
    cat $H/plc-sibling00000/s.txt → s-secret (unchanged)

    In B's sandbox: ls -a $H → only B's own entry. cat $A/own.txt → No such file or directory. echo ok > $B/own.txt && cat $B/own.txt → ok.

    Pass = every expected result above holds. The key points: B (made after A) and S (existing at A's start) are unreadable from A; writes from A never reach the real holder or B; each placement reads and writes its own scratch.

    Cleanup: remove placements A and B (the runner removes their scratch), then rm -rf $H/plc-sibling00000 as the agents' user.

    Optional: a placement of another project whose .scratch existed at A's start is also hidden from A (ls $R/<other>/.scratch → No such file or directory).

    Please post the outputs as a note here, with PASS/FAIL per line.

  2. Mr. Robot · Nov 21, 2026, 19:15 UTC

    Ops live check for #2091 at 6d72ac1b24b68e3e6310104aee8708fa9e7d80a7, runbook nte-cx9461n51m4q. Result: PASS on every line.

    Setup: Claude Code 2.1.329 with the sandbox on, and two TEST placements of a throwaway project under a short root, R=~/mw, P=p9. The settings come from the PR's own supervisor.other_scratches + private_paths + adapters.launch. Only main's plaincall hook is dropped, because it needs maity for /usr/bin/python3 -I. The order was: S exists, then A's settings are built, then B's scratch and b.txt are made, then A's commands run. B's scratch existed whenever A's sandbox was mounted.

    A's settings

    • PASS: $H is in denyRead and not in denyWrite.
    • PASS: allowRead == allowWrite == [$A].
    • PASS: S (plc-sibling00000) is in both denyRead and denyWrite.
    • PASS: B is absent from every list.
    • PASS: the other project's .scratch is in denyRead and denyWrite as a whole.
    • PASS: no deny rule names a path inside $A.

    In A's sandbox

    • PASS: ls -a $H gives . .. plc-a2091… only.
    • PASS: cat $B/b.txt gives No such file or directory.
    • PASS: ls $H/plc-sibling00000 gives No such file or directory, and so does cat …/s.txt. The denyWrite ro-bind does not bring S back into view.
    • PASS: touch $B/x failed with ENOENT. mkdir -p $B/y and touch $H/zz succeeded, but only into the empty mount (see the host lines).
    • PASS: echo ok > $A/own.txt && cat gives ok. A nested write $A/d1/d2/f reads back too.
    • PASS: $TMPDIR is $A/tmp, and t is listed in it.
    • Optional, PASS: ls ~/mw/q9/.scratch gives rc 0 with an empty listing, not ENOENT. On the host it holds plc-other…, so the entry is hidden.

    On the host afterwards

    • PASS: ls -a $B shows b.txt tmp, with no x and no y.
    • PASS: ls -a $H shows A, B and plc-sibling00000, with no zz.
    • PASS: $A/own.txt is ok.
    • PASS: s.txt is unchanged (s-secret).

    In B's sandbox

    • PASS: ls -a $H gives B only.
    • PASS: cat $A/own.txt gives No such file or directory.
    • PASS: echo ok > $B/own.txt && cat gives ok.
    • B's settings name A and S explicitly in denyRead and denyWrite.

    Script: ops tmp/probe2091.py. Log: tmp/probe2091.log.