Skip to content

fix: use absolute paths for credential helper binaries to prevent PATH hijacking#236

Draft
bukinoshita wants to merge 1 commit intomainfrom
fix/credential-path-hijack-e834
Draft

fix: use absolute paths for credential helper binaries to prevent PATH hijacking#236
bukinoshita wants to merge 1 commit intomainfrom
fix/credential-path-hijack-e834

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Use absolute paths for credential helpers on Linux and Windows to prevent PATH hijacking and protect Resend API keys. Addresses Linear BU-627.

  • Bug Fixes
    • Linux: Resolve secret-tool from trusted paths (/usr/bin, /usr/local/bin, /bin), fall back to /usr/bin/which, reject non-absolute results, and cache the resolved path. All calls (get, set, delete, isAvailable) now use absolute paths.
    • Windows: Build an absolute PowerShell path from %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe, defaulting to C:\Windows if unset. Use this path for both execFile and spawn.
    • Tests: Added Linux tests for resolution, fallback, rejection, caching, and absolute path usage. Updated Windows tests to assert absolute PowerShell path and stdin usage. MacOS unchanged (/usr/bin/security).

Written for commit 00723e3. Summary will update on new commits.

…H hijacking

Resolve secret-tool (Linux) and powershell.exe (Windows) to absolute
paths before execution, preventing local PATH hijacking attacks that
could steal Resend API keys.

Linux:
- Check trusted paths (/usr/bin, /usr/local/bin, /bin) first
- Fall back to /usr/bin/which for resolution
- Reject non-absolute paths from which output
- Cache resolved paths for subsequent calls
- Use absolute /usr/bin/which instead of bare 'which' in isAvailable()

Windows:
- Construct absolute PowerShell path from %SystemRoot% env var
- Default to C:\Windows if SystemRoot is not set

Closes BU-627

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
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.

2 participants