T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:38
- Finding
- Unvalidated and Unquoted Deployment Parameters Enable Command Injection and Path Traversal<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 38–39; the unsafe copy pattern is repeated at line 53 **Vulnerability Type**: Shell command injection and arbitrary-path file write **Risk Level**: High ### Vulnerable Code ```bash mkdir -p /data/games/{game-name} cp -r /path/to/build/* /data/games/{game-name}/ ``` The update procedure repeats the unsafe destination construction: ```bash cp -r /path/to/new-build/* /data/games/{game-name}/ ``` ### Technical Analysis The deployment instructions place the `{game-name}` placeholder directly into shell commands without requiring validation, shell-safe quoting, or destination-path canonicalization. If an agent replaces this placeholder with attacker-controlled text, shell metacharacters may alter the command structure. For example, a value containing `;`, command substitution, redirection, or similar shell syntax can introduce an additional command when textual substitution is performed. A value containing path components such as `../../` can also cause the destination to escape the intended `/data/games/` root. The source path is represented as another unquoted placeholder. Implementations derived from this documentation may consequently mishandle source paths containing whitespace, wildcard characters, leading hyphens, or shell metacharacters. ### Attack Path 1. An attacker asks the agent to deploy or update a game and supplies a crafted game name. 2. The agent substitutes that value directly into the documented command without validating it as a restricted slug. 3. A value containing shell syntax changes the command executed by the shell, or a traversal value such as `../../target` resolves outside `/data/games/`. 4. The command runs with the agent's filesystem permissions. 5. The attacker can cause commands to execute or files to be copied to an unintended writable location. Exploitation requires the game name or another substituted path to be derived from an untrusted request and i ...[truncated 680 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Require game names to match a strict allowlist, such as `^[A-Za-z0-9_-]+$`. - Explicitly reject empty values, `.` and `..`, path separators, whitespace, leading hyphens, control characters, and shell metacharacters. - Pass values as shell variables and quote every expansion: ```bash game_name='validated-slug' source_dir='/validated/build/path' destination="/data/games/$game_name" mkdir -p -- "$destination" cp -r -- "$source_dir"/. "$destination"/ ``` - Canonicalize the destination and verify that it remains a child of `/data/games/` before creating directories or copying files. - Validate the source as an existing directory and avoid directly interpolating user-provided source paths. - Use a deployment script that accepts structured arguments rather than having the agent construct shell commands through textual substitution. - Run deployment under a dedicated, least-privileged account that can write only to the game-content directory and perform only the required nginx reload operation. ]]>
