Skip to content

feat(guardrails): deny a decoder feeding an execution sink - #11515

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-9763-41188562738-1
Oct 31, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-9763-41188562738-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #9763

Summary

Opened by the work-resolve-issue lane. The run's own summary:

block-root-delete-target now refuses a decoder feeding an execution sink outright, whatever the decoded text targets, and an attended session is denied too. On the Bash tool the decoders are base64/base32/basenc -d and xxd -r, and the sinks are a stdin shell, source /dev/stdin, eval, a -c operand, a here-string program, bash/source <(...), a substitution in command position, and a command interpreter code runs. On the PowerShell tool it is [Convert]::FromBase64String reaching iex/Invoke-Expression. Decoded output sent to a file or a pager passes, and so does a decoder named in quoted prose. Design choice: the Outcome says 'denied outright, whatever the target', so the guard decodes nothing. I read the done-when's per-root deny/allow cases this way: deny cases are payloads that decode to deletes of /, $HOME, outside the roots, and inside the tree (all refused), and allow cases are decoded output written to a file strictly inside the git toplevel, the scratchpad or an allowed root. The sink detection reuses the guard's existing 'the command before is read as a pipe into this one' model, because the shared tokenizer reports no operators between segments. The known false positives and the gaps that follow from that are declared in the header.

Not verified

  • scripts/run-test-file.sh plugins/guardrails/hooks/block-root-delete-target.test.sh was not executed: this lane runs no test runner or interpreter. The new cases were traced by reading the code (by me and by the review subagent), not run. Left to the PR's CI
  • scripts/run-test-file.sh plugins/guardrails/hooks/run-guards.test.sh (including the #4528 long-command ceiling case) was not executed here; left to the PR's CI. The new per-segment work skips segments that hold no decoder word and read no decoded text, to keep that case's cost flat
  • scripts/check-changelog-fragments.sh --check-required origin/main as the issue spells it was not run; the lane's check-changelog-fragments wrapper ran and passed. Left to the PR's CI
  • tidy skipped: the change is about 440 changed lines, over the 300-line tidy cutoff
  • Declared gaps the review raised and this PR does not close: a heredoc a shell reads as its program whose body decodes (bash <<EOF over $(base64 -d x), cat <<EOF | sh), and a backtick after a launcher (sudo ...). Both are listed in the guard header and the README row
  • The Bash|PowerShell row's added wall time was not measured; per the recorded decision it is tracked under #5946 as a host-run item
  • The working tree also lists untracked .bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile and .zshrc at the checkout root. This run did not create them (they look like sandbox mount placeholders), and they are not part of this change

Fix

  • plugins/guardrails/hooks/block-root-delete-target.sh: new DECODER SINKS arm (rdt_dec_class tracks decoded stdout across segments; rdt_sink_check judges shells, source and eval and opens a sink for substitution-supplied programs; rdt_ps_decoded tracks FromBase64String taint through PowerShell levels
  • plugins/guardrails/hooks/block-root-delete-target.test.sh: section 2l. 35 Bash forms x 4 payloads (decoding to deletes of /, $HOME, outside the roots, inside the tree) all deny. Decoded output to a file inside the toplevel, the scratchpad and an allowed root, pager, quoted-prose and script-operand c
  • plugins/guardrails/README.md: guard row lists decoder sinks as covered and adds their gaps to Not covered; Hook budget accounting paragraph for #9763 states the k (no added process; prefilter cost only)
  • .changes/guardrails/feat-9763-decoder-sinks-5c2e9a17.md: minor changelog fragment (written by hand: the new-changelog-fragment wrapper refused on a detached HEAD)

Verification

The runner ran each check from the base copy against 97b8ab3:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: All 42 changelog fragment(s) under .changes/ are valid
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: 12 passed, 6 skipped over 4 changed files (shellcheck failed twice first, on an SC2128 name clash and an SC2016 directive placement; both fixed and rerun)
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/verify/bin/cant-fail-scan --file plugins/guardrails/hooks/block-root-delete-target.test.sh --lines 2687-2810 --check: PASS, no gating findings
  • fresh-context review subagent over the whole diff (read-only trace): every section 2l deny and allow case traced to the expected exit, no regression in existing cases, no set -u or scope bugs. It found six bypasses, fixed here: taint now flows through any non-pager stage, nested -c/eval parses inher
  • git-read diff --numstat HEAD plus the untracked fragment: 4 files, about 440 changed lines, 1 area (plugins/guardrails)
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41188562738

Left out: the items under Not verified.

Related

#9763

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 97b8ab315f1d6341083f70b70b4b64c7cc792f2e: 0 finding(s), 0 as inline comments.

No security findings. critical-findings: 0

I read the full diff, 669 lines across 4 files. The PR adds a decoder-sink arm to the block-root-delete-target guard, in the hook script, its test, the README and a changelog fragment. No plugin.json or marketplace.json changed, so there are no manifest lines to report.

What I checked

  • Direction of change. The change only adds refusals. The prefilters now also pass commands naming base64, base32, basenc, xxd or FromBase64. No existing deny, ask or allow path is removed or narrowed, and no allowlist or userConfig default changes.
  • Refusal path. The new decoder-sink form is not in the list of forms that ask when the session is attended (block-root-delete-target.sh around line 940). It falls through to printf ... >&2; exit 2, so it denies in attended and unattended sessions alike, as the PR claims.
  • Scoping of new state. rdt_dec_feed, rdt_sink and rdt_dec_prev are declared local in rdt_parse and rdt_segment. rdt_scan_body resets the feed to 0. A nested parse of an eval or -c text inherits the feed from the calling segment. I found no way for a command to clear the taint of an earlier segment.
  • Trusted paths. None of the 4 changed files matches the trusted-path globs. The hook is a guard that fails closed (decoder sinks exit 2), so I did not treat it as a control that lets more through.
  • Declared gaps. The header and README list gaps that remain open. These include decoded text carried through a variable (x=$(base64 -d f); eval "$x"), unnamed decoders such as openssl base64 -d, powershell -EncodedCommand, and a heredoc a shell reads as its program. They are the guard's known limits as a text-matching deterrent, not something this diff introduces. The base guard has no decoder coverage at all.
  • PR context. The context file contains no embedded directives aimed at the reviewer.

Not verified

  • I could not run the test suite. By the PR's own account, nothing in this change was executed.

Spend

  • None. No workflow, schedule, model or billing setting changes.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 97b8ab315f1d6341083f70b70b4b64c7cc792f2e: 0 finding(s), 0 as inline comments.

Code review: PR #11515 (decoder feeding an execution sink, block-root-delete-target)

I found no blocking or advisory findings. This is a read-only trace of the diff. I ran no tests, because this lane has no shell. The author states the test files were not run either, so that gap is for the PR's CI.

What I checked

  • Hard deny in attended sessions. The new decoder-sink form is not in the hook::refuse case list in rdt_block (block-root-delete-target.sh ~L940). It therefore falls through to exit 2, so an attended session is denied too, as the PR says. The test file asserts this.
  • Taint propagation. rdt_dec_prev is read from the enclosing segment's rdt_dec_feed. A -c operand or eval text parsed inside a fed segment inherits the feed, which covers ... | sh -c sh. rdt_scan_body resets the feed to 0 for substitution bodies. A < redirect on fd 0 clears the feed. A > redirect on fd 1, -o or --output, and xxd's second operand all stop a decoder from being treated as writing decoded text to stdout. Pagers (less, more, most) pass nothing on.
  • Sink detection. The shell and source option walk in rdt_sink_check reads -c, -s, -- and a script operand correctly. bash script.sh and base64 -d x | bash build/x.sh stay allowed. The A || B && C precedence in the source and shell branches evaluates as (A || B) && C, which is what is intended.
  • Parse state. rdt_sink is local to rdt_parse. It is set by rdt_sink_check through dynamic scope, and rdt_segment checks it before rdt_check_segment, so a decoder is judged only against sinks opened earlier in the parse.
  • PowerShell. The __svd save/restore keeps taint across nested ( and $( levels. A later group in the same statement cannot consume or lose an earlier group's taint. A decoded value in one statement does not reach iex in a following statement unless a pipe connects them.
  • Prefilters. All four are widened consistently: the main Bash filter, rdt_ix_code, rdt_scan_body and the parallel word check. The PowerShell prefilter gains *frombase64*.
  • Docs and changelog.
    • The changelog fragment (bump: minor) fits an added refusal class.
    • The README row, the header's coverage and gap lists, and the Hook budget accounting paragraph (k unchanged, prefilter cost only) match the code.
    • No pre-existing gap line for this mechanism existed to drop.
    • The measured wall time is deferred to feat(guardrails): extend delete scoping to find, xargs, rsync and other deleters #5946, as the issue's decision comment says.

Closing issue #9763 criteria

  • New deny and allow cases. Section 2l adds the deny cases for /, $HOME, outside the tree and inside the tree, and the allow cases for the tree, scratchpad and allowed root. The allow cases are decoded output written to a file there, which the guard never decodes. Met by inspection, not run.
  • Quoted prose. The git commit -m and echo '...' cases stay allowed.
  • File or pager output. The file and less/more cases are allowed.
  • Header and README. Both list the mechanism as covered.
  • run-guards.test.sh and the guardrails: Bash|PowerShell PreToolUse row takes 30+s on a ~70 KB command; its 60s timeout fails open #4528 ceiling case. Not run by this review and not verifiable here. The author says they were left to CI.
  • --check-required origin/main. Not run here. The author says it was left to CI.

Behavior to know about (declared in the header, not defects)

  • The guard treats ; and && as a pipe when tracking decoded output. base64 -d x; ls; bash is refused.
  • After an unquoted substitution that an eval, -c or source runs, any later bare decoder is refused. For example, eval "$(direnv export bash)"; echo $T | base64 -d is refused.
  • Not covered:
    • interpreters that read their program from stdin (base64 -d | python3)
    • variable or file carriage of decoded text
    • decoders behind a launcher
    • heredoc shells

Cost: no billed-resource change; the diff touches only a hook, its tests and docs.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 97b8ab315f1d6341083f70b70b4b64c7cc792f2e.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 9128915 Oct 31, 2026
50 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-9763-41188562738-1 branch October 31, 2026 10:36
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.

feat(guardrails): deny a decoder feeding an execution sink

0 participants