T09 · Insecure Skill Coding Practices
- Location
scripts/install.sh:199- Finding
Command Injection Through Generated Startup Scripts
- Content
View full analysis
> "$START_SERVER" <> "$START_ALL" </tmp/clawtime.log & ``` ### Technical Analysis The installer constructs executable shell source using values supplied interactively by the user. `PUBLIC_URL` is emitted without quoting, while `BOT_NAME` and `BOT_EMOJI` are placed inside double quotes without escaping embedded quotation marks, command substitutions, backticks, line breaks, or shell control operators. Here-document expansion occurs while the installer generates each file, and the resulting file is later parsed again as shell syntax. Consequently, input that changes the syntactic structure of an assignment can add arbitrary commands to `start-server.sh` or `start.sh`. This is a code-generation ...[truncated 2095 chars]- Remediation
View remediation
> "$START_SERVER" printf 'BOT_NAME=%q\n' "$BOT_NAME" >> "$START_SERVER" printf 'BOT_EMOJI=%q\n' "$BOT_EMOJI" >> "$START_SERVER" ``` 4. Validate `PUBLIC_URL` using a URL parser and require: - The `https` scheme. - A valid hostname. - No credentials, control characters, whitespace, shell syntax, or unexpected path/query components. 5. Apply explicit length and character restrictions to `BOT_NAME` and `BOT_EMOJI`. 6. Prefer passing configuration as fixed argument-array elements or through a securely generated environment file parsed without shell evaluation. 7. Add automated tests using quotation marks, command substitutions, backticks, newlines, semicolons, pipes, and redirection characters to verify that generated configuration cannot change shell syntax. ]]>
