T09 · Insecure Skill Coding Practices
- Location
SKILL.md:58- Finding
Shell Command Injection Through Unsafe URL Interpolation
- Content
View full analysis
" # Reject shell metacharacters if printf '%s' "$URL" | grep -qE '[;|&`$()]'; then echo "Invalid URL: contains disallowed characters" exit 1 fi ``` The value is subsequently passed to commands such as: ```bash yt-dlp --print title --print description --print uploader "$URL" \ 2>/dev/null > /tmp/reeltalk_work/metadata.txt ``` ### Technical Analysis The instructions require the agent to substitute the user-provided value directly into the shell assignment `URL=""`. Validation occurs only after the shell has parsed and executed that assignment. Consequently, the validation cannot protect against syntax introduced during interpolation. The denylist rejects several common shell metacharacters but does not reject double quotes, backslashes, carriage returns, newlines, or other control characters. An input containing a double quote followed by a newline can terminate the assignment and inject a separate shell command before the `grep` validation is reached. The documented requirement to accept only `http://`, `https://`, or `www.` prefixes is also not implemented in the displayed validation code. Moreover, downstream utilities are not given an explicit `--` option terminator, creating additional argument-confusion risk if a non-URL value reaches them. ### Attack Path 1. An attacker supplies a purported video URL containing a double quote and newline. 2. The agent replaces the literal `` placeholder with that value. 3. The injected quote terminates the `URL` assignment. 4. The newline introduces a new shell command. 5. The shell executes the injected command before reaching the validation block. 6. The injected command runs with the same operating-system privileges and environment access as the skill process. For example, a payl ...[truncated 660 chars]- Remediation
View remediation
