T09 · Insecure Skill Coding Practices
- Location
scripts/photo_geolocator.py:320- Finding
Report CSV Path Traversal and Symlink Escape Permit Modification of Files Outside the Photo Directory
- Content
View full analysis
bool: return path.suffix.lower() in (".jpg", ".jpeg") ``` ### Technical Analysis The `write` command treats the `filename` column of the supplied report CSV as a trusted relative filename. It joins the value directly to both `photo_dir` and `backup` without validating that the resolved paths remain inside those directories. A filename containing `../` can escape the selected directories. In addition, `Path.is_file()` follows symbolic links, while `is_jpg()` only validates the textual suffix. A symlink named with a `.jpg` extension inside the photo directory can therefore refer to a JPG outside that directory and pass both checks. The required backup does not eliminate the vulnerability. `shutil.copy2()` also receives a destination derived from the unvalidated CSV filename, allowing that destination to escap ...[truncated 2149 chars]- Remediation
View remediation
