Commit 0ba62e5
fix(core): replace unsafe cmd.exe fallback with PowerShell on Windows
When bash is absent, zx silently fell through to child_process with
shell:true — which on Windows means cmd.exe. cmd.exe does not interpret
bash-style ANSI-C quoting (\$'...''), so every interpolated argument is a
straight injection vector: '& calc &' passes through the quoting layer
unmodified and the metacharacters are executed by cmd.exe.
Fix: make the bash-not-found path Windows-aware.
- Probe PATH for pwsh then powershell.exe in order of preference.
- If a PS shell is found, use it with the matching quotePowerShell quoting
convention and the '; exit \0' postfix.
- If no safe shell is found at all on win32, throw a Fail with a clear
diagnostic rather than silently executing in an insecure context.
- Non-Windows platforms retain the prior (acceptable) behaviour.
- Explicit shell/prefix/postfix CLI overrides are still honoured after
auto-detection runs.
Reported-by: LAKSHMIKANTHAN K (letchupkt)
CWE: CWE-78 (OS Command Injection)1 parent 98531fc commit 0ba62e5
1 file changed
+32
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
1025 | | - | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
1026 | 1028 | | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1030 | 1057 | | |
1031 | | - | |
| 1058 | + | |
1032 | 1059 | | |
1033 | 1060 | | |
1034 | 1061 | | |
| |||
0 commit comments