T09 · Insecure Skill Coding Practices
- Location
scripts/shortio.sh:217- Finding
Arbitrary Command Execution Through Unsafe URL Interpolation
- Content
View full analysis
/dev/null \ || echo "$url" | sed 's|:|%3A|g; s|/|%2F|g') ``` ### Technical Analysis The value of the `--url` argument is interpolated directly into Python source code passed to `python3 -c`. Although shell variable expansion does not itself reevaluate shell metacharacters contained in the variable, the expanded value becomes part of the Python program and is parsed as Python syntax. An attacker can supply a URL containing a single quote, closing parentheses, and additional Python statements. This breaks out of the quoted Python string and permits arbitrary Python code execution. Python can then invoke operating-system commands through modules such as `os` or `subprocess`. The fallback to `sed` does not mitigate the vulnerability because the injected code is processed when Python parses and executes the generated source. ### Attack Path 1. An attacker causes the Skill or its user to invoke the `find` command with an attacker-controlled `--url` value. 2. The supplied value closes the Python string and the surrounding function calls. 3. Additional Python statements are inserted before a comment marker suppresses the remaining generated source. 4. For example, a value structurally equivalent to the following can execute a local command: ```text ')); __import__("os").system("id"); # ``` 5. The generated Python program executes the injected statement with the privileges and environment of the user running the Skill. 6. The attacker can replace the demonstration command with commands that read files, modify user data, access environment variables, or initiate network connections. ### Impact Assessment Successful exploitation ...[truncated 692 chars]- Remediation
View remediation
