T03 · Remote Payload Retrieval and Execution
Error
- Location
- kagi-enrich.sh:43
- Finding
- Unverified Remote Binary Download and Execution<![CDATA[ ## Vulnerability Details **File Location**: `kagi-enrich.sh:43-87` **Vulnerability Type**: Remote payload retrieval and execution without cryptographic integrity verification **Risk Level**: High ### Vulnerable Code ```bash if [[ ! -x "$BIN" ]]; then OS="$(uname -s | tr '[:upper:]' '[:lower:]')" ARCH="$(uname -m)" case "$ARCH" in x86_64) ARCH="amd64" ;; aarch64|arm64) ARCH="arm64" ;; esac if command -v curl >/dev/null 2>&1; then RELEASE_META="$(curl -fsSL "https://api.github.com/repos/joelazar/kagi-skills/releases/latest")" elif command -v wget >/dev/null 2>&1; then RELEASE_META="$(wget -qO- "https://api.github.com/repos/joelazar/kagi-skills/releases/latest")" else echo "Error: Neither curl nor wget found. Please download the binary manually from:" >&2 echo " https://github.com/joelazar/kagi-skills/releases/latest" >&2 exit 1 fi TAG="$(printf '%s\n' "$RELEASE_META" | grep -m1 '"tag_name"' | cut -d'"' -f4 || true)" if [[ -z "$TAG" ]]; then echo "Error: Could not resolve latest release tag from GitHub API." >&2 echo "Please download manually from: https://github.com/joelazar/kagi-skills/releases/latest" >&2 exit 1 fi BINARY="kagi-enrich_${TAG}_${OS}_${ARCH}" URL="https://github.com/joelazar/kagi-skills/releases/download/${TAG}/${BINARY}" echo "kagi-enrich binary not found. Download pre-built binary from GitHub releases?" >&2 echo " $URL" >&2 read -r -p "Download? [Y/n] " reply >&2 </dev/tty case "${reply:-Y}" in [Yy]*|"") ;; *) echo "Aborted. Install Go 1.26+ to build from source, or download manually:" >&2 echo " $URL" >&2 exit 1 ;; esac if command -v curl >/dev/null 2>&1; then curl -fsSL "$URL" -o "$BIN" else wget -qO "$BIN" "$URL" fi chmod +x "$BIN" fi exec "$BIN" "$@" ``` ### Technical Analysis When a suitable locally built binary is unavailable, the wrapper queries a mutable `latest` release endpoint, constructs an a ...[truncated 2313 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Prefer building the executable from the audited local Go source instead of downloading a mutable prebuilt artifact. 2. If prebuilt binaries must be supported, pin an explicitly reviewed release version rather than resolving the mutable `latest` release at runtime. 3. Store the expected SHA-256 digest for every supported platform inside the reviewed skill package or obtain it through an independently authenticated trust channel. 4. Download the artifact to a securely created temporary file and verify its digest before granting execute permission or moving it into `.bin`. 5. Fail closed and delete the temporary artifact if verification fails, the expected digest is unavailable, or the platform is unsupported. 6. Install the verified artifact using an atomic rename so an interrupted download cannot leave a partially written executable at the final path. 7. Consider signed releases using a verifiable mechanism such as Sigstore or another signing system with a pinned maintainer identity. Verify the signature and identity before installation. 8. Do not treat a checksum file hosted alongside the binary as sufficient authentication if both can be replaced through the same compromised release channel. 9. Avoid executing an existing `.bin/kagi-enrich` solely because it has an executable bit. Record and revalidate its trusted digest before each execution or when installation state changes. ]]>
