T09 · Insecure Skill Coding Practices
- Location
scripts/feed_core.py:1730- Finding
Command Injection in Linux Subscription Installation
- Content
View full analysis
/dev/null | grep -v "{PLIST_LABEL}"; ' f'echo "{cron_line} # {PLIST_LABEL}") | crontab -', shell=True, check=True, capture_output=True, ) ``` ### Technical Analysis The subscription command incorporates arguments derived from user-controlled options, including `--keywords`, into `cron_line`. Each argument is processed with `shlex.quote()`, but the resulting string is subsequently embedded inside an outer double-quoted `echo` argument and executed with `shell=True`. The quoting generated by `shlex.quote()` is not safe in this context. For example, a value containing command substitution is converted into a single-quoted shell fragment, but those single-quote characters occur inside the outer double-quoted string. Within double quotes, single quotes are ordinary characters and do not suppress shell expansion. Consequently, constructs such as `$(command)` or backtick command substitution can still be evaluated by the shell while the crontab is being installed. This is a classic command-injection vulnerability caused by constructing a compound shell command from user-controlled data and passing it to a shell interpreter. ### Attack Path 1. An attacker supplies, publishes, or persuades an Agent to process a malicious keyword value containing shell command substitution. 2. The user or Agent invokes the Skill with `--subscribe`, for example with a crafted `--keywords` argument. 3. `_subscription_args()` places that keyword in the scheduled command argument list. 4. `_shell_quote()` applies `shlex.quote()`, but the quoted result is interpolated into the outer double-quoted `echo` command. 5. `subprocess.run(... ...[truncated 875 chars]- Remediation
View remediation
