T09 · Insecure Skill Coding Practices
- Location
SKILL.md:21- Finding
Shell Command Injection Through Sender-Controlled Command Arguments
- Content
View full analysis
/scripts/tracker.py --user "发送者名字" --item "鸡腿" --count 1 ``` Associated parameter instructions: ```markdown - `--user`: 必填。从上下文(Sender Name)中提取。如果用户自称“老哥”,则记为“老哥”。 - `--item`: 选填,默认为“鸡腿”。用户如果说喝咖啡,可改为“咖啡”。 - `--count`: 选填,默认为 1。如果用户说“加 10 个鸡腿”,则设为 10。 ``` ### Technical Analysis The skill instructs the agent to extract a sender name from conversation context and interpolate it into a command executed through the `exec` tool. The value is placed inside double quotes, but double quotes do not prevent shell evaluation of command substitutions such as `$(...)` or backticks. Consequently, if `exec` invokes a shell, a crafted sender name can cause the shell to execute embedded commands before `tracker.py` starts. The Python script does not invoke a shell itself; the vulnerability originates from the execution procedure defined in `SKILL.md`. The `--item` value may present the same risk if it is populated directly from user language rather than selected from a trusted fixed mapping. ### Attack Path 1. An attacker supplies or claims a crafted sender name containing shell command-substitution syntax, such as `$(attacker-command)`. 2. The agent follows the skill instructions and extracts that value as the sender name. 3. The agent constructs the documented command: ```bash python3 .../tracker.py --user "$(attacker-command)" --item "鸡腿" --count 1 ``` 4. The `exec` tool passes the command to a shell. 5. The shell evaluates the command substitution before launching Python. 6. The injected command executes with the permissions and environment of the agent process. 7. Its output is then passed to `tracker.py` as the apparent username, potentially concealing the preceding command execution. Exploitation requires the ...[truncated 1032 chars]- Remediation
View remediation
