T09 · Insecure Skill Coding Practices
- Location
SKILL.md:109- Finding
Shell Command Injection Through Unquoted User-Controlled Paths
- Content
View full analysis
> .zshrc & source .zshrc # Windows CMD: setx PATH=%PATH%;SDK_PATH\envsetup.bat # Windows PowerShell: $env:Path += ";SDK_PATH\envsetup.bat" ``` ```bash # Lines 125–140 cjpm init --path cangjie_project_path python3 ./scripts/main.py -e cangjie_project_path/cjpm.toml dependencies.package_name package_version python3 ./scripts/main.py -e cangjie_project_path/cjpm.toml dependencies.organization::package_name package_version cd cangjie_project_path & cjpm build ``` ```bash # Lines 148–151 cjpm init --path cangjie_project_path --type=dynamic ``` ### Technical Analysis The Skill instructs the Agent to replace `SDK_PATH` and `cangjie_project_path` with values supplied by the user and then execute the resulting commands through a shell. These values are not quoted, validated, or passed as isolated process arguments. A path containing shell metacharacters, command substitution, redirection, environment expansion, or command separators can alter the structure of the command. Quoting only part of a command is also insufficient if the path is inserted before the shell parses it. The SDK setup command creates an additional persistent side effect by appending content to `.zshrc`. A maliciously constructed SDK path could cause attacker-controlled shell syntax to be stored in the shell configuration and evaluated when the configuration is sourced or when a later interactive shell starts. The command: ```bash cd cangjie_project_path & cjpm build ``` uses a single `&`, which backgrounds the `cd` operation rather than safely sequencing the directory change and build. Consequently, `cjpm build` may execute from the ...[truncated 1570 chars]- Remediation
View remediation
