T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:217
- Finding
- Command Injection Through Untrusted Shell Command Interpolation<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 217–233 **Vulnerability Type**: OS command injection **Risk Level**: High ### Vulnerable Code ```bash For each asset URL discovered, download using curl with error handling. If curl fails (non-zero exit), log the URL and continue to the next asset. # Logos (favicon, og:image, header logos) curl -sfLo "{output_dir}/logos/{site-name}-favicon.ico" "{favicon_url}" || echo "FAIL: {favicon_url}" curl -sfLo "{output_dir}/logos/{site-name}-og-image.png" "{og_image_url}" || echo "FAIL: {og_image_url}" # Images curl -sfLo "{output_dir}/images/{site-name}-{descriptive-name}.{ext}" "{image_url}" || echo "FAIL: {image_url}" # SVGs - Write inline SVGs to files using Write tool # Videos curl -sfLo "{output_dir}/videos/{site-name}-{name}.mp4" "{video_url}" || echo "FAIL: {video_url}" # Fonts curl -sfLo "{output_dir}/fonts/{font-name}.woff2" "{font_url}" || echo "FAIL: {font_url}" ``` ### Technical Analysis The skill instructs an agent to construct Bash commands by interpolating values derived from a user-supplied URL and an untrusted website. These values include asset URLs, site names, descriptive names, extensions, and output paths. Wrapping a substitution in double quotes is not sufficient if the generated value itself is inserted as shell source text. A value containing a double quote can terminate the quoted argument, after which shell operators, command substitutions, redirections, or additional commands may be interpreted. The failure-reporting expressions also interpolate the same untrusted URLs into `echo` commands. Filename generation is particularly exposed because the instructions recommend deriving descriptive names from asset alt text or surrounding context. Both are fully controlled by the target website. No validation, canonicalization, escaping function, fixed filename generation, or argument-array execution mechanism is required. ### Attack Path 1. An attacker operates a websi ...[truncated 1519 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not create shell source strings containing website-derived values. 2. Use a downloader API or execute `curl` through an argument-array interface where each URL and destination is passed as a distinct argument without shell evaluation. 3. Generate output filenames locally from random identifiers or cryptographic hashes rather than alt text or URL components. 4. If human-readable names are required, apply a strict allowlist such as ASCII letters, digits, hyphens, and underscores, then impose a maximum length. 5. Validate extensions against a fixed allowlist and determine file types from verified response metadata or file signatures. 6. Canonicalize each destination path and verify that it remains inside the intended output directory before writing. 7. Reject control characters, quotes, shell metacharacters, path separators, and traversal sequences in every value used for naming. 8. Avoid interpolating failed URLs into shell-based logging. Use structured logging or safely pass the URL as data. 9. Run downloads in a sandbox with minimal filesystem access, no unnecessary credentials, and restricted outbound networking. ]]>
