T09 · Insecure Skill Coding Practices
- Location
SKILL.md:413- Finding
Arbitrary Command Execution via Python Code Injection in URL Decoder
- Content
View full analysis
/dev/null) echo "URL → $URL_DECODED" fi ``` ### Technical Analysis The quick-decode script interpolates `$INPUT` directly into Python source supplied through `python3 -c`. Although the value is placed inside a single-quoted Python string, the shell does not provide protection for the resulting Python syntax. An attacker can include a single quote and closing delimiters in the input to terminate the intended string and append arbitrary Python statements. The preceding `grep` condition is not a security control. It only requires the input to contain a percent-encoded sequence and does not reject Python metacharacters. For example, an input shaped as follows passes the percent-encoding check and transforms the generated Python source into multiple executable statements: ```text ')); __import__("os").system("id"); print(unquote('%41 ``` The effective Python source becomes equivalent to: ```python from urllib.parse import unquote print(unquote('')) __import__("os").system("id") print(unquote('%41')) ``` This permits arbitrary operating-system command execution rather than merely URL decoding. ### Attack Path 1. An attacker supplies a crafted string to be decoded, such as through a message, API response, configuration value, or untrusted file. 2. A user or agent invokes the documented `decode.sh` script with that value as its argument or standard input. 3. The crafted input contains a valid percent-encoded sequence, so it passes the `grep` condition. 4. The script inserts the complete attacker-controlled value into the source passed to `python3 -c`. 5. The attacker closes the intended Pyth ...[truncated 950 chars]- Remediation
View remediation
