T09 · Insecure Skill Coding Practices
- Location
video_editor_auto_v4.6.py:566- Finding
Arbitrary User-Supplied Working Directory Is Recursively Deleted
- Content
View full analysis
= 2 and os.path.isdir(sys.argv[1]): input_dir = sys.argv[1] output_dir = sys.argv[2] if len(sys.argv) > 2 else "./output" work_dir = sys.argv[3] if len(sys.argv) > 3 else "./video_work" os.makedirs(output_dir, exist_ok=True) os.makedirs(work_dir, exist_ok=True) process_batch(input_dir, output_dir, work_dir) return ``` ### Technical Analysis Batch mode permits the caller to supply any path as `work_dir`. The program calls `os.makedirs(..., exist_ok=True)`, which accepts an already existing directory, and does not record whether the directory was created by the current execution. After successful concatenation, `shutil.rmtree(work_dir, ignore_errors=True)` recursively deletes the entire selected directory. There is no canonical-path validation, dedicated ownership marker, restriction to a program-controlled temporary root, check against filesystem roots or important user directories, or confirmation before deletion. Consequently, the cleanup operation is not limited to temporary artifacts created by this program. The use of `ignore_errors=True` also suppresses deletion errors, making partial destructive cleanup less visible. This behavior is not disclosed in `SKILL.md`. ### Attack Path 1. An attacker, unsafe wrapper, or mistaken operator invokes batch mode with a writable existing directory as the third argument, for example: ```bash python3 video ...[truncated 1103 chars]- Remediation
View remediation
