T09 · Insecure Skill Coding Practices
- Location
scripts/ci_agent.py:192- Finding
Windows Command Injection Through Repository-Controlled CI Configuration
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Unity CI skill matches its stated purpose, but its bundled runner has unsafe command and file-path handling that users should review before installing.
Use this only with trusted Unity repositories and review ci_config.json before running it, especially on Windows. Prefer patching the runner to use argument-list subprocess calls with shell=False and constrain log/result paths to the project before using it in CI.
scripts/ci_agent.py:192Windows Command Injection Through Repository-Controlled CI Configuration
scripts/ci_agent.py:180Arbitrary File Overwrite Through Unrestricted Result File Path
The skill instructs users to run a Python CLI, copy files into a project, and invoke Unity batchmode builds, which clearly implies shell execution plus file read/write capability. Because the skill does not declare any tool scope or allowed-tools restrictions, an agent may execute these operations with broader privileges than intended, increasing the risk of unintended command execution or filesystem modification in an automated environment.
The module docstring presents the skill description, applicability, and usage primarily in Chinese, and similar Chinese-only user-facing text appears throughout the CLI. For a general-purpose CI tool described as applicable across platforms and Unity versions, this imposes a specific language without user opt-in or justification, which matches the language/locale policy violation criteria.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
# 3. fallback: 试试不带版本的 Unity 命令
for cmd in ["Unity", "unity"]:
try:
result = subprocess.run([cmd, "-version"], capture_output=True, text=True, timeout=10)
if result.returncode == 0:
return cmd
except:
The build/compile commands are constructed as a single shell command string using values from ci_config.json and runtime environment, then executed with shell=True on Windows. This enables command injection if an attacker can influence fields such as unity_path, execute_method, log_file, or the working directory context, because shell metacharacters can be interpreted by cmd.exe.
def run_command(cmd, timeout=600):
"""运行命令,返回 (success, stdout)"""
try:
result = subprocess.run(
cmd, capture_output=True, text=True, timeout=timeout,
cwd=os.getcwd(), shell=(platform.system() == "Windows")
)
The USAGE text shown to users is Chinese-only even though the tool is a cross-platform CLI intended for broad use. Because the file does not offer a language choice or explain a region-specific requirement, this is a natural-language locale policy issue.
This markdown file includes a code example that calls AssetDatabase.SaveAssets() and later instructs users to run python ci_agent.py build, both of which can change project state. The guide does not include any user-facing warning that these operations may write or persist changes to project files.
Lines L200-L202 state that the code ensures the Unity Editor is closed to avoid conflicts, yet the implementation is only a no-op pass. This is an active contradiction between inline intent documentation and actual behavior, not merely an omitted detail.
The file's user-facing comments and usage instructions are written entirely in Chinese, including setup and operational guidance. This imposes a specific language choice without offering an alternative or indicating that the skill is intentionally region-specific.
The comment text is written entirely in Chinese ('Unity CI Agent 配置文件 — 按项目自定义'), which imposes a specific language in a user-facing configuration context without indicating any language choice or locale-specific justification. This matches the policy category for language or locale constraints lacking user opt-in.