T03 · Remote Payload Retrieval and Execution
Warning
- Location
- tunnel.sh:17
- Finding
- Unverified Remote VS Code CLI Download and Execution<![CDATA[ ## Vulnerability Details **File Location**: `tunnel.sh`, lines 17 and 78-96 **Vulnerability Type**: Remote executable retrieval without integrity verification **Risk Level**: Medium ### Vulnerable Code ```bash CLI_URL="https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64" ``` ```bash download_cli() { local cli_bin="$CLI_DIR/code" if [ -f "$cli_bin" ]; then log_info "CLI already exists, skipping download" return 0 fi log_info "Downloading VS Code CLI..." local tmp_file="$CLI_DIR/vscode_cli.tar.gz" if ! curl -sL "$CLI_URL" -o "$tmp_file"; then log_error "Download failed" rm -f "$tmp_file" exit 1 fi log_info "Extracting CLI..." if ! tar -xzf "$tmp_file" -C "$CLI_DIR"; then log_error "Extraction failed" rm -f "$tmp_file" exit 1 fi rm -f "$tmp_file" chmod +x "$cli_bin" log_success "CLI downloaded: $cli_bin" } ``` ### Technical Analysis The script downloads a mutable VS Code CLI archive from an external URL, follows redirects with `curl -L`, extracts the archive, marks the resulting binary executable, and subsequently launches it. It does not verify a cryptographic checksum, digital signature, pinned release version, final redirect destination, or archive contents. HTTPS protects the connection under normal conditions, and the configured URL belongs to the expected VS Code service. Nevertheless, transport security alone does not establish artifact integrity if the upstream distribution service, redirect destination, signing infrastructure, or served artifact is compromised. The effective executable payload can also change after the Skill package has been reviewed because the URL selects the current stable build. The existing-file check introduces an additional trust assumption: any preexisting regular file at `$CLI_DIR/code` is accepted without validation and later executed. ### Attack ...[truncated 1408 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin the CLI to an explicit, reviewed version instead of using a mutable `stable` download selector. 2. Obtain a vendor-published SHA-256 or stronger digest through a separately authenticated channel and verify it before extraction. 3. Prefer vendor-supported cryptographic signature verification when signatures and trusted signing keys are available. 4. Download with strict failure handling, such as `curl --fail --show-error`, and validate the final redirect destination against an explicit allowlist. 5. Inspect the archive file list before extraction and reject absolute paths, `..` traversal entries, unexpected symlinks, and unexpected filenames. 6. Extract into a newly created private temporary directory, validate the resulting binary, and then install it atomically. 7. Ensure `$CLI_DIR` is owned by the expected user and is not writable by untrusted users. Use restrictive directory permissions such as `0700`. 8. Do not trust an existing `$CLI_DIR/code` solely because it is a regular file. Verify its checksum, signature, ownership, permissions, and expected version before every execution. 9. Fail closed and remove unverified artifacts whenever any integrity or validation check fails. ]]>
