T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/_lib.py:111- Finding
Verification Follows File Symlinks Outside the Target Skill Directory
- Content
View full analysis
list[str]: """Return sorted list of relative paths of files to be hashed.""" skill_dir = Path(skill_dir).resolve() result = [] for root, dirs, files in os.walk(skill_dir): # In-place prune dirs[:] = sorted(d for d in dirs if d not in EXCLUDE_DIRS and not d.startswith("._")) for fname in sorted(files): full = Path(root) / fname rel = str(full.relative_to(skill_dir)).replace("\\", "/") if not should_exclude(rel): result.append(rel) return sorted(result) ``` ```python def compute_content_hash(skill_dir: Path, file_list: list[str]) -> str: """SHA-256 over (sorted) [rel_path:content\n] for each file. Streamed.""" h = hashlib.sha256() skill_dir = Path(skill_dir) for rel in file_list: full = skill_dir / rel h.update(rel.encode("utf-8")) h.update(b":") with open(full, "rb") as f: while True: chunk = f.read(65536) if not chunk: break h.update(chunk) h.update(b"\n") return "sha256:" + h.hexdigest() ``` ### Technical Analysis `collect_files()` includes file symlinks in the list of content to hash. The later `open(full, "rb")` operation follows those symlinks without validating that the resolved target remains beneath `skill_dir`. Consequently, verification of an untrusted Skill can read any file accessible to the user running the verifier. This exceeds the minimum filesystem access required to authenticate files contained within a Skill directory. The verifier does not directly print the external file contents. However, when the computed hash differ ...[truncated 1512 chars]- Remediation
View remediation
