T09 · Insecure Skill Coding Practices
- Location
music_tagger.py:160- Finding
Tamperable Backup File Enables Arbitrary File Copy and Deletion
- Content
View full analysis
{old_path.name}") count += 1 if count > 0: self.backup_file.unlink(missing_ok=True) print(f"已撤销 {count} 个音乐文件的操作") return True else: print("没有需要撤销的音乐文件") return False ``` ### Technical Analysis The undo operation treats every key and value loaded from `.music-tagger-backup.json` as a trusted filesystem path. It does not validate the JSON schema, authenticate the backup, verify file ownership, reject symbolic links, or ensure that canonicalized paths remain within the intended input and output directories. After reversing the attacker-controlled mappings, the code uses one supplied path as the source of `copy2()` and another as its destination. It then unconditionally removes the source with `unlink()` after a successful copy. Consequently, a crafted backup can direct the application to relocate an arbitrary file that the invoking user can read and delete to any nonexistent path whose parent directory the user can write. This does not grant privileges beyond those of the user running the progra ...[truncated 1641 chars]- Remediation
View remediation
