T03 · Remote Payload Retrieval and Execution
- Location
- cli/scripts/download_release_binary.sh:68
- Finding
- Remote Binary Is Downloaded and Executed Without Cryptographic Authenticity Verification<![CDATA[ ## Vulnerability Details **File Location**: `cli/scripts/download_release_binary.sh:8, 48-57, 68-91`; execution continues through `cli/scripts/run_release_binary.sh:43-59` **Vulnerability Type**: Unverified remote payload retrieval and execution **Risk Level**: High ### Vulnerable Code ```bash BASE_URL="${BASE_URL:-https://app.fangcloud.com/sync/vv25/knowclaw/release}" ``` ```bash validate_binary() { local bin_path="$1" local os os="$(uname -s)" if [ "${os}" = "Darwin" ]; then # Avoid executing invalid Mach-O files that may be killed by the kernel. codesign --verify --verbose=2 "${bin_path}" >/dev/null 2>&1 else "${bin_path}" --help >/dev/null 2>&1 fi } ``` ```bash case "$(uname -s)" in Darwin|Linux) zip_name="${file}.zip" zip_url="${BASE_URL}/${zip_name}" tmp_zip="${RELEASE_DIR}/${zip_name}.tmp.$$" tmp_extract_dir="$(mktemp -d "${TMPDIR:-/tmp}/fangcloud-extract.XXXXXX")" trap 'rm -f "${tmp_zip}"; rm -rf "${tmp_extract_dir}"' EXIT echo "Downloading ${zip_url}" curl -fL "${zip_url}" -o "${tmp_zip}" extracted_bin="$(extract_binary_from_zip "${tmp_zip}" "${file}" "${tmp_extract_dir}")" if [ -z "${extracted_bin}" ] || [ ! -f "${extracted_bin}" ]; then echo "Downloaded zip does not contain expected binary: ${file}" >&2 exit 1 fi chmod +x "${extracted_bin}" if ! validate_binary "${extracted_bin}"; then echo "Downloaded binary is invalid and cannot run: ${zip_url}" >&2 echo "Please update the release artifact at the source URL." >&2 exit 1 fi mv -f "${tmp_zip}" "${RELEASE_DIR}/${zip_name}" cp "${extracted_bin}" "${bin_target}" chmod +x "${bin_target}" ``` The runner subsequently downloads and executes the binary: ```bash is_healthy() { local bin_path="$1" if [ "${os}" = "Darwin" ]; then codesign --verify --verbose=2 "${bin_path}" >/dev/null 2>&1 else "${bin_path}" --help >/dev/null 2>&1 fi } if [ ! -x "${target}" ] | ...[truncated 2981 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Publish a signed release manifest containing the filename, platform, architecture, version, and SHA-256 digest of every artifact. 2. Bundle the trusted public verification key with the Skill and verify the manifest with a mechanism such as Sigstore, minisign, or an equivalent release-signing system. 3. Verify the downloaded archive and extracted binary before setting executable permissions or invoking the binary for any reason. 4. Pin expected artifact hashes or immutable release versions in the reviewed Skill package. Do not rely only on a mutable URL. 5. Remove the production `BASE_URL` override, or enforce an explicit allowlist requiring the exact HTTPS scheme, hostname, port, and path prefix. 6. On macOS, require a designated code-signing identity or expected Apple Team ID and verify notarization rather than accepting any structurally valid signature. 7. On Linux, replace the executable `--help` health check with non-executing format and architecture checks performed only after signature and digest verification. 8. Validate ZIP entries and reject symlinks, unexpected paths, duplicate expected filenames, and archives containing multiple matching binaries. 9. Publish the CLI source and reproducible build instructions so the effective executable can be reviewed and independently reproduced. 10. Execute the CLI with a minimized environment and only provide the specific credential required for the requested operation. ]]>
