T09 · Insecure Skill Coding Practices
- Location
scripts/safe-writer.py:141- Finding
Workspace Path Traversal Through Unsanitized Task and Step Identifiers
- Content
View full analysis
- Remediation
View remediation
Path: validate_component(component, "path component") resolved_base = base.resolve() candidate = (resolved_base / component).resolve() try: candidate.relative_to(resolved_base) except ValueError: raise ValueError("Path escapes the permitted workspace") return candidate ``` 3. Apply containment validation separately to: - Task identifiers - Step directory names - Metadata read paths - Metadata write paths 4. Reject absolute paths, drive-qualified paths, `.` and `..`, path separators, null bytes, and alternate separator forms before filesystem access. 5. Account for symbolic-link traversal. Validate the resolved parent directory immediately before reading, creating, or replacing the target. 6. Implement equivalent canonicalization in PowerShell: - Obtain the fully resolved candidate path. - Obtain the fully resolved output root. - Verify that the candidate is a descendant of the output root using a separator-aware comparison. - Reject the operation if containment cannot be established. 7. Add automated tests covering Unix and Windows traversal forms, absolute paths, drive prefixes, UNC paths, mixed separators, and symbolic-link escapes. ]]>
