You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
remove_iso_files.sh: prefix can escape the repo root and rm -rf runs unquoted #12134
lib/remove_iso_files.sh takes its prefix argument from the command line without checking it, builds a glob from it, and deletes the matches with an unquoted rm -rf. A prefix containing / or .. escapes the repository root, and with -force the confirmation prompt is skipped, so the deletion happens with no warning.
Evidence (verified in the current tree)
lib/remove_iso_files.sh:19-37: prefix="$1" with no validation beyond the empty check.
lib/remove_iso_files.sh:66-67: cd "$repo_root" then prefix="${prefix}_", with no check that prefix is a plain name.
lib/remove_iso_files.sh:103: rm -rf $pattern. The variable is unquoted, so word splitting and globbing apply again to the already-built pattern.
Reproduction in a scratch tree: repo at .../repo with a sibling ../outside/victim_x.iso. Running bash remove_iso_files.sh ../outside/victim -force printed ./../outside/victim_*.iso, found 1 file, and deleted ../outside/victim_x.iso. Return code 0.
A prefix with a space ('a b') does not delete anything, but it still reports "Exiting without error" under -force, because the unquoted glob splits into two words.
Callers: lib/build_iso.sh:127 passes "$hostname" with -force. The risk is an operator typo or a hostname value that carries a path, not a remote attacker.
Why it matters
Deleting files outside the repo is irreversible and gives no prompt when -force is used. The script's own header says it only erases ISO files "in the repository root".
Suggested fix shape
Accept only a plain name: reject any prefix that contains /, starts with ., or contains characters outside [A-Za-z0-9._-], with a usage error and non-zero exit. The operator script argument contract (AGENTS.md, doc/agents/operator-script-argument-contract.md) asks for exactly this kind of strict parse.
Use a bash array or find -maxdepth 1 -name ... -print0 and rm -f -- on the array instead of rm -rf $pattern.
Add a test that a prefix containing ../ is refused and that a file outside the root survives.
Plan: verify the premise on current main (lib/remove_iso_files.sh — prefix escape + unquoted rm -rf). A sibling fix (commit 8034f4b3934, for #12135) reportedly rewrote this script but the rewrite was never runtime-verified against this issue's reproduction. I will re-run the issue's scratch-tree reproduction against current main: if the escape is refused and the outside file survives, close as completed with fresh evidence; if it still escapes, implement the suggested fix shape (plain-name prefix validation, array/rm -f -- deletion, regression test), PR, merge, close.
Done — Lane VH (archer), 2026-11-23: premise STALE; the vulnerability is fixed on main. Closing as completed.
The fix landed 2026-11-21 in commit 8034f4b39343c7d480ae6ee78dd5c399ef918009 ("lib: keep remove_iso_files inside the repo root", Refs #12134) — the same commit that fixed sibling #12135. It implements this issue's suggested fix shape: the prefix must match ^[A-Za-z0-9_][A-Za-z0-9._-]*$ (no /, no leading ., no glob/shell metacharacters), matches are collected into a bash array under nullglob, and deletion is rm -f -- "${files[@]}" — no unquoted rm -rf $pattern remains. That commit was never runtime-verified against this issue's reproduction; this pass supplies that verification.
Runtime verification (laptop, script extracted verbatim from current origin/main, scratch tree with a sibling ../outside/victim_x.iso, run from a scratch git repo):
bash remove_iso_files.sh ../outside/victim -force → refused: Error: prefix must be a plain name, exit 1, victim file survived. (The issue's original reproduction deleted the victim and exited 0.)
Normal path intact: prefix host1 -force deleted exactly the two in-root host1_*.iso files, exit 0; a non-matching in-root ISO and the outside victim were untouched.
Caller compatibility: the only caller, lib/build_iso.sh:127, passes "$hostname" — a plain name, accepted by the new validation.
Noted gap (no action taken): no checked-in regression test or verifier references remove_iso_files anywhere on main (git grep finds only the caller); the runtime evidence above is the verification of record for this issue.
Activity
developing-today commentedon Nov 20, 2026
CODE-4402
dezren39 commentedon Nov 23, 2026
Claim — Lane VH (archer) taking code#12134 now.
Plan: verify the premise on current main (
lib/remove_iso_files.sh— prefix escape + unquotedrm -rf). A sibling fix (commit8034f4b3934, for #12135) reportedly rewrote this script but the rewrite was never runtime-verified against this issue's reproduction. I will re-run the issue's scratch-tree reproduction against current main: if the escape is refused and the outside file survives, close as completed with fresh evidence; if it still escapes, implement the suggested fix shape (plain-name prefix validation, array/rm -f --deletion, regression test), PR, merge, close.dezren39 commentedon Nov 23, 2026
Done — Lane VH (archer), 2026-11-23: premise STALE; the vulnerability is fixed on main. Closing as completed.
The fix landed 2026-11-21 in commit
8034f4b39343c7d480ae6ee78dd5c399ef918009("lib: keep remove_iso_files inside the repo root", Refs #12134) — the same commit that fixed sibling #12135. It implements this issue's suggested fix shape: the prefix must match^[A-Za-z0-9_][A-Za-z0-9._-]*$(no/, no leading., no glob/shell metacharacters), matches are collected into a bash array undernullglob, and deletion isrm -f -- "${files[@]}"— no unquotedrm -rf $patternremains. That commit was never runtime-verified against this issue's reproduction; this pass supplies that verification.Runtime verification (laptop, script extracted verbatim from current
origin/main, scratch tree with a sibling../outside/victim_x.iso, run from a scratch git repo):bash remove_iso_files.sh ../outside/victim -force→ refused:Error: prefix must be a plain name, exit 1, victim file survived. (The issue's original reproduction deleted the victim and exited 0.)'a b'→ refused, exit 1..hidden→ refused, exit 1.'h*'→ refused, exit 1; matching in-root file untouched.host1 -forcedeleted exactly the two in-roothost1_*.isofiles, exit 0; a non-matching in-root ISO and the outside victim were untouched.Caller compatibility: the only caller,
lib/build_iso.sh:127, passes"$hostname"— a plain name, accepted by the new validation.Noted gap (no action taken): no checked-in regression test or verifier references
remove_iso_filesanywhere on main (git grepfinds only the caller); the runtime evidence above is the verification of record for this issue.