T09 · Insecure Skill Coding Practices
- Location
scripts/synthesize_edge_tts.py:42- Finding
Manifest-Controlled IDs Allow Path Traversal and Arbitrary File Access
- Content
View full analysis
- Remediation
View remediation
Path: base = base.resolve() candidate = (base / filename).resolve() if not candidate.is_relative_to(base): raise ValueError(f"Path escapes output directory: {filename!r}") return candidate ``` For Python versions without `Path.is_relative_to`, use `candidate.relative_to(base)` inside a `try` block. 3. Apply the same validation independently in both `synthesize_edge_tts.py` and `build_timeline.py`. Do not rely on the manifest having previously passed through another script. 4. Reject: - Absolute paths. - `.` and `..` path components. - Directory separators. - Empty IDs. - Control characters and platform-specific separator variants. 5. Where overwriting is not explicitly required, avoid unconditional FFmpeg `-y` behavior or require an explicit overwrite option. 6. Add regression tests using IDs such as `../target`, `/tmp/target`, `a/b`, empty strings, Unicode separators, and valid values such as `line_01`. ]]>
