Commit Graph
4 Commits
Author SHA1 Message Date
Trung Nguyen dca687987e hooks/builtins: name the resolved shell in the env block
The session_start env block previously named the OS but not the shell.
When the model reads 'Operating System: Windows' it defaults to POSIX
syntax by habit and emits '&&', 'grep', 'head', '2>/dev/null', 'ls -la',
'$(pwd)' — none of which work under Windows PowerShell 5.1 or cmd.exe.
The shell tool description already carries a shell-specific hint
(shellSyntaxHint), but it sits far from the user turn and is drowned
out by the agent's own system prompt; the env block sits at the top
of every turn and is cached, so that is where the disambiguation
belongs.

Resolve the shell via the shared shellpath.DetectShell helper and print
its base name plus the resolved path. Long-form dialect rules stay in
the shell tool description (shellSyntaxHint) so this block stays terse
and doesn't diverge from them.

The base-name derivation lives in a new shellpath.ShellBaseName helper
so the same logic isn't copied into hooks/builtins.

No behaviour change on darwin/linux where the shell defaults to $SHELL
or /bin/sh; the extra 'Shell:' line lands cleanly in the existing
tab-indented env block.
2026-08-31 09:00:17 +02:00
David Gageot 8a109b26a5 fix(shellpath): pass shell exit message via env, validate board worktree before opening a shell
Passes exit message via DOCKER_AGENT_SHELL_EXIT_MSG env var instead of
interpolating into the command line (prevents injection). Uses POSIX printf,
cmd.exe delayed expansion on Windows, dedupes PowerShell lookup. Validates
worktree exists before exec'ing in board TUI.

Assisted-By: Claude
2026-07-07 19:44:21 +02:00
David Gageot 3e3d174967 feat(board): add s shortcut to open a shell in the card's worktree
Assisted-By: Claude
2026-07-07 19:36:04 +02:00
David Gageot 24d947c2da fix: prevent PATH hijacking and TOCTOU in shell/binary resolution (CWE-426)
Introduce pkg/shellpath to centralize safe shell binary resolution:
- WindowsCmdExe() resolves cmd.exe via ComSpec or %SystemRoot%\System32
  instead of bare PATH lookup
- DetectShell()/DetectWindowsShell() use exec.LookPath (absolute paths)
  for PowerShell, falling back to WindowsCmdExe()

Replace vulnerable bare cmd.exe resolution in three critical locations:
- pkg/tools/builtin/shell.go (detectShell)
- pkg/hooks/executor.go (initShell)
- pkg/tui/handlers.go (startShell)

Fix TOCTOU race in credential providers:
- lookupBinary() now returns the resolved absolute path
- KeychainProvider and PassProvider store and reuse the resolved path
  instead of re-resolving bare binary names at invocation time

Assisted-By: docker-agent
2026-03-12 13:25:39 +01:00