T09 · Insecure Skill Coding Practices
- Location
scripts/cultural_tourism_douyin_report.py:560- Finding
Arbitrary command execution through subscription keyword injection
- Content
View full analysis
/dev/null; echo "{cron_line}") | crontab -', shell=True, check=True, capture_output=True ) ``` ### Technical Analysis The `keyword` value originates from the `--keyword` command-line argument and is inserted into `cron_line` without validation or shell escaping. That string is subsequently embedded in a larger command passed to `subprocess.run(..., shell=True)`. Because a shell interprets the resulting string, shell expansions and metacharacters in the keyword are evaluated. In particular, command substitution remains active inside the double-quoted argument used by `echo`. An input such as: ```text $(id > /tmp/subscription-command-executed) ``` would be evaluated by the shell while constructing the crontab entry. This results in immediate arbitrary command execution rather than merely storing the supplied text in crontab. The operation runs with the privileges of the user invoking the Skill. No additional operating-system privilege escalation is required for exploitation. ### Attack Path 1. An attacker persuades the user or Agent to request a daily subscription using a crafted keyword. 2. The Agent invokes the script with the crafted value, for example: ```bash python3 scripts/cultural_tourism_douyin_report.py \ --subscribe \ --keyword '$(id > /tmp/subscription-command-executed)' ``` 3. `install_subscription()` embeds the untrusted keyword in `cron_line`. 4. The complete string is passed to `/bin/sh` because `shell=True` is enabled. 5. The shell evaluates the command substitution. 6. The attacker's command executes with the invoking user's per ...[truncated 603 chars]- Remediation
View remediation
