Commit ade6207
committed
fix(cli): prevent ZX_* control-plane injection via --env file
loading a .env file via --env merges its contents into process.env, which
resolveDefaults() then blindly promotes into live execution settings. An
attacker who can modify the .env file (supply-chain PR, compromised dep) can
set ZX_PREFIX/ZX_POSTFIX/ZX_SHELL to arbitrary shell code that runs for every
call in an otherwise-trusted script.
Fix: snapshot ZX_* keys present in process.env before dotenv.config() runs,
then purge any ZX_* key introduced by the file before resolveDefaults() sees
the environment. Legitimate ZX_* variables set by the operator (e.g. from the
shell that launched zx) are preserved; only file-injected ones are stripped.
Reported-by: LAKSHMIKANTHAN K (letchupkt)
CWE: CWE-94 / CWE-77 (Command Injection)1 parent 98531fc commit ade6207
1 file changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
115 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
| |||
0 commit comments