Commit 6c64db9
Expand tilde manually in TUI (#4827)
* Fix command injection vulnerability in TUI
The TUI was building a command string from user input via string
concatenation and passing it to `sh -c` through syscall.Exec. This
allowed shell metacharacters in any TUI input field (git URI, file
path, tokens, etc.) to be interpreted as shell commands.
Replace the `sh -c` invocation with a direct syscall.Exec of the
trufflehog binary, passing arguments as a proper argv array. This
eliminates shell interpretation entirely.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Add tilde expansion for TUI args after removing shell layer
Since sh -c was removed to fix command injection, ~/foo paths entered
in the TUI are no longer expanded by a shell. This adds a narrow
expandTilde helper that replaces a leading ~ with os.UserHomeDir()
before exec, restoring path resolution without reintroducing any
shell interpretation.
Guards against empty $HOME to prevent ~/foo silently resolving to /foo.
Made-with: Cursor
---------
Co-authored-by: Bryan Beverly <bryan.beverly@trufflesec.com>
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent afd5336 commit 6c64db9
1 file changed
+30
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
283 | 305 | | |
284 | 306 | | |
285 | 307 | | |
| |||
308 | 330 | | |
309 | 331 | | |
310 | 332 | | |
311 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
312 | 339 | | |
313 | 340 | | |
314 | 341 | | |
315 | | - | |
316 | | - | |
| 342 | + | |
| 343 | + | |
317 | 344 | | |
318 | 345 | | |
319 | 346 | | |
| |||
0 commit comments