T09 · Insecure Skill Coding Practices
- Location
scripts/organize.py:123- Finding
Untrusted Scan Plan Allows Arbitrary File Relocation and Destination Path Escape
- Content
View full analysis
1: dest_path = dest_root / category / rel else: dest_path = dest_root / category / f["name"] ``` The resulting paths are later used directly during execution: ```python for move in moves: src = Path(move["source"]) dst = Path(move["dest"]) if dst.exists() and not yes: skipped_conflicts += 1 errors.append({ "source": move["source"], "dest": move["dest"], "error": "destination_exists" }) continue try: dst.parent.mkdir(parents=True, exist_ok=True) shutil.move(str(src), str(dst)) succeeded += 1 ``` ### Technical Analysis `organize.py` accepts a scan JSON file and treats its `scan_dir`, `abs_path`, `path`, `name`, and size metadata as authoritative. The input is parsed as JSON, but its schema, provenance, and path relationships are not validated. In particular: 1. `f["abs_path"]` can identify any file accessible to the executing account. The code does not verify that the resolved source is inside the declared `scan_dir`. 2. `f["path"]` may be absolute or contain `..` traversal components. When this value is appended to `dest_root / category`, it can resolve outside the intended organization directory. 3. The destination is not canonicalized ...[truncated 2216 chars]- Remediation
View remediation
