You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[deep-review][duplication] D3: V1 and V2 exec-wrapper detectors have diverged on shell vocabulary and flag handling #366
Two shell-wrapper detectors exist, both reachable today, with different shell vocabularies and different PowerShell flag handling.
V1: src/OpenClaw.Shared/ExecShellWrapperParser.cs — string-based BFS, used by the live legacy exec-approval path (SystemCapability.HandleRunAsync → wrapper expansion at lines 374-389).
V2: src/OpenClaw.Shared/ExecApprovals/ExecShellWrapperNormalizer.cs — argv-based single-level, used by the V2 pipeline that's currently inert (ExecApprovalV2NullHandler is the only registered handler).
How they diverged
V2 added: zsh, dash, ash, ksh, fish to the recognized shell list.
V1 handles -EncodedCommand Base64 UTF-16LE decoding and -Cmd:value inline-separator forms. V2 does not (the inline-separator form was apparently dropped intentionally; the -EncodedCommand decoding lives elsewhere in V2 via ExecCommandResolver).
Why it matters
Once V2 ships (the coordinator is wired in), the legacy V1 path stops firing — that's the design. But until then, the live exec gate doesn't recognize zsh/dash/ash/ksh/fish wrappers. An agent invoking zsh -c "rm -rf" reaches the policy evaluator as a literal zsh -c "rm -rf" string match. The default defaultAction: deny saves us, but the policy author who wrote Allow: bash * and Deny: rm * finds neither rule matches a zsh invocation reliably.
Security review filed this as E-6 (depth-4 short-circuiting under nested wrappers) — this duplication is the structural cause.
Proposed fix
Three options, in order of preference:
Promote the shared vocabulary to a single static ShellRegistry.RecognizedShells set with the union of V1 and V2. Both parsers read from it. Eliminates drift by construction.
Backport V2's expanded shell list to V1. Simpler but doesn't address future drift.
Ship V2 and delete V1. Highest payoff, but requires the coordinator wiring that's been pending.
Add an assertion test that walks both parsers' recognized shell lists and asserts they match (or that V1 is a subset of V2).
Severity
Medium — security-relevant duplication; observable as "policy rules don't match zsh wrappers."
Related
C7 (validator gap on execApprovals.set) — defense-in-depth in the same area.
D-V2-coordinator (out of scope for this review, but addressing the V2 rollout dissolves several items).
Activity
AlexAlves87 commentedon May 14, 2026
Picking this up. Will backport zsh/dash/ash/ksh/fish from V2 (ExecShellWrapperNormalizer) to V1 (ExecShellWrapperParser) to close the vocabulary gap.
fix(exec-shell): add zsh/dash/ash/ksh/fish to V1 POSIX shell recognizer