T09 · Insecure Skill Coding Practices
- Location
organizer.py:210- Finding
Unvalidated Execution Plan Allows Arbitrary Filesystem Moves
- Content
View full analysis
Dict: results = {"moved": [], "errors": []} log_lines = [f"# Organize log {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}", ""] for item in plan: source = Path(item["source"]) target = Path(item["final_target"]) try: target.parent.mkdir(parents=True, exist_ok=True) shutil.move(str(source), str(target)) results["moved"].append({"from": str(source), "to": str(target)}) ``` The command-line handler passes decoded, caller-controlled JSON directly to this function: ```python if args.execute: plan = json.loads(args.execute) results = execute_plan(plan) update_index(config) print(json.dumps(results, ensure_ascii=False, indent=2)) return ``` The documented workflow explicitly permits modification of destination-related plan fields before execution: ```markdown - If the user requests **changes**: adjust the plan (modify `target_subdir` and `final_target` fields accordingly), show the updated table, and ask again Pass the (possibly modified) plan JSON back to the script: ```bash python3 ~/.claude/skills/organize/organizer.py --execute '' ``` ``` ### Technical Analysis `execute_plan()` treats the `source` and `final_target` fields in supplied JSON as trusted filesystem paths. It does not verify that: - The source is a regular file located directly inside the configured `downloads_dir`. - The destination is contained within the configured `target_root`. - The source and destination are free of symbolic-link redirection. - The destination does not already exist at execution time. - The plan was produced by the current invocation of `--scan`. - The d ...[truncated 2226 chars]- Remediation
View remediation
