Skip to content

security: PATH injection vulnerability in install.sh symlink creation #3009

@louisgv

Description

@louisgv

Severity

HIGH

Location

sh/cli/install.sh, lines 114-132

Issue

The script resolves the bun binary path using command -v bun without validation, then symlinks it to /usr/local/bin/bun with sudo:

bun_path="$(command -v bun 2>/dev/null || true)"
if [ "$spawn_in_path" = false ]; then
    # ... various sudo symlink operations using $bun_path ...
    sudo ln -sf "$bun_path" /usr/local/bin/bun 2>/dev/null || true
fi

Attack Scenario

If an attacker controls the user's PATH environment variable (e.g., via a compromised .bashrc or through a previous attack), they can:

  1. Place a malicious bun binary in a directory early in PATH
  2. The install script will resolve to the malicious binary
  3. The script will symlink the malicious binary to /usr/local/bin/bun with sudo
  4. All future invocations of bun (including by spawn itself) will execute the malicious code with elevated privileges

Recommendation

Before symlinking, validate that the bun binary:

  1. Is located in an expected directory (e.g., ~/.bun/bin/, /usr/local/bin/)
  2. Has a valid signature or checksum
  3. Is owned by root or the current user (not a random user)

Example:

bun_path="$(command -v bun 2>/dev/null || true)"
case "$bun_path" in
    "$HOME/.bun/bin/bun"|/usr/local/bin/bun)
        # OK - expected location
        ;;
    *)
        log_warn "bun found at unexpected location: $bun_path"
        bun_path=""
        ;;
esac

Impact

Privilege escalation if an attacker can control the user's PATH before the install script runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in-progressIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processingsecuritySecurity vulnerabilities and concerns

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions