T09 · Insecure Skill Coding Practices
- Location
SKILL.md:37- Finding
Shell Command Injection Through User-Controlled JSON Input
- Content
View full analysis
' ``` ### Technical Analysis The workflow instructs the agent to interpolate a JSON object containing user-controlled fields directly into a single-quoted Bash command. JSON validation does not provide shell escaping because Bash parses the command before `save.py` receives the argument. A single quote in any string field, such as `note` or `source`, can terminate the surrounding shell quote. The remaining content may then introduce shell operators and arbitrary commands. Merely producing valid JSON is insufficient to prevent this issue when the serialized JSON is subsequently embedded in shell syntax. For example, a malicious field could contain content conceptually equivalent to: ```text '; attacker_command; # ``` If inserted without shell-safe argument handling, the first quote closes the JSON argument, the injected command is interpreted by Bash, and the comment marker can suppress the remaining generated command text. ### Attack Path 1. An attacker asks the agent to save a trade containing crafted text in a user-controlled field such as `note`. 2. The crafted value includes a single quote, shell separators, and an attacker-selected local command. 3. The agent serializes the trade as JSON and substitutes it for `` in the documented Bash command. 4. Bash terminates the quoted a ...[truncated 821 chars]- Remediation
View remediation
