T09 · Insecure Skill Coding Practices
- Location
scripts/init_skill.py:47- Finding
Path Traversal and Unauthorized File Overwrite Through Unvalidated Skill Name
- Content
View full analysis
Path: """Create a new skill directory with standard structure. Args: skill_name: Kebab-case skill name output_path: Parent directory where the skill folder will be created Returns: Path to the created skill directory """ skill_dir = output_path / skill_name skill_dir.mkdir(parents=True, exist_ok=True) # Create directories (skill_dir / "scripts").mkdir(exist_ok=True) (skill_dir / "references").mkdir(exist_ok=True) (skill_dir / "assets").mkdir(exist_ok=True) # Create SKILL.md skill_md = skill_dir / "SKILL.md" skill_md.write_text(SKILL_MD_TEMPLATE.format( skill_name=skill_name, skill_title=to_title(skill_name), )) # Create scripts/__init__.py (skill_dir / "scripts" / "__init__.py").write_text(INIT_PY_CONTENT) # Create .gitkeep files so empty dirs are tracked (skill_dir / "references" / ".gitkeep").write_text("") (skill_dir / "assets" / ".gitkeep").write_text("") return skill_dir ``` ```python skill_name = sys.argv[1] # Parse --path option output_path = Path.cwd() if "--path" in sys.argv: path_idx = sys.argv.index("--path") if path_idx + 1 < len(sys.argv): output_path = Path(sys.argv[path_idx + 1]) else: print("Error: --path requires a value") sys.exit(1) output_path = output_path.resolve() output_path.mkdir(parents=True, exist_ok=True) skill_dir = init_skill(skill_name, output_path) ``` ### Technical Analysis The command-line `skill_name` is treated as a filesystem path component without validating that it is a single kebab-case name. The expression `output_path / skill_name` does not guarantee containment within `output_path`: ...[truncated 1982 chars]- Remediation
View remediation
