T09 · Insecure Skill Coding Practices
- Location
scripts/run.py:292- Finding
Unvalidated Workspace-Relative Paths Permit File Access Outside the Workspace
- Content
View full analysis
- Remediation
View remediation
Path: relative = Path(value) if relative.is_absolute(): raise ValueError(f"Absolute paths are not allowed: {value}") root = workspace.resolve() candidate = (root / relative).resolve(strict=False) try: candidate.relative_to(root) except ValueError as exc: raise ValueError(f"Path escapes workspace: {value}") from exc return candidate ``` 3. Apply this helper to every input, output, existence check, read, and write. 4. Prefer a fixed allowlist of exact paths for this Skill: - `output/DRAFT.md` - `output/CITATION_BUDGET_REPORT.md` - `output/CITATION_INJECTION_REPORT.md` - `citations/ref.bib` - Required files under `outline/` 5. Validate path fields when loading `UNITS.csv`, rather than only after a unit is launched. 6. Add regression tests covering absolute paths, `../` traversal, nested traversal, and symlinked workspace directories. 7. Run the Skill under an account or sandbox that cannot write outside the active workspace. ]]>
