fix(exec): fail closed on Windows shell wrappers in allowlist mode#67655
Conversation
Greptile SummaryThis PR closes an allowlist-bypass for Windows shell wrappers other than
Confidence Score: 4/5Not safe to merge as-is — a stale test assertion will fail in CI. The security fix itself is correct and the new PowerShell regression test is well written, but the existing formatSystemRunAllowlistMissMessage test was left with a substring that no longer appears in the updated message, which will cause a test failure. That P1 must be fixed before landing. src/node-host/exec-policy.test.ts lines 67–74 — stale .toContain() assertion needs to match the new message text.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d523e57e62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return ( | ||
| "SYSTEM_RUN_DENIED: allowlist miss " + | ||
| "(Windows shell wrappers like cmd.exe /c require approval; " + | ||
| "(Windows shell wrappers like cmd.exe /c or powershell -Command require approval; " + |
There was a problem hiding this comment.
Preserve message compatibility with existing allowlist tests
The updated denial text in formatSystemRunAllowlistMissMessage inserts or powershell -Command between cmd.exe /c and require approval, which no longer matches the existing assertions that still expect the old contiguous phrase (src/node-host/exec-policy.test.ts:67-74 and src/node-host/invoke-system-run.test.ts:25-31). This commit therefore introduces deterministic test regressions unless the dependent checks are updated in the same change or the message keeps a backward-compatible substring.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. Current main is source-reproducible by evaluating allowlist policy with isWindows=true, shellWrapperInvocation=true, and cmdInvocation=false; the guard still requires cmdInvocation today, so the PowerShell wrapper path is not blocked there. Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the prepared fail-closed Windows shell-wrapper policy after adding redacted real runtime proof and letting the exact-head CI complete cleanly. Do we have a high-confidence way to reproduce the issue? Yes. Current main is source-reproducible by evaluating allowlist policy with isWindows=true, shellWrapperInvocation=true, and cmdInvocation=false; the guard still requires cmdInvocation today, so the PowerShell wrapper path is not blocked there. Is this the best way to solve the issue? Yes for the code direction. The prepared head is narrow and aligns policy, denial copy, docs, changelog, and regression coverage, but merge should wait for real behavior proof and completed CI. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 86a9b3fcb1c0. Re-review progress:
|
d523e57 to
3baf42a
Compare
|
Maintainer update: rebased this onto current main and prepared the branch at What changed in the prepared head:
Verification run locally:
Waiting on fresh CI/ClawSweeper for this prepared head before merge. |
Issue
In Windows allowlist mode, the wrapper guard only failed closed for
cmd.exe-style invocations. That left a gap where other shell-wrapper transports such aspowershell -Commandcould still be analyzed like a normal allowlisted command, which is the wrong security posture for inline shell payloads and command chaining.Fix
shellWrapperInvocationis true, instead of limiting the guard tocmdInvocationpowershell -Commandalongsidecmd.exe /csrc/node-host/exec-policy.test.tsHow to test
pnpm test src/node-host/exec-policy.test.ts src/node-host/invoke-system-run.test.ts -t "PowerShell|shell wrapper|cmd.exe wrappers|allowlist"isWindows: true,shellWrapperInvocation: true, andcmdInvocation: falsewindowsShellWrapperBlockedis set, and the error guidance mentionspowershell -Command