Skip to content

Expand tilde manually in TUI#4827

Merged
mcastorina merged 2 commits intomainfrom
fix/tui-command-injection
Mar 20, 2026
Merged

Expand tilde manually in TUI#4827
mcastorina merged 2 commits intomainfrom
fix/tui-command-injection

Conversation

@mcastorina
Copy link
Contributor

@mcastorina mcastorina commented Mar 20, 2026

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Note

Medium Risk
Changes how the TUI restarts the program by removing the sh -c indirection and manually expanding ~, which could affect argument parsing/quoting and path handling. Scope is limited to the TUI launch path but impacts process execution behavior.

Overview
When launched via the TUI, the app now re-execs the current binary directly instead of building a command string and running it through sh -c, reducing shell injection risk and preserving literal arguments.

Adds expandTilde to manually expand leading ~/~/ in TUI-provided arguments so common home-directory paths continue to work without shell expansion.

Written by Cursor Bugbot for commit 0ba6947. This will update automatically on new commits. Configure here.

bryanbeverly and others added 2 commits March 20, 2026 07:23
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>
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
@mcastorina mcastorina requested a review from a team March 20, 2026 14:28
@mcastorina mcastorina merged commit 6c64db9 into main Mar 20, 2026
14 checks passed
@mcastorina mcastorina deleted the fix/tui-command-injection branch March 20, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants