T09 · Insecure Skill Coding Practices
- Location
scripts/download_sph.sh:31- Finding
Arbitrary File Overwrite Through Unsanitized Output Filename
- Content
View full analysis
- Remediation
View remediation
&2 exit 2 fi ``` 2. Reject empty names, `.` and `..`, path separators, and control characters. 3. Canonicalize the destination and verify that its parent remains the canonical Downloads directory. 4. Reject existing symbolic-link destinations: ```bash if [[ -L "$out" ]]; then echo "Refusing to write through a symbolic link" >&2 exit 2 fi ``` 5. Use exclusive file creation or a securely created temporary file inside `~/Downloads`, then atomically rename it after a successful download. 6. Consider generating the final filename internally and treating any user-provided value only as a sanitized basename. 7. If overwriting existing files is unnecessary, fail when the destination already exists. ]]>
