T09 · Insecure Skill Coding Practices
- Location
scripts/cultural_tourism_bilibili_report.py:554- Finding
Shell Command Injection and Persistent Cron Injection Through the Subscription Keyword
- 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 user-controlled `--keyword` command-line argument and is interpolated directly into a command executed with `shell=True`. Neither the keyword nor `script_path` is validated or safely quoted. The surrounding double quotes do not prevent shell expansion. Shell constructs such as command substitution, backticks, embedded quotes, and newline characters can alter command behavior. Newlines can additionally insert arbitrary cron entries, converting immediate command injection into persistent execution. ### Attack Path 1. An attacker supplies or induces the Agent to use a malicious subscription keyword containing shell syntax. 2. The Agent invokes the script with `--subscribe` and the crafted keyword. 3. `install_subscription()` inserts the keyword into `cron_line`. 4. The complete string is passed to a shell through `subprocess.run(..., shell=True)`. 5. The shell evaluates the injected syntax with the privileges of the user running the Skill. 6. A crafted newline or cron expression can also register an attacker-controlled recurring command. ### Impact Assessment Successful exploitation provides arbitrary command execution under the Agent user's account. The attacker could read or modify user-accessible files, steal credentials, download additional payloads, alter the user's crontab, or establish recurring execution. No administrative privilege is inherently obtained, but the comp ...[truncated 64 chars]- Remediation
View remediation
