T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/integrity.py:616- Finding
Path Traversal Allows Restore Operations Outside the Workspace
- Content
View full analysis
- Remediation
View remediation
Path: relative = Path(user_path.replace("\\", "/")) if relative.is_absolute() or ".." in relative.parts: raise ValueError("Absolute paths and traversal are not allowed") root = root.resolve() candidate = (root / relative).resolve() if not candidate.is_relative_to(root): raise ValueError("Path escapes the authorized root") return candidate ``` - For `restore`, accept only relative paths already recorded in the integrity manifest. - Independently validate the snapshot source under `.integrity/snapshots` and the destination under the workspace. - Apply the same centralized validation to `accept`, `restore`, and `rollback`. - Revalidate paths immediately before writing to reduce time-of-check/time-of-use exposure. ]]>
