T09 · Insecure Skill Coding Practices
- Location
etf-assistant.sh:237- Finding
Command Injection Through Unvalidated DCA Calculator Inputs
- Content
View full analysis
- Remediation
View remediation
&2 return 1 fi if [[ ! "$years" =~ ^[1-9][0-9]*$ ]]; then echo "Invalid duration: enter a positive whole number of years." >&2 return 1 fi if (( years > 100 )); then echo "Invalid duration: maximum supported duration is 100 years." >&2 return 1 fi ``` After these checks, use the validated integer duration in Bash arithmetic: ```bash local months=$((10#$years * 12)) ``` The `10#` prefix forces base-10 interpretation. For maximum isolation, perform the complete calculation in a small Python program that parses arguments with `decimal.Decimal`, rejects invalid or non-finite values, and never evaluates user input as source code. ]]>
