Skip to content

fix(exec-shell): add zsh/dash/ash/ksh/fish to V1 POSIX shell recognizer - #377

Merged
shanselman merged 2 commits into
openclaw:masterfrom
AlexAlves87:fix/exec-shell-v1-posix-vocabulary
May 14, 2026
Merged

shanselman merged 2 commits into
openclaw:masterfrom
AlexAlves87:fix/exec-shell-v1-posix-vocabulary

Conversation

@AlexAlves87

Copy link
Copy Markdown
Contributor

Summary

ExecShellWrapperParser (V1, the live exec-approval gate) only recognised bash and sh as POSIX shell wrappers. V2 (ExecShellWrapperNormalizer) already included zsh, dash, ash, ksh, and fish, but V1 never received the update.

As a result, a policy with Allow: bash * would not match a zsh -c "..." invocation — the command reached the policy evaluator unwrapped, so neither Allow nor Deny rules for known shells applied reliably.

Changes

  • ExecShellWrapperParser.cs: add zsh, dash, ash, ksh, fish to the POSIX shell branch
  • ExecShellWrapperParserTests.cs: extend the existing Expand_Bash_C_ExtractsPayload theory with the five new shells

Fixes #366.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

V2 (ExecShellWrapperNormalizer) already recognised these shells; V1
(ExecShellWrapperParser), which is the live exec-approval gate, did not.
Policy rules like `Allow: bash *` would not match a zsh invocation.

Fixes openclaw#366.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@shanselman

Copy link
Copy Markdown
Collaborator

Thanks for tightening the V1 shell wrapper vocabulary. One gap before merge: the legacy parser uses Path.GetFileName(tokens[0]) and only strips .exe for shells explicitly listed with .exe variants. This PR adds zsh, dash, ash, ksh, and fish, but not zsh.exe, dash.exe, ash.exe, ksh.exe, or fish.exe.

On Windows those are the executable names we are most likely to see from PATH, so the V1 path can still fail to unwrap the same shells this PR is trying to cover.

Suggested fix: either add the .exe variants in ExecShellWrapperParser, or switch this branch to the same normalized-basename behavior used by V2 (ExecCommandToken.NormalizedBasename) so future POSIX shell names do not need duplicate entries. Please add theory rows for the .exe variants too.

…automatically

Switch TryExtractWrappedPayload from Path.GetFileName + OrdinalIgnoreCase
comparisons to ExecCommandToken.NormalizedBasename, which strips the path,
lowercases, and removes the .exe suffix in one step. This closes the gap
where zsh.exe/dash.exe/ash.exe/ksh.exe/fish.exe (the names most likely to
appear on Windows PATH) were not recognised as shell wrappers.

All existing cmd/powershell/pwsh/bash/sh .exe variants are now covered by
the same path without enumerating them. Add .exe theory rows for the five
new POSIX shells.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@AlexAlves87

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Switched TryExtractWrappedPayload to use ExecCommandToken.NormalizedBasename — that strips path, lowercases, and removes the .exe suffix in one step, so all five new shells and their .exe variants are covered without enumerating them manually. Added theory rows for the .exe forms too.

@shanselman
shanselman merged commit 36f5d24 into openclaw:master May 14, 2026
11 checks passed
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.

[deep-review][duplication] D3: V1 and V2 exec-wrapper detectors have diverged on shell vocabulary and flag handling

2 participants