T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/homebrew/setup.sh:145
- Finding
- Unverified Homebrew Installer Is Downloaded and Executed Directly<![CDATA[ ## Vulnerability Details **File Location**: `scripts/homebrew/setup.sh:145-151` **Vulnerability Type**: Unverified remote payload retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```bash install_homebrew_with_mirror() { local mirror_name="$1" local mirror_url="${BREW_MIRRORS[$mirror_name]}" log_info "Installing Homebrew with $mirror_name mirror..." # Set environment variables for install script export HOMEBREW_BREW_GIT_REMOTE="${mirror_url}/brew.git" export HOMEBREW_CORE_GIT_REMOTE="${mirror_url}/homebrew-core.git" # Run official installer /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` ### Technical Analysis When Homebrew is not present, the script retrieves a shell program from a mutable GitHub `HEAD` URL and immediately executes the response with `/bin/bash`. There is no version pinning, cryptographic signature validation, checksum verification, content inspection, or separation between retrieval and execution. Although the URL is the official Homebrew installer location and HTTPS protects the network transport, the effective code executed can change after this Skill has been reviewed. Compromise of the upstream repository, maintainer account, hosting platform, DNS/PKI path, or delivery endpoint could therefore turn this command into arbitrary code execution. This behavior exceeds the minimum privileges and actions necessary to configure a Homebrew mirror. Mirror configuration can be performed without automatically installing Homebrew, and installation should be a distinct, explicitly approved operation. ### Attack Path 1. A user invokes the Homebrew mirror setup script. 2. `setup_homebrew_mirror` determines that `brew` is not installed. 3. The script enters `install_homebrew_with_mirror`. 4. `curl` retrieves the current contents of the mutable `HEAD/install.sh` resource. 5. The response is substituted directly into `/bin/bash -c`. 6. ...[truncated 738 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not pass a network response directly to a shell. 2. Keep mirror configuration separate from Homebrew installation; if Homebrew is absent, stop and provide safe manual instructions. 3. If automated installation is required: - Pin the installer to a reviewed release or immutable commit. - Download it to a securely created temporary file. - Verify a publisher-provided signature or a pinned SHA-256 digest. - Display the source, version, digest, and intended operation to the user. - Require explicit confirmation immediately before execution. - Execute with ordinary user privileges and allow privilege elevation only for narrowly scoped commands. 4. Remove the temporary file after execution and report exactly what was changed. 5. Prefer a package or installer distribution mechanism that provides signed, versioned artifacts. ]]>
