Files
claude/.claude/tasks/plans/2026-11-14-docker-mount-deny-1400.md
T
bchanot 0f73d7ee01 fix(settings): deny docker mounts of the host root in 7 spellings
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.
2026-11-15 15:22:34 +01:00

8.9 KiB
Raw Blame History

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:

  1. Bench (harmless analogue, echo in place of docker, 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; V3 Bash(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=/,*; M3 Bash(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 img under V4, echo run --mount type=bind,source=/srv,target=/x img under M1 (no over-match of non-root paths). Run bench.sh; results.tsv append-only; every control must RAN in auto mode.
  2. settings.json deny: for each shape the bench proves, the docker rule Bash(docker * <shape>) and its Bash(rtk docker * <shape>) twin; keep the two existing -v rows (the T42 lock forbids removal; the new docker * -v /:/* supersedes them in coverage, removal not in scope).
  3. push-guard.test.sh T41 heredoc: every new row listed (presence lock).
  4. 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 match source=/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 sees docker … 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 allows rtk 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 commonest docker run -v /:/x img is uncovered (docker run * -v /:/* needs a token before -v; docker run -v /:* is legacy prefix syntax).
  • Shapes (one row each, leading * = typed docker, rtk docker, */rtk docker, /usr/bin/docker; no --mount literal so --mount= and source-first are covered): D1 Bash(*docker * /:/*) (-v /:/x, --volume /:/x, -itv /:/x, any subcommand) D2 Bash(*docker *=/:/*) (-v=, --volume=, -itv=) D3 Bash(*docker *v/:/*) (attached -v/:/x, -dv/:/x) D4 Bash(*docker *source=/,*) D5 Bash(*docker *src=/,*) D6 Bash(*docker *source=/ *) D7 Bash(*docker *src=/ *)
  • Bench (analogue echo for docker, 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-line echo 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: current Bash(echo run -v /:*) on echo run -v /srv:/x img (does the legacy row over-match?) and on echo run -v /:/x img.
  • rtk.tsv: rtk rewrite rc 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 the rtk 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 -v rows stay (D1 supersedes them; removal = next removed-ok window, not this fix) unless the MEASURE row shows docker run -v /:* over-matches non-root mounts: then it goes through removed-ok + T41.
  • autoMode soft_deny settings.json:615: widen additively from "docker run with 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 with Bash(*GIT_CONFIG_PARAMETERS*)). Each shape gets four prefixes: docker , rtk docker , */rtk docker , */docker (the last two still need a / right before rtk/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, prefixes echo , rtk echo , */rtk echo , */echo ): positives as r2; negatives add echo run -v /srv/:/x img and echo run -v ~/dev/:/x img under every shape, and a mention row grep -n 'echo run -v /:/x' f under S1 (want RAN). MEASURE (not gating): multi-line continuation rows (failure → named residual, check sent keeps \n), quoted --mount "type=bind,source=/,target=/x" under S4, legacy Bash(echo run -v /:*) on -v /srv:/x and -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.