T09 · Insecure Skill Coding Practices
- Location
scripts/make-product.sh:205- Finding
Command Execution Through Unvalidated Bash Arithmetic Expressions
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 fi } require_uint "sticker stroke width" "$STICKER_STROKE_WIDTH" require_uint "logo size" "$LOGO_SIZE" require_uint "logo opacity" "$LOGO_OPACITY" require_uint "font size" "$FONT_SIZE" require_uint "corner radius" "$CORNER_RADIUS" require_uint "padding" "$PADDING" require_uint "pattern opacity" "$PATTERN_OPACITY" ``` 2. **Enforce explicit bounds after syntax validation.** Recommended constraints include: - Opacity: `0-100`. - Logo size: `1-100`. - Stroke width, padding, corner radius, and font size: conservative positive limits appropriate for expected images. - Width and height ratios: strict decimal values greater than `0` and no greater than `1`. 3. **Validate decimal ratios without constructing executable `bc` programs from raw input.** Use a strict regular expression such as `^(0(\.[0-9]+)?|1(\.0+)?)$`, then pass values through controlled calculation code. 4. **Validate enumerated options.** Restrict positions to: - `top-left` - `top-right` - `bottom-left` - `bottom-right` - `random` 5. **Reject unknown wrapper arguments.** `run.sh` should use an allowlist rather than forwarding every unrecognized option to `make-product.sh`. 6. **Apply the same validation to configuration-derived values.** Configuration checks should verify types, finite numeric values, bounds, color syntax, font names, and allowed positions before constructing command arguments. 7. **Add regression tests** that confirm payloads containing `$()`, backticks, brackets, semicolons, signs, whitespace, newlines, and non-decimal arithmetic syntax are rejected before any arith ...[truncated 46 chars]
