T09 · Insecure Skill Coding Practices
- Location
SKILL.md:28- Finding
Command Injection Through Unsafe Interpolation of User-Controlled Case Text
- Content
View full analysis
" Replace `` with the user's original case text. ``` ### Technical Analysis The skill instructs the agent to substitute the user's original, untrusted case text directly into a shell command. Enclosing the placeholder in double quotes does not make arbitrary input safe in shell source. Shell constructs such as command substitution (`$(...)` or backticks) remain active inside double-quoted strings. An embedded double quote can also terminate the intended argument and introduce additional shell syntax. For example, if a malicious case description contains `$(id)`, direct textual substitution produces: ```bash bash scripts/run_case_echo.sh "患者,男,63岁,$(id)" ``` The shell executes `id` before invoking the script. Input containing embedded quotes and command separators could similarly escape the argument and execute independent commands. The wrapper correctly quotes `"$1"` at `scripts/run_case_echo.sh:5`, but that protection applies only after the invoking shell has already parsed and evaluated the constructed command. It therefore does not prevent this vulnerability. ### Attack Path 1. An attacker supplies a purported Chinese medical case containing shell command substitution or quote-breaking syntax. 2. The agent follows `SKILL.md` and replaces `` with the original case text in the documented shell command. 3. The command is submitted to a shell as a constructed command string. 4. The shell evaluates attacker-controlled substitutions or metacharacters before `run_case_echo.sh` starts. 5. The injected command executes with the operating-system privileges and environment of th ...[truncated 531 chars]- Remediation
View remediation
