T09 · Insecure Skill Coding Practices
- Location
scripts/timeline.sh:87- Finding
Arbitrary Command Execution Through sed Program Injection
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 fi ``` 2. Validate time values similarly: ```bash if [[ ! "$time_str" =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]]; then echo "Error: Invalid time" >&2 exit 1 fi ``` 3. Treat event text and tags exclusively as data. Rebuild the file using a temporary file and `printf '%s\n'`, rather than placing the entry inside executable `sed` syntax. 4. Create temporary files with `mktemp` in a trusted directory, preserve permissions where necessary, and atomically replace the original file only after successful generation. 5. Consider rejecting carriage returns, newlines, and other control characters if timeline entries are required to remain single-line records. 6. Validate tags against an allowlist such as letters, digits, underscores, and hyphens. 7. Add regression tests with multiline input and strings containing `sed` metacharacters to verify that they are stored literally and never interpreted. ]]>
