Commit 8d8aa53
committed
fix(security): prevent command injection in test-hook.sh
The test-hook.sh script had a command injection vulnerability where
the hook script path was used unquoted in a bash -c context:
output=$(timeout "$TIMEOUT" bash -c "cat '$TEST_INPUT' | $HOOK_SCRIPT")
This allowed potential code execution if a malicious path was provided.
Changes:
- Add input validation to reject paths with shell metacharacters
- Use a flag to track executable status instead of modifying the path
- Use proper argument passing via bash -c positional parameters
- Arguments are now safely passed as $1 and $2 instead of string concat
The fix uses the pattern:
bash -c 'cat "$1" | "$2"' -- "$TEST_INPUT" "$HOOK_SCRIPT"
This ensures paths are treated as literal strings, not shell code.1 parent 1af7555 commit 8d8aa53
1 file changed
Lines changed: 18 additions & 2 deletions
Lines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
144 | 154 | | |
145 | 155 | | |
146 | | - | |
| 156 | + | |
147 | 157 | | |
148 | 158 | | |
149 | 159 | | |
| |||
187 | 197 | | |
188 | 198 | | |
189 | 199 | | |
190 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
191 | 207 | | |
192 | 208 | | |
193 | 209 | | |
| |||
0 commit comments