T09 · Insecure Skill Coding Practices
- Location
scripts/gamma.sh:116- Finding
Arbitrary Command Execution Through Unvalidated --max-wait Arithmetic Expression
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 fi if [[ ! "$poll_interval" =~ ^[1-9][0-9]*$ ]]; then echo "Error: --poll-interval must be a positive decimal integer" >&2 exit 1 fi if [[ ! "$cards" =~ ^[1-9][0-9]*$ ]]; then echo "Error: --cards must be a positive decimal integer" >&2 exit 1 fi ``` Apply explicit upper bounds to prevent excessive waits and resource consumption: ```bash if (( max_wait > 3600 )); then echo "Error: --max-wait cannot exceed 3600 seconds" >&2 exit 1 fi if (( poll_interval > 300 )); then echo "Error: --poll-interval cannot exceed 300 seconds" >&2 exit 1 fi ``` Additional hardening should include: 1. Rejecting missing values for options before reading `$2`. 2. Validating enumerated options such as `--format`, `--amount`, `--image-source`, `--image-style`, and `--dimensions` against explicit allowlists. 3. Retaining array-based `curl` argument construction to prevent ordinary shell argument injection. 4. Adding regression tests that pass arithmetic payloads, alphabetic strings, signed values, whitespace, oversized integers, and missing option values. 5. Ensuring invalid input is rejected before any credit-consuming Gamma API request is submitted. ]]>
