T09 · Insecure Skill Coding Practices
- Location
grok-selfie.sh:70- Finding
User-Controlled Multipart Values Can Cause Local File Disclosure
- Content
View full analysis
/dev/null 2>&1 else curl -s -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendPhoto" \ -F "chat_id=$TELEGRAM_CHAT_ID" \ -F "photo=$IMAGE_URL" > /dev/null 2>&1 fi ``` ### Technical Analysis The script passes variable-backed scalar values to `curl` using `-F`. In curl multipart syntax, a value beginning with `@` is interpreted as a local filename whose contents should be uploaded. Shell quoting prevents shell expansion but does not disable curl's own `@filename` interpretation. `CAPTION` is taken directly from the third command-line argument without validation. Consequently, a caption such as `@/etc/passwd` can instruct curl to open the specified local file and place its contents in the outbound multipart request. The same parsing behavior affects other variable-backed `-F` fields, although the caption is the field most directly exposed to user-controlled input. The comment and documentation asserting that `curl -F` safely transmits form data are therefore inaccurate for untrusted scalar values. ### Attack Path 1. An attacker supplies or influences a selfie request whose caption begins with `@`, such as `@/etc/passwd`. 2. The agent or caller invokes: ```bash ./grok-selfie.sh "some context" mirror "@/etc/passwd" ``` 3. The script assigns the third argument to `CAPTION`. 4. The value is passed to curl as `-F "caption=$CAPTION"`. 5. Curl interprets the value as a request to read `/etc/passwd`. 6. Curl includes the local file in the HTTPS multipart request sent to Telegram. 7. Even if Telegram rej ...[truncated 711 chars]- Remediation
View remediation
