T09 · Insecure Skill Coding Practices
- Location
scripts/score.sh:5- Finding
Command Injection Through Unvalidated Bash Arithmetic Expressions
- Content
View full analysis
- Remediation
View remediation
&2 exit 2 fi completed_num=$((10#$COMPLETED)) failed_num=$((10#$FAILED)) SCORE=$((completed_num * 10 - failed_num * 5)) ``` Additional hardening should include: - Use the validated numeric variables in every later comparison. - Quote variables in non-arithmetic shell contexts. - Define reasonable upper bounds to prevent integer overflow or nonsensical scores. - Add tests using malformed values, arithmetic syntax, array subscripts, empty arguments, negative numbers, and very large integers. - Consider moving all score processing into the Python implementation to avoid maintaining two inconsistent scoring engines. ]]>
