T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/init_skill.py:189- Finding
Path Traversal Through an Unvalidated Skill Name
- Content
View full analysis
- Remediation
View remediation
64: raise ValueError("Skill name exceeds the maximum length") ``` 2. Explicitly reject absolute paths and path separators: ```python candidate = Path(skill_name) if candidate.is_absolute() or len(candidate.parts) != 1: raise ValueError("Skill name must be a single relative path component") ``` 3. Resolve the final path and verify that it remains beneath the authorized base directory: ```python base_dir = Path(path).resolve() skill_dir = (base_dir / skill_name).resolve() if not skill_dir.is_relative_to(base_dir): raise ValueError("Resolved skill path escapes the output directory") ``` 4. Run the process with the minimum filesystem permissions needed and avoid executing it as a privileged user. 5. Add regression tests covering `../target`, nested path components, absolute paths, repeated separators, leading or trailing hyphens, and valid skill names. ]]>
