The single legacy row matched no real spelling (bench M5). 28 rows (7 shapes x 4 prefixes, bench-proven with an echo analogue) now deny them; soft_deny covers create, container run and compose up; T41 locks the rows.
8.9 KiB
PLAN — docker-mount-deny (phase 2 residual, TODO.md:89) r1
Scope: settings.json (permissions.deny), lib/tests/push-guard.test.sh (T41 heredoc), new bench dir .claude/tasks/plans/2026-11-14-docker-mount-bench/.
DIAGNOSIS: deny covers host-root mounts only as Bash(docker run * -v /:/*) and Bash(docker run -v /:*). Uncovered (security gate 2026-10-23, left out of phase 2 for lack of bench rows): --volume /:/x, -v=/:/x / --volume=/:/x, --mount type=bind,source=/,… (also src=/, key order, source=/ last), and the docker container run / docker create subcommands. Second cause found 2026-11-14: rtk rewrites docker run --volume … and docker run --mount … to rtk docker run … (rc 3) BEFORE the permission check (bash-deny-probe README), so a rule starting docker never sees those forms; -v forms stay unrewritten (rc 2), which is why today's rule works. CLI 2.1.325: a pattern ending :* is the legacy prefix syntax (docker run * -v /:* never matched).
RELATED MEMORY: phase 2 bench method (.claude/tasks/plans/2026-11-02-phase2-bench), bash-deny-probe facts (rtk rewrite before evaluation; quoted args escape), H4a rtk read twins precedent (a43ba1b); BDR-136 (guards: deny rows, classifier backstop); push-guard T41/T42 non-weakening lock.
FIX PLAN:
- Bench (harmless analogue,
echoin place ofdocker, nothing mounted): copy phase2-bench run.sh/bench.sh into the new dir (paths relative to it), cases.tsv rows, each want DENIED with an automatic no-rule control. Candidate shapes (subcommand-agnostic*after the binary):- V1
Bash(echo * --volume /:/*)←echo run --rm --volume /:/x img - V2
Bash(echo * -v=/:/*)←echo run -v=/:/x img; V3Bash(echo * --volume=/:/*) - V4
Bash(echo * -v /:/*)←echo container run -v /:/x img(subcommand-agnostic twin of today's rule) - M1
Bash(echo * --mount *source=/,*)←echo run --mount type=bind,source=/,target=/x img; M2*src=/,*; M3Bash(echo * --mount *source=/ *)←… --mount type=bind,target=/x,source=/ img; M4*src=/ * - T1 twin shape:
Bash(rtk echo * --volume /:/*)←rtk echo run --volume /:/x img(rtk prefix form; analogue binary name) - negative rows (want RAN):
echo run -v /srv:/x imgunder V4,echo run --mount type=bind,source=/srv,target=/x imgunder M1 (no over-match of non-root paths). Runbench.sh; results.tsv append-only; every control must RAN in auto mode.
- V1
- settings.json deny: for each shape the bench proves, the docker rule
Bash(docker * <shape>)and itsBash(rtk docker * <shape>)twin; keep the two existing-vrows (the T42 lock forbids removal; the newdocker * -v /:/*supersedes them in coverage, removal not in scope). - push-guard.test.sh T41 heredoc: every new row listed (presence lock).
- TODO.md:89 closed with the bench path; shapes the bench refutes → named residual with the classifier as backstop.
RISK: low-medium. Over-match:
*source=/,*cannot matchsource=/srv,(comma right after/);-v /:/*needs/:exactly. A docker rule never blocks a non-mount docker call.
r2 (correctness CONCERNS(4), robustness CONCERNS(3), simplicity CONCERNS(2); all folded) — r2 WINS over r1
- DIAGNOSIS corrected: hooks/rtk-rewrite.sh:91-96 (
60ee4a9) keeps the ORIGINAL command on rtk rc 2|3, so the native matcher seesdocker …as typed; the gap is simply "no rule" (rtk's own rc 2 comes from reading the same deny list). rc 0 rewrites DO happen where a project allowsrtk docker *(faunosteo settings.local.json:113-116):rtk docker run …, or/…/rtk docker run …when rtk is off the hook PATH (rtk-rewrite.sh:128-131). Today even the commonestdocker run -v /:/x imgis uncovered (docker run * -v /:/*needs a token before-v;docker run -v /:*is legacy prefix syntax). - Shapes (one row each, leading
*= typeddocker,rtk docker,*/rtk docker,/usr/bin/docker; no--mountliteral so--mount=and source-first are covered): D1Bash(*docker * /:/*)(-v /:/x,--volume /:/x,-itv /:/x, any subcommand) D2Bash(*docker *=/:/*)(-v=,--volume=,-itv=) D3Bash(*docker *v/:/*)(attached-v/:/x,-dv/:/x) D4Bash(*docker *source=/,*)D5Bash(*docker *src=/,*)D6Bash(*docker *source=/ *)D7Bash(*docker *src=/ *) - Bench (analogue
echofordocker, new dir .claude/tasks/plans/2026-11-14-docker-mount-bench/ with copies of phase2 run.sh/bench.sh; each DENIED row has its no-rule control; deny text must say "has been denied"): positives: D1 ←echo run -v /:/x img,echo run --rm --volume /:/x img,echo container run -itv /:/x img,/usr/bin/echo run -v /:/x img,rtk echo run -v /:/x img,/home/u/.local/bin/rtk echo run -v /:/x img, multi-lineecho run --rm \\\n -v /:/x \\\n img; D2 ←echo run -v=/:/x img,echo run --volume=/:/x img; D3 ←echo run -v/:/x img,echo run -dv/:/x img; D4 ←echo run --mount type=bind,source=/,target=/x img,echo run --mount=type=bind,source=/,target=/x img,echo run --mount source=/,target=/x img, multi-line mount; D5 ←--mount type=bind,src=/,dst=/x,--mount src=/,dst=/x; D6 ←--mount type=bind,target=/x,source=/ img; D7 ←--mount type=bind,dst=/x,src=/ img. negatives (want RAN, under the matching rule):echo run -v /srv:/x img,echo run --rm --network none -v /opt/orbistep:/app:ro img,echo exec -i c psql -v ON_ERROR_STOP=1 -f -,echo run --mount type=bind,source=/srv,target=/x img,echo run --mount type=bind,source=/srv/,target=/x img. MEASURE: currentBash(echo run -v /:*)onecho run -v /srv:/x img(does the legacy row over-match?) and onecho run -v /:/x img. - rtk.tsv:
rtk rewriterc for the real docker spellings, run from this repo and from faunosteo, before and after the settings change (record only; rc 0 forms must be caught by the leading-*rows, proven by thertk echo/ absolute rows). - settings.json: Edit tool insert of D1-D7 after the existing docker rows (exact-match on the line after the tab line), then
jq -e .. The two old-vrows stay (D1 supersedes them; removal = next removed-ok window, not this fix) unless the MEASURE row showsdocker run -v /:*over-matches non-root mounts: then it goes through removed-ok + T41. - autoMode soft_deny settings.json:615: widen additively from "
docker runwith a bind mount outside the cwd" to "docker run/create/container run/compose up" (restriction only). - push-guard.test.sh T41 heredoc: D1-D7 listed.
- TODO.md:89 closed with the bench path AND a named residual list (classifier backstop): quoted mount args (
-v "/:/x", a quote cannot sit in a pattern, phase2 M3q), root aliases (//:/x,/.:/x,/..:/x, relative../..), upper-case mount keys, compose-file volumes, plus any shape the bench refutes.
r3 (confirmation CONCERNS(2), folded; FINAL)
- No bare leading
*(it denies any command that merely MENTIONS the text: grep, commit messages,rtk rewrite "…"; seen live withBash(*GIT_CONFIG_PARAMETERS*)). Each shape gets four prefixes:docker,rtk docker,*/rtk docker,*/docker(the last two still need a/right beforertk/docker, a narrow mention class, accepted and stated). - Shapes (S = suffix after the prefix): S1
* /:/*; S2*=/:/*; S3* -v/:/*(attached shorthand only; attached clusters-itv/:/x→ residual, a*v/:/form over-matches~/dev/:/x); S4*source=/,*; S5*src=/,*; S6*source=/ *; S7*src=/ *. Rows = 7 shapes × 4 prefixes = 28 deny rows (e.g.Bash(docker * /:/*),Bash(rtk docker * /:/*),Bash(*/rtk docker * /:/*),Bash(*/docker * /:/*)). - Bench (analogue
echo, prefixesecho,rtk echo,*/rtk echo,*/echo): positives as r2; negatives addecho run -v /srv/:/x imgandecho run -v ~/dev/:/x imgunder every shape, and a mention rowgrep -n 'echo run -v /:/x' funder S1 (want RAN). MEASURE (not gating): multi-line continuation rows (failure → named residual, checksentkeeps\n), quoted--mount "type=bind,source=/,target=/x"under S4, legacyBash(echo run -v /:*)on-v /srv:/xand-v /:/x. - Self-denial hygiene: the executor writes settings.json LAST; after that no Bash command may quote a covered spelling (rtk.tsv "after" rows read the command from a file:
rtk rewrite "$(cat f)"); presence is checked by make test T41 only; commit/memory text written from files. - Legacy
Bash(docker run -v /:*): if MEASURE shows it over-matches, Claude adds it to the push-guard removed-ok list and the USER deletes the settings line by hand (hard_deny: Claude never removes a deny entry); otherwise kept until the next removal window. - Residuals (TODO line, classifier backstop):
-v "/:/x"quoted short form, attached clusters-itv/:/x, host path from a variable or substitution (-v "$R":/x,$(realpath /)), root aliases//,/.,/.., relative../.., upper-case mount keys, compose-file volumes (no static or classifier coverage unless the file is read in the transcript), multi-line forms if MEASURE fails.