T09 · Insecure Skill Coding Practices
- Location
scripts/generate_app_package.py:391- Finding
Arbitrary Shell Commands Can Be Embedded in Generated Initialization Scripts
- Content
View full analysis
None: commands = [str(item).rstrip() for item in spec.get("init_commands") or []] fixes = collect_permission_fixes(spec, services) scripts_dir = version_dir / "scripts" if not commands and not fixes: if scripts_dir.exists(): shutil.rmtree(scripts_dir) return evidence = [str(item).strip() for item in spec.get("init_source_evidence") or [] if str(item).strip()] if not evidence: fail("init.sh content requires init_source_evidence from official repository or documentation") scripts_dir.mkdir(exist_ok=True) lines = [ "#!/bin/bash", "", "# Generated from official installation evidence:", *[f"# - {item}" for item in evidence], "", ] if commands: lines.extend(commands) ``` The resulting script is subsequently written to disk and made executable: ```python init_path = scripts_dir / "init.sh" init_path.write_text("\n".join(lines), encoding="utf-8") init_path.chmod(0o755) ``` ### Technical Analysis The generator accepts the `init_commands` array from the input JSON specification and copies every entry verbatim into a Bash script. There is no command allowlist, shell-token validation, metacharacter filtering, or structured representation of permitted initialization operations. The only security gate is the presence of at least one non-empty `init_source_evidence` string. The generator does not validate that the evidence URL is project-owned, that it exists, or that it supports the supplied command. An attacker can therefore provide an arbitrary evidence string while embedding shell operators, command subst ...[truncated 1511 chars]- Remediation
View remediation
