T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/skill_updater.py:305- Finding
Lockfile Path Traversal Allows Out-of-Scope Directory Deletion and Replacement
- Content
View full analysis
Path: path = Path(skill_path) if path.is_absolute(): return path anchor = provider_root.parent if provider_root.name.startswith(".") else provider_root return (anchor / path).resolve() ``` The resulting path is subsequently used by the update operation: ```python repo_dir = source_cache[source_url] local_skill = resolve_local_skill_path(provider, entry["skillPath"]).parent source_skill = repo_dir / Path(entry["skillPath"]).parent if local_skill.exists(): shutil.rmtree(local_skill) shutil.copytree(source_skill, local_skill) entry["skillFolderHash"] = report.latest_ref_or_hash entry["updatedAt"] = updated_at ``` ### Technical Analysis The `skillPath` value is read from `.skill-lock.json`, but the updater does not enforce that the resolved local path remains inside the expected provider or skills directory. The resolver explicitly accepts absolute paths. Relative paths are normalized with `Path.resolve()`, which processes `..` components and follows existing symbolic links, but the resolved result is not checked against an approved root such as `provider_root / "skills"`. The update function then applies destructive filesystem operations to this unvalidated path: 1. `shutil.rmtree(local_skill)` recursively deletes the resolved directory. 2. `shutil.copytree(source_skill, local_skill)` replaces it with content obtained from the selected source repository. The source-side path is also built from lockfile-controlled data without confirming that it remains inside `repo_dir`. A local hash comparison provides a partial safeguard, because an update normally proceeds only when the local tree ...[truncated 2058 chars]- Remediation
View remediation
