T03 · Remote Payload Retrieval and Execution
- Location
scripts/setup.sh:21- Finding
Unverified Remote Installer Is Piped Directly Into a Shell
- Content
View full analysis
/dev/null 2>&1; then log "未检测到 uv,开始自动安装..." command -v curl >/dev/null 2>&1 || fail "安装 uv 需要 curl,请先安装 curl。" curl -LsSf https://astral.sh/uv/install.sh | sh export PATH="$HOME/.local/bin:$PATH" command -v uv >/dev/null 2>&1 || fail "uv 安装完成,但当前 shell 仍无法找到 uv。" fi ``` ### Technical Analysis Line 25 downloads a mutable response from `https://astral.sh/uv/install.sh` and passes it directly to `sh`. No pinned version, expected checksum, cryptographic signature, or local inspection step is used before execution. Although `astral.sh` is the expected upstream distribution site for `uv`, HTTPS authenticates only the endpoint at connection time; it does not ensure that the downloaded content matches a previously reviewed installer. A compromise of the upstream website, DNS or certificate infrastructure, deployment pipeline, or associated distribution account could replace the response with arbitrary shell commands. The downloaded script executes with all permissions of the user running `scripts/setup.sh`. Installing `uv` is relevant to the declared functionality, but executing an unverified, mutable shell payload is not the minimum-risk mechanism necessary to perform that installation. ### Attack Path 1. An attacker compromises the installer endpoint, its deployment pipeline, or another component of its delivery chain. 2. The user invokes `bash scripts/setup.sh` on a system where `uv` is unavailable. 3. `curl` retrieves the attacker-controlled response. 4. The shell pipeline immediately executes the response without verification or user review. 5. The payload performs arbitrary actions with the invoking user's privileges. ### Impact Assessment Successful exploitation provides arbitrary command ex ...[truncated 657 chars]- Remediation
View remediation
" curl --fail --location --proto '=https' \ --output uv-release.tar.gz \ "https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/" echo " uv-release.tar.gz" | sha256sum --check - # Extract and install only after successful verification. ``` The version, artifact name, and checksum must be fixed to values obtained from the trusted release metadata rather than dynamically accepted from the download endpoint. ]]>
