Skip to content

fix(security): a redirect before the -c operand hides no payload, and the rm floor reads nested shells - #22719

Merged
iamwhatever merged 1 commit into
mainfrom
fix/19473-walk-redirect
Oct 30, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/19473-walk-redirect

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A recursive-force wipe of root or home is refused when it is wrapped in a nested shell, and a redirect placed before a -c operand no longer hides that operand from any gate.

On main, two gaps let a nested-shell command through:

  • A redirect before the -c operand hid the payload from every gate. The shared _nested_shell_payloads took the redirect word itself as the -c script, so every gate that reads nested payloads (the self-protection floors, the deny views, the rm floor) looked at the redirect instead of the script bash runs.
  • The rm floor never read nested payloads. deny_gate ran _rm_wipe_targets on the top-level text only, so bash -c 'rm -fr /' and busybox sh -c 'rm -fr /' were allowed (the two catalog rows match -rf only).

Why it matters

The rm floor exists to catch common respellings of rm -rf / and rm -rf ~; wrapping the command in bash -c was a one-step way around it. The redirect gap was wider: it reached every gate that relies on the shared nested-payload extractor.

Not a goal

What changed (motivation → approach → change)

Both fixes read commands through the shared quote-aware reader, shell_commands.read_commands (#25175). It knows where a command ends at a live separator, even one glued to a word, and which words are redirections.

Part Change
shell_commands.py redirect_free_views(text): each command holding a live redirection, rendered without it, read for every frame holding a < or >, so a quoted or escaped carrier flag (bash "-c", bash -\c) hides nothing. read_commands reads &>, &>> and `>
shell_normalizer._shell_payload_walk Adds the redirect-hidden payloads to each frame's payloads (self-protection and git-publish floors).
deny_gate deny views Same, so the frame's echo / cat exemption still applies.
rm_floor._rm_wipe_targets_nested (called from deny_gate) Runs the floor on the text and on every nested payload. Each command's argv (redirections and targets stepped over) goes to the shared _nested_shell_payloads. A payload is skipped when it is an eval / source / . argument, or when the shared data-consumer exemption marks it inert in its own command. At a live <<, the stopped command runs to the line's end (a herestring is a payload) and the rest of the line is read too; only the heredoc body is data.

A redirect view ends at its command's separator, so a later command's words are never read as the script: bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed again. Each command is read on its own, so a glued && / & no longer lets an echo exemption cover the next command.

Each payload is read as yielded and \$-unescaped (fail closed: a single-quoted bash -c 'rm -fr \$HOME' is over-refused). A single-quoted $HOME inside a double-quoted payload is not read, as on main (#25385). docs/system-specs/modules/security.md covers the reader helpers and the rm floor's nested read. test/test_security_gate_liveness.py: package line budget 32,793 → 32,930 (measured).

Before / after

Command main this PR
bash -c 'rm -fr ~' allowed refused
bash -c 2>/dev/null 'rm -fr ~' allowed refused
bash -c 2>$(printf /dev/null) 'rm -fr ~' allowed refused
bash -c &>/dev/null 'rm -fr ~' allowed refused
env -S 2>/dev/null '<protected-branch publish>' allowed refused
echo x&&bash -c 'rm -fr /' allowed refused
true&>x rm -r -f ~ (dash runs the rm) refused refused
echo $( bash -c 'rm -fr ~' ) allowed refused
echo '<home wipe>' | sh allowed allowed (#25477)
echo '<home wipe>' | tee x; sh run.sh allowed allowed
git log --oneline | head -3 allowed allowed
bash -c 'rm -fr \<newline>~' allowed refused
bash -c 2>/dev/null 'make lint' && git commit -m 'git push origin main' allowed allowed
echo "$(date)" bash -c 'rm -fr ~' allowed allowed (prints)
echo bash -c 'rm -fr ~' allowed allowed
bash -c 'rm -fr /tmp/x' no floor refusal no floor refusal

Backwards compatibility

Compatible: the change only adds refusals for wipes of root or home itself, and for payloads a redirect used to hide. Redirect-hidden payloads are added beside the frame's own; the original text is still walked, so no gate sees less than on main. Walk time on deep nesting stays at main's level (measured below).

Removes nothing: no rule, pattern, key or function is removed.

Tests

test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads:

  • Refused by the floor (component=argv-floor): bash -c, busybox sh -c, $"..." forms, redirect shapes before or glued to the operand (a target spanning words or a substitution, a quoted ( or ; target, two redirects, a target named eval / source), env -S, glued herestring and -c'...' decoys, comments, a newline after echo, substitution bodies, a heredoc marker's own line, line continuations, single-quoted $HOME inside a double-quoted payload, and glued && / & / || / | before a nested wipe.
  • Kept: bash -c 'rm -fr /tmp/x', echo bash -c '...', echo "$(date)" bash -c '...', bash -c 2>/dev/null 'ls', heredoc bodies, and rm -rf /tmp/x stays refused by its row as on main.
  • A redirect hides no payload from the self-protection floor or the deny views; a later commit message is not read as the script.
  • eval arguments are not walked: a 1,200-deep eval stack reads one frame.

Proof: PROVEN test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_nested_wipe_is_refused_by_the_floor[bash -c 'RM -fr /'], test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_nested_wipe_is_refused_by_the_floor[busybox sh -c 'RM -fr /'], test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_nested_wipe_is_refused_by_the_floor[bash -c $" RM -fr "], test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_nested_wipe_is_refused_by_the_floor[bash -c "RM -fr "$""], test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_nested_wipe_is_refused_by_the_floor[bash -c 'cd x && RM -fr ~'] (head 49c6590)

Scoped tests: 434 passed on 49c6590050.

Cost through is_denied (best of 5 x 300 calls, under one host lock):

Command main this PR
git log --oneline -5 2>/dev/null | head -3 > /tmp/out.txt 0.86 ms 1.14 ms
bash -c 'make lint' 2>&1 | tee build.log 1.04 ms 1.22 ms
cd src && python -m pytest … > /tmp/t.log 2>&1; tail -5 /tmp/t.log 1.15 ms 1.49 ms
'echo "$(' * 300 nesting (one call) 12.7 s 13.0 s
echo >x at every nesting level 18.9 s 20.4 s
bash -c >x at every nesting level 25.9 s 27.4 s
"rm x " + "<<a " * 5000 (one call) 0.18 s 0.25 s

Every new refuse row is allowed on main (probed through is_denied); the glued && rows are allowed and the commit-message row refused on the prior head dd699a4adb.

Targeted: every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped.

Manual verification

N/A — unit coverage sufficient: the change is a pure function of the command text, probed through is_denied.

Related Issues

Part of #19473

Sibling sweep

Swept: git grep -n "_nested_shell_payloads(" -- src/
Sibling: src/kiro_crew/security/shell_normalizer.py -- changed here
Sibling: src/kiro_crew/security/deny_gate.py -- changed here
Sibling: src/kiro_crew/security/argv_floor_git.py -- not affected -- its defer check waits for frames _shell_payload_walk already judges

Pattern harvest

Rule candidate: review-prompt
Pattern: an argv walker that picks "the next word" after a flag must skip shell redirections, which bash removes from argv wherever they sit.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 21, 2026 09:30
@iamwhatever
iamwhatever requested a review from buluoray October 21, 2026 09:30
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/deny_gate.py

  • src/kiro_crew/security/rm_floor.py

  • src/kiro_crew/security/shell_commands.py

  • src/kiro_crew/security/shell_normalizer.py

  • @iamwhatever posted a complete reasoning template for 38577b8.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 38577b84c33161f98df34a7bddb31f2eab9287c3 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 38577b84c33161f98df34a7bddb31f2eab9287c3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change only adds refusals, it routes through the shared reader rather than adding a second parser, and a revert undoes it cleanly.

Notes

  • The rm floor now accumulates the case-by-case spelling handling AGENTS.md calls a review smell: &>→& > re-reads, <<< handling, glued-copy counting, both \$ views. Defer the next spelling round (rm floor: nested-shell spellings still read wrong after #22719 (option after -c, comment backslash, heredoc into a shell) #22756) rather than adding more readings to _command_tokens.
  • read_commands now reads &>, >| and <<< differently. That also changes how exfil_bash.py and the existing _segments callers see commands. The PR text names only the rm floor and nested-payload gates, so pin one exfil_bash case that shows nothing loosened there.
  • This reverses a scope line in security.md (rm floor out of scope for "bash -c payloads"). That line was a spec statement, not a pinned test or a docs/decisions/ entry, so it isn't blocking. Still, say in the description that it was a deliberate scope widening.

[DESIGN-REVIEWED] 38577b8

Description read

[DESCRIPTION-READ] c0ccfcd8caa6c8f167990968340d8cd6ddace4f06793576024b33a34638ff079

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 38577b84c33161f98df34a7bddb31f2eab9287c3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The rm floor's nested read is a third payload walk next to two that already exist. It differs from them in how it handles eval and the exemptions, so this is a note and not a block.

Notes

  • Item 1 — duplicate of shell_normalizer._shell_payload_walk (shell_normalizer.py:1416): _rm_wipe_targets_nested is a new walk that descends through nested payloads. I grepped _nested_shell_payloads( and found 3 descending walks (shell_normalizer.py:1468, deny_gate.py:274, rm_floor.py:225). The new one adds its own eval skip and its own seen / length bound. The rm floor's needs differ (it skips eval, an O(N) cost the PR measured, and it must not lowercase), so whether this is a second spelling is a judgement call. Subtraction: run _rm_wipe_targets over the sources that _shell_payload_walk already yields, and delete _rm_wipe_targets_nested's own descent loop.

What this change ships

Inventory (8 items) — 7 justified

Intent: stop a recursive-force wipe of root or home from getting past the gates inside a nested shell or behind a redirect before -c. This is a FIX.

  1. bash -c 'rm -fr ~' and busybox sh -c 'rm -fr /' are now refused by the rm floor — duplicate walk of _shell_payload_walk
  2. A redirect before the -c operand no longer hides the script from the self-protection, git-publish and deny gates — justified
  3. &>, &>> and >| are read as one redirection by the shared reader — justified
  4. A glued && or & no longer lets an echo exemption cover the next command — justified
  5. A herestring <<< no longer stops the shared reader, which also changes what exfil_bash reads — undeclared
  6. Within one is_denied call, the two walks share one view result per frame — justified
  7. A single-quoted \$HOME payload is now refused (fails closed) — justified
  8. Package line budget raised to 33,147; the description says 32,930 — justified

[FIRST-PRINCIPLES-REVIEWED] 38577b8

Description read

[DESCRIPTION-READ] b4e500e0ef27b8ba9202080721445648664034e00f86805911c23b54228b6073

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 38577b84c33161f98df34a7bddb31f2eab9287c3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 38577b8

Verdict parsed from the review's SHA-scoped output markers for commit 38577b84c33161f98df34a7bddb31f2eab9287c3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 38577b84c33161f98df34a7bddb31f2eab9287c3 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 38577b84c33161f98df34a7bddb31f2eab9287c3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 38577b8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 38577b84c33161f98df34a7bddb31f2eab9287c3 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 38577b84c33161f98df34a7bddb31f2eab9287c3 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 22 classified, 0 newly refused, 21 still allowed.
  • ubuntu-latest (platform posix): 22 classified, 0 newly refused, 21 still allowed.
  • windows-latest (platform windows): 8 classified, 0 newly refused, 8 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The change only adds refusals inside the shell deny composite: the rm floor now reads nested-shell payloads, payloads hidden behind a redirect are added to the deny views and the self-protection and git-publish floors, and the shared reader now treats &>, >| and <<< as redirections. The classifier can test all of these, and no confirmed newly-refused row has been handed to this review. One narrowing is argued but not confirmed: read_commands changes go to every caller, so the exfil_bash tier now reads text after a <<< that it used to skip as heredoc data. The herestring rows below probe that.

TIGHTENING: The rm recursive-force floor and the nested-payload walks (sensitive-bash / deny-rules, argv-floor component) -- they refuse a root or home wipe hidden in a nested shell or behind a redirect before the -c operand: - rm_targets = _rm._rm_wipe_targets(tool_name) / + rm_targets = _rm._rm_wipe_targets_nested(tool_name) together with + payloads = [*payloads, *_submodule("shell_commands").redirect_hidden_payloads(source)] ("sh -c 2>/dev/null '<script>' hides no script").

ADJUDICATED: 30 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: posix (22 rows): bash -c / sh -c / env -S carriers with a redirect before and after the operand, &> and &>> used for background runs and health probes, >| under noclobber, <<< herestrings feeding jq, read, gh and cat, an escaped \$TMPDIR inside a double-quoted payload (the new \$→$ view), and $HOME or ~ in a nested payload that removes nothing. Together they cover each posix-shell assumption the diff adds (bash's reading of &> against dash's, the herestring word, the order of -c and its operand). windows (8 rows): cmd /c with 2>nul before and after the operand, PowerShell 2>$null and *>, the rm -r -fo $env:TEMP\... alias form, Git Bash bash.exe -c under a C:\Program Files path, and %TEMP% redirect targets. These probe whether the posix-only reader (now splitting &> and parsing redirects) over-reads Windows spellings. One Windows assumption has no row: PowerShell's & call operator placed directly before > (for example & tool>out). Nobody writes that form for real, so I spent no slot on it.

UNADJUDICATED: Narrowing to check, not a guard outside the classifier: shell_commands.read_commands (<<< no longer stops the read; &> and >| now read as redirections; a trailing | added to the ShellWord glue check) is shared by exfil_bash.py. An input reaches it through is_denied → the exfil tier → read_commands, so a herestring's word and the commands after it are now read where before they were treated as heredoc data. The rows gh pr comment 9332 --body-file - <<< "$DISPOSITION", cat <<< "$NOTES" > docs/notes.md && git add docs/notes.md and jq -r '.number' <<< "$PR_JSON" probe this boundary. Any loss here would come from the harness verdict, not from this review.

[SCOPE-REVIEWED] 38577b8

@iamwhatever
iamwhatever force-pushed the fix/19473-walk-redirect branch from 8376d8e to 26e0757 Compare October 21, 2026 10:03
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • A redirect target named eval or source drops the payload (span=f6adfbd55f89)

outcome: fixed
fixed in 26e0757: _after_shell_verb counts eval / source / . only in program position (_argv_programs), so a redirect target named eval or source is a file and the payload after it is read.
Tests: refuse rows bash -c > eval '...' and bash -c 2> source '...' in TestRmFloorReadsNestedShellPayloads.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Consume the complete redirect operand before selecting the script (span=5e784cc06287)

outcome: fixed
fixed in 26e0757: where a redirect's target ends cannot be told from dequoted words, so when the -c (or env -S) operand is a redirect every later word up to the end of that simple command is a candidate payload (fail closed).
Each word is yielded once per call, so it stays linear. Tests cover a target spanning words, a spaced 2> $(...), a quoted ( in the target and two redirects.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Redirect filenames incorrectly grant the source exemption (span=e8aa6e56f6f9)

outcome: fixed
fixed in 26e0757: same root cause and fix as the Opus finding: the eval/source skip now needs the verb in program position, so a redirect target named source grants no exemption.
Test: refuse row bash -c 2> source '...'.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Quoted printed arguments are scanned as executable scripts (span=e8aa6e56f6f9)

outcome: rebutted
rebutted: not a defect. The finding is a false refusal, the safe direction for this gate, and no wipe passes.
The shared _data_consumer_exempt refuses the exemption for a dequoted word holding ; because the tokenizer has dropped the quotes and cannot tell echo 'a; b' from echo a;b, where b really runs. Reading it as a command fails closed.
Widening the exemption here would need quote-aware tokens, which this PR does not add; it would also change the shared rule four other gates rely on.

@iamwhatever
iamwhatever force-pushed the fix/19473-walk-redirect branch from 26e0757 to a0bca5b Compare October 21, 2026 10:19
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • A glued payload equal to an inert echo argument was exempted (span=f6adfbd55f89)

outcome: fixed
fixed in a0bca5b: _rm_wipe_targets_nested exempts a payload only when its text occurs nowhere in the command but in its exact-token spots, and every spot is a data consumer's argument.
A payload cut out of a glued herestring or -c'...' word therefore stays walked when an echo decoy repeats it, before or after.
Tests: two refuse rows in TestRmFloorReadsNestedShellPayloads; echo bash -c '...' stays exempt.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 21, 2026
@iamwhatever
iamwhatever force-pushed the fix/19473-walk-redirect branch from a0bca5b to 8f7b800 Compare October 21, 2026 10:42
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • A source argument exempts an independently executable payload (span=e8aa6e56f6f9)

outcome: fixed
fixed in 8f7b800: the eval / source skip now carries the same guard as the data-consumer skip: a payload is skipped only when its text occurs nowhere in the command but in its exact-token spots.
A herestring or -c'...' payload equal to a source / . / eval argument therefore stays walked. Test: refuse row source '...' || bash<<<'...'.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Later command flags miss the redirect-aware extraction (span=5e784cc06287)

outcome: fixed
fixed in 8f7b800: the every-carrier sweep in _nested_shell_payloads now also calls _operands_past_redirect, sharing the memo and the dedupe set, so a later -c carrier behind a redirect yields its script.
Cost stays linear (bash -c -c >x x 1,600 yields 1,603 payloads). Test: refuse row bash -c -c 2>/dev/null '...'.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Security Scope note (head a0bca5b3269b): the one newly refused row is a push helper behind sh -c 2>/dev/null '...' sh <branch>, where the script pushes to "$1".

Main already refuses the same command without the redirect. Bash removes the redirect before it runs the script, so both spellings run the same push, to a branch the gate cannot read from the text. Main refused the plain spelling and missed the redirect spelling; this PR makes them agree. No legitimate operation is newly narrowed, so there is no code change. A maintainer can override the Security Scope lane for this head if they agree.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 21, 2026
@iamwhatever
iamwhatever force-pushed the fix/19473-walk-redirect branch from 8f7b800 to 1ac968b Compare October 21, 2026 11:22
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b9957ab21577d6a65f23930a2b228d01134e69f2
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s).
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 426 passed on b9957ab. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Dependency License Gate on b9957ab215 is a repo setting, not this diff: "Dependency review is not supported on this repository. Please ensure that Dependency graph is enabled". This PR adds no dependencies.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 47f1ff7130f79df0e2e44605911154470f122006
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s).
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 426 passed on 47f1ff7. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Holding this PR for a maintainer: head 47f1ff7130 removes a refusal main has, and it must not merge as is.

The regression (Opus 5.5 on 47f1ff7130, src/kiro_crew/security/shell_commands.py:221): the shared reader now reads &> as one redirection, so in the commands below true is the only program and the rm floor never sees the rm.

Command main 83986247 47f1ff7130
true&>x rm -r -f ~ refused allowed
true &>x rm -fr / refused allowed

This is reachable: a cron command passes is_denied and then runs under /bin/sh, which is dash on Debian and Ubuntu. Dash has no &>; it runs true in the background and then runs >x rm -r -f ~. Opus's repro: dash -c 'true&>x rm -r -f victim' deleted victim.

Suggested fix (Opus): have rm_floor._segments read the text both ways, once with &> as a redirection and once with & as a cut, and join the targets, as the ${…} tracking already does. Readings may add refusals, never remove one.

Why we pause: this is the fifth review round on the same seam (the rm floor's nested read and the shared reader's operators). The retro and design are on #22756, and the remaining equal-to-main shapes are tracked in #25477. The PR is set to draft until a maintainer rules on the fix and the approach.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Hold lifted. The PR is ready for review again on head a440b04dcb.

What changed: the Opus finding on 47f1ff7130 (true&>x rm -r -f ~ was refused on main but allowed here, and dash runs the rm). rm_floor._segments now reads the text both ways: once with &> as one redirection (bash), and once with &> split into & then > (dash). The segments of both readings are joined, so the second reading can only add refusals. Text without &> is read once, as before.

Test: test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads::test_a_glued_amp_redirect_still_refuses_the_dash_wipe. It fails on 47f1ff7130 and passes here.

Other updates: the rm floor paragraph in docs/system-specs/modules/security.md names the two readings; _PACKAGE_LINE_BUDGET is 32,972 (+2); the PR body table has the new row. Rebased onto 0f277f1511 (a docs-only change on main).

Gates: scoped security tests 427 passed; black, flake8, mypy, comment-history and docs-lint clean; prove.py PROVEN on a440b04dcb; push guard SAFE TO PUSH.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a440b04dcbcb9c26a25f7921a827c0ee8feb45c4
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 427 passed on a440b04. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e1e4b84220d292ced45d1869f050bbaca7a46a67
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 428 passed on e1e4b84. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: fae987e8fff1a9131c8933ffa7d117ea733b4195
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 428 passed on fae987e. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: conflict with main in test/test_security_gate_liveness.py (the security package line budget). Kept main's note and value (32,802) and added this PR's +174, so the budget is 32,976, equal to the measured package size. No code change. New head 3c004c07e7 on main e0c36aed59; prove.py PROVEN on this head.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 3c004c07e7b0c66e8e078c17f6656c82aca03d25
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 428 passed on e1e4b84. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

Sensitive change review

  • Head commit: 3c004c07e7b0c66e8e078c17f6656c82aca03d25
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 428 passed on d6cde7e1a5, the same PR files as 3c004c0. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: redirect_free_views re-read cmd.argv once per redirect

  • span=e0f4af479de1 Redirect filtering repeatedly rebuilds the entire command

fixed in a1587b70a303: redirect_free_views splits each command once with cmd._parts(); the test is now one comparison, the last argv start against the first redirect end, so it is linear in redirects.
Same verdict as before: argv and redirects are in text order, so "some argv word starts after some redirect ends" is the same as "the last argv word starts after the first redirect ends".
2,000 >x redirects through is_denied: 0.87 s, against 0.85 s on main (24 s before).
Test: TestRmFloorReadsNestedShellPayloads::test_many_redirects_split_each_command_once counts the splits (1 now, 2,001 on the old head); a count, not a wall clock, so it cannot flake.

This replaces #22719 (comment), whose marker was malformed; the reasoning is unchanged.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none; a script piped into a shell is not read on main either

  • span=e8aa6e56f6f9 Command splitting loses executable pipeline payloads

accepted-and-deferred to #25477: every cited shape is allowed on main 0f277f1511 and on this head, so this PR is not weaker than main on any of them.
Rows (main / this PR, both allowed): echo '<home wipe>' | sh, ... |& sh, ... | (sh), printf '%s' '<home wipe>' | bash, ... |& bash, ... | (bash), echo "bash -c '<home wipe>'" | sh, and the same inside bash -c "...".
Two earlier rounds of this PR read pipes (a pipe join, then a whole-line read); both over-refused ordinary pipelines (| tee x; sh run.sh) and were removed, so the pipe case gets its own design in #25477.
This is a security-class finding, so no override is posted; a maintainer rules on it.

Issue: #25477 (the row list is in #25477 (comment)).

This replaces #22719 (comment), whose marker was malformed; the reasoning is unchanged.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: redirect_hidden_payloads adds each redirect-free view's payloads to the walk

  • span=5e784cc06287 Redirect views treat printed payloads as executable commands

Rebutted: a false-positive refusal for a rare edge case, not a bypass. The PR is stricter here, never looser.
On this head the redirect form gets the same verdict main already gives the same command with no redirect.
On main the redirect only hid the script from the walk, which is the bug this PR fixes.
The data-consumer fix inside each view would take the PR past its 175-line production cap, so it is not taken here.
No override is posted by the author; this is security-class, so a maintainer rules on it.

Command main this PR
echo bash -c '<publish to main>' refused refused
echo bash -c >/dev/null '<publish to main>' allowed refused
echo bash -c 'pkill -f x' allowed allowed

<publish to main> stands for a git push to the protected branch. Both verdicts were checked with is_denied on main 33834b909a and on e1e4b84220.

This replaces #22719 (comment), whose marker was malformed; the reasoning is unchanged.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none new; the here-string gap predates this PR

  • span=e8aa6e56f6f9 A here-string still hides the executable -c operand

needs-a-decision: the finding is real (bash runs the script after <<< word), and it already exists on main e0c36aed59; this PR does not make it worse.
Every here-string row is allowed on main and on this head; the plain and 2>-redirect rows go from allowed on main to refused here.
This is the sixth finding on the same redirect-before--c seam, so the PR is paused under the same-seam rule until a human decides.
Security-class: no override is posted by the author.

Command main this PR
bash -c '<wipe>' allowed refused
bash -c 2>/dev/null '<wipe>' allowed refused
bash -c <<< harmless '<wipe>' allowed allowed
bash <<< harmless -c 2>/dev/null '<wipe>' allowed allowed
bash -c 2>/dev/null <<< harmless '<wipe>' allowed allowed

<wipe> stands for a recursive-force delete of home. Verdicts are is_denied on main e0c36aed59 and on 3c004c07e7.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: the shared reader stopped at <<< as if it were a heredoc

  • span=e8aa6e56f6f9 A here-string still hides the executable -c operand

fixed in 4c4668b: the reader stops only at a << that is not part of <<<; a <<< is a redirection with one target word, so the script after it is the -c operand.
A command holding <<< is also read with its own raw words, so bash <<< '<wipe>' stays refused.
Tests: TestRmFloorReadsNestedShellPayloads::test_a_herestring_hides_no_script (the 3 cited rows, failing before the fix) and test_a_harmless_herestring_stays_allowed.
9 other shapes remain (a heredoc or a flag between -c and the script); every one is also open on main and is tracked in #25814.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4c4668b4d275daf2a0ca2dfd97170b407c0078f9
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). A <<< herestring is a redirection with one target word, not a heredoc stop, so it hides no -c script; a command holding one is also read with its raw words, so bash <<< '<script>' stays read. The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 434 passed on 4c4668b. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: d2a334d6e43e5bf6a680c605f5cf2f38170381f2
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). A <<< herestring is a redirection with one target word, not a heredoc stop, so it hides no -c script; a command holding one is also read with its raw words, so bash <<< '<script>' stays read. The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 434 passed on 1e52022940, the same PR files as d2a334d. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: conflict with main in test/test_security_gate_liveness.py (e511845 -> d328624); CI re-running.

The conflict was the security package line budget only. Main's new note and its raise are kept; the budget is set to the measured 33,086 (main's tree measures 32,909, plus this PR's 177). No code change. Scoped tests: 434 passed; prove.py PROVEN. The 40-shape probe still shows 0 shapes opened against main; 30 closed and 10 equal to main, the 10 being the heredoc and flag shapes in #25814.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none new; the nested payload reader reads &> the bash way, as on main

  • span=e8aa6e56f6f9 Bash-only command splitting exempts a wipe executed by dash

Rebutted: not a regression. Every cited row is allowed on main d32862446c and on this head, so this PR is not weaker than main on any of them.
The outer reading already splits &> both ways (true&>x <wipe> is refused); the nested reader's bash-only reading is unchanged from main.
Tracked with the other same-class shapes in #25814 (rows in #25814 (comment)).
The PR's production-line cap is spent; closing it here would grow the PR again on the same seam.
Security-class: no override is posted by the author; a maintainer rules on it.

Command main this PR
dash -c "echo&>/dev/null sh -c '<wipe>'" allowed allowed
dash -c "cat&>/dev/null sh -c '<wipe>'" allowed allowed
echo&>/dev/null sh -c '<wipe>' allowed allowed
true&>x <wipe> refused refused

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

The Backend Tests (3.12, 2) and Backend Tests (Windows) (2) reds on d2a334d6e4 are main's, not this PR's. Each shard fails exactly these 2 tests, both part of the main break tracked in #25937 (fix: #25947):

  • test/test_dir_fd_create_race_ratchet.py::test_no_lock_file_is_created_with_a_nonexclusive_open
  • test/test_subagent_prompt_hooks.py::test_hook_time_is_not_charged_to_the_first_prompt_watchdog

Coverage Gate is red only because those shards failed. No rerun or push for these; this PR rebases once after #25947 merges.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased onto the #25947 and #25944 fixes for the main-only reds; CI re-running.

New head 49c6590050 on main 1fc4b3ae9f. The only conflict was the security package line budget: main's note is kept and the budget is 33,086 (main's measured 32,909 plus this PR's 177). No code change. Scoped tests: 434 passed; prove.py PROVEN. The 40-shape probe still shows 0 shapes opened against main (30 closed, 10 equal to main, tracked in #25814), and the dash &> rows are equal to main.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 49c65900503588d3dd64007a5ad31c8359a3ebaa
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). A <<< herestring is a redirection with one target word, not a heredoc stop, so it hides no -c script; a command holding one is also read with its raw words, so bash <<< '<script>' stays read. The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 434 passed on 49c6590. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: PR was CONFLICTING with main; CI re-running.

New head 38577b84c3 on main f369225a20. The only conflict was the security package line budget: main's note is kept and the budget is 33,147 (main's measured 32,970 plus this PR's 177). No code change. Scoped tests: 434 passed.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 38577b84c33161f98df34a7bddb31f2eab9287c3
  • What rule changed: the rm floor (rm_floor.py, called from deny_gate.py) now reads every nested shell payload. It takes each command from the shared reader shell_commands.read_commands, so a live && / & glued to a word ends the command. A new reader helper, shell_commands.redirect_free_views, renders each command without its redirections; the deny views and shell_normalizer._shell_payload_walk (self-protection and git-publish floors) walk those views as extra frames, so a redirect before the -c operand hides no script. The shared reader reads &>, &>> and >| as one redirection (&&> stays a separator), and no raw-text filter decides which frame is read: a frame holding a < or > is read by the reader itself (continuations folded, no nested bodies), so a quoted or escaped carrier flag (bash "-c", bash -\c, env "-S") hides nothing. Both walks share one view result per frame within one is_denied call. Ordinary commands cost +0.16 to +0.35 ms over main; deep nesting with a redirect at every level is about 8% slower. The rm floor no longer drops single quotes from a payload, so a quoted ; stays data; a single-quoted $HOME in a double-quoted payload is left as on main (rm floor: quote-free payload view over-refuses a quoted ';' in printed text #25385). The rm floor reads each command the shared reader finds, so a glued && ends a command; a script piped into a shell is not read, as on main (rm floor: read nested payload lines with the shared reader (pipelines view) #25477), and ordinary pipelines (| tee x; sh run.sh) stay allowed. Its heredoc handling is one forward pass (5,000 << on a line: 0.25 s). A <<< herestring is a redirection with one target word, not a heredoc stop, so it hides no -c script; a command holding one is also read with its raw words, so bash <<< '<script>' stays read. The redirect view splits each command once, so 2,000 redirects cost 0.87 s, as on main. The rm floor also reads each &> split into & then >, because dash ends the command there (true&>x rm -r -f ~ runs the rm under /bin/sh); both readings are joined, so that case stays refused as on main.
  • Before -> after (what was allowed/blocked, now): before, a nested root or home wipe was allowed (bash -c 'rm -fr ~', bash -c 2>/dev/null '...', echo x&&bash -c '...'). Now the floor refuses those. Harmless nested commands (project-relative deletes, redirected ls, printed echo bash -c '...', heredoc bodies) stay allowed, and a later command's words are no longer read as the script, so bash -c 2>/dev/null 'make lint' && git commit -m '...' is allowed as on main.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): false refusals of ordinary commands. Known fail-closed over-refusal: a single-quoted bash -c 'rm -fr \$HOME'. No secret is exposed and no allow path is widened: every redirect-free view is an extra frame beside the original text.
  • Evidence checked (which sandbox result proves it): is_denied results pinned by the refuse and allow rows in test/test_denied_commands_security_rows.py::TestRmFloorReadsNestedShellPayloads. Probed: the glued && rows are allowed on main and on dd699a4adb, refused here; the commit-message row is refused on dd699a4adb, allowed here and on main. prove.py: PROVEN.
  • No regression:
    • Tools still work (which tools/commands were run, result): main's TestRecursiveForceRmFloor allow rows stay allowed; the reader's own suite test/test_shell_commands_reader.py passes.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or API change. deny_gate keeps its fail-closed read-error path.
    • Existing tests (which suites passed on this head): test_security_gate_liveness.py, test_denied_commands_security_rows.py, test_denied_commands_security.py, test_shell_commands_reader.py: 434 passed on 38577b8. Every test file that imports the shell normalizer, the reader, the rm floor, is_denied or the argv floors: 9,620 passed, 21 skipped on e60afc8 (before the view removal).
  • How to undo: revert this one commit. No data or config migration.

🤖 AI-assisted comment 🤖

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Review-ready on 38577b84c3: GPT 6.1, Opus 5.5, Security Scope Review and PR Readiness are green (readiness: passed), 98 checks with 0 failing. No override was needed on this head. Awaiting a human approval.

The 9 heredoc/flag shapes and the dash &> rows that stay equal to main are tracked in #25814.

🤖 AI-assisted comment 🤖

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Approving at 38577b8.

What this fixes: on main, bash -c 'rm -fr ~' and busybox sh -c 'rm -fr /' passed the recursive-force rm floor, and a redirect placed before the -c operand (sh -c 2>/dev/null '<script>') hid the script from every gate that reads nested payloads. Both now read through the shared quote-aware command reader instead of a new parser or a new regex row, and nothing in the sandbox scope changes.

Checked:

  • CI on this head is green (84 pass, 14 skipping) and the branch merges cleanly into current main.
  • The spec in docs/system-specs/modules/security.md changes in the same diff.
  • Ran the three touched test modules locally: 359 passed.
  • Mutation: switching deny_gate.py back to the top-level-only _rm_wipe_targets fails 59 tests, including test_a_nested_wipe_is_refused_by_the_floor[bash -c 'RM -fr /'].
  • Mutation: dropping the redirect-hidden payloads from shell_normalizer._shell_payload_walk fails 11 tests, including test_a_redirect_hides_no_publish_from_the_git_floor[env -S 2>/dev/null 'bash -c "{}"'].
  • Compared main and this head on everyday commands (bash -c 'make test' 2>&1 | tee log, sh -c "cd /tmp && rm -rf build", a git commit -m or gh pr comment --body that quotes bash -c 'rm -fr ~', ls &>/dev/null && echo ok, sh -c 'rm -rf "$HOME/.cache"'): all still allowed. Only the nested root or home wipes changed to refused.

Follow-ups, not blocking:

  • The per-line argv reader in rm_floor.py reads each line up to eight ways. I did not measure walk time myself; the body's measurement is the evidence for it.
  • _shell_payload_walk imports shell_commands inside its loop to dodge the import cycle; _submodule("shell_commands"), as deny_gate.py does, would match the existing pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants