T09 · Insecure Skill Coding Practices
- Location
scripts/manus.sh:74- Finding
Unrestricted Remote File Download and Local File Overwrite
- Content
View full analysis
[output_dir] task_id="$1" output_dir="${2:-.}" mkdir -p "$output_dir" curl -s "$API_BASE/tasks/$task_id" \ -H "API_KEY: $MANUS_API_KEY" | jq -r '.output[]?.content[]? | select(.type == "output_file") | "\(.fileName)\t\(.fileUrl)"' | \ while IFS=$'\t' read -r filename url; do if [ -n "$filename" ] && [ -n "$url" ]; then # Sanitize filename safe_name=$(echo "$filename" | tr -cd '[:alnum:]._-' | head -c 100) [ -z "$safe_name" ] && safe_name="output_file" echo "Downloading: $safe_name" >&2 curl -sL "$url" -o "$output_dir/$safe_name" echo "$output_dir/$safe_name" fi done ;; ``` ### Technical Analysis The `download` action extracts `fileUrl` and `fileName` values from a remote API response and passes the URL directly to `curl -L`. It does not validate the URL scheme or destination hostname. Redirect following is enabled without validating each redirect target. Consequently, a compromised or malicious task response could make the client request an attacker-selected URL. Depending on the protocols supported by the installed `curl`, this may include non-HTTPS resources, loopback addresses, private network services, or local resources. This is a client-side server-side request forgery–style issue, although retrieved content is written locally rather than automatically returned to the attacker. The filename is restricted to alphanumeric characters, periods, underscores, and hyphens, which prevents direct path traversal. However, the destination is opened with normal overwrite behavior. An API-controlled filename can therefore replace an existing file in the user-selected output directory. Different remote filenames may also ...[truncated 2007 chars]- Remediation
View remediation
