T09 · Insecure Skill Coding Practices
- Location
scripts/capture.py:63- Finding
Arbitrary Command Execution Through Shell-Based Server Configuration
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its visual testing purpose, but it can run project-provided server commands through a shell, which gives untrusted configs too much local execution power.
Use this only with trusted repositories or inside an isolated container/CI job. Review any .visual-qa.json server value before running it, avoid exposing unrelated secrets in the environment, pin dependencies for CI, and treat saved screenshots/diffs as sensitive artifacts. Do not run the documented rm -rf baseline update unless you have verified the exact target path.
scripts/capture.py:63Arbitrary Command Execution Through Shell-Based Server Configuration
scripts/diff.py:143Visual Regression Gate Can Pass When Expected Screenshots Are Missing
SKILL.md:196Unpinned Runtime Dependencies and Browser Installation Reduce Supply-Chain Integrity
The skill includes a raw rm -rf .visual-qa/baselines command, which is inherently dangerous because recursive force deletion bypasses safeguards and is easy to misuse in automated or agent-driven workflows. Even though the intended purpose is routine baseline refresh, path confusion, variable substitution in derived versions, or blind copy/paste can lead to destructive file deletion beyond the expected test assets.
rm -rf .visual-qa/baselines mv .visual-qa/current .visual-qa/baselines
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
"""Start a local development server."""
print(f"🚀 Starting server: {command}")
env = os.environ.copy()
env['PORT'] = str(port)
process = subprocess.Popen(
This duplicate finding identifies the same root issue: shell-based execution of a configurable command allows arbitrary command injection and host code execution. The surrounding skill context does not reduce risk, because a screenshot tool does not need unrestricted shell execution to perform its primary purpose.
env = os.environ.copy()
env['PORT'] = str(port)
process = subprocess.Popen(
command,
shell=True,
stdout=subprocess.PIPE,
This duplicate finding identifies the same root issue: shell-based execution of a configurable command allows arbitrary command injection and host code execution. The surrounding skill context does not reduce risk, because a screenshot tool does not need unrestricted shell execution to perform its primary purpose.
env = os.environ.copy()
env['PORT'] = str(port)
process = subprocess.Popen(
command,
shell=True,
stdout=subprocess.PIPE,
The documented workflow instructs users to delete the entire baseline directory before replacing it, but it does so without an explicit warning, confirmation step, or safer alternative. In an agent or CI-assisted context, destructive shell commands can be copied or executed automatically, causing unintended loss of testing artifacts and potentially broader damage if paths are modified or misresolved.
Although presented as a screenshot utility, the script also starts arbitrary local commands from --server or config using the shell. This expands the tool from passive capture into a general command-execution primitive, which is dangerous in automation or agent environments where users may not expect code execution.
The script executes a user/config-supplied server command via subprocess.Popen with shell=True, which allows shell metacharacter injection if the command string is influenced by untrusted input. In an agent skill context, this is especially risky because configuration or arguments may be attacker-controlled, leading to arbitrary code execution on the host running the skill.
env = os.environ.copy()
env['PORT'] = str(port)
process = subprocess.Popen(
command,
shell=True,
stdout=subprocess.PIPE,
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
stderr=subprocess.PIPE,
cwd=cwd,
env=env,
preexec_fn=os.setsid if os.name != 'nt' else None
)
# Wait for server to start
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
cmd.extend(['--port', str(port)])
print(f"🔧 Running capture...")
result = subprocess.run(cmd)
return result.returncode == 0
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
cmd.extend(['--port', str(port)])
print(f"🔧 Running capture...")
result = subprocess.run(cmd)
return result.returncode == 0
When --keep-current or --keep-diffs is used, the script persistently copies screenshots and visual diffs into predictable local directories without any warning that sensitive page content may be retained on disk. In a visual QA workflow, screenshots can easily contain secrets, internal UI states, PII, or environment-specific data, so silent retention increases the chance of accidental disclosure or later exfiltration.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
if args.keep_current:
keep_current_dir = '.visual-qa/current'
os.makedirs(keep_current_dir, exist_ok=True)
subprocess.run(['cp', '-r', f'{current_dir}/.', keep_current_dir])
print(f"\n📁 Current screenshots saved to: {keep_current_dir}")
if args.keep_diffs or not passed:
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
if args.keep_diffs or not passed:
keep_diff_dir = '.visual-qa/diffs'
os.makedirs(keep_diff_dir, exist_ok=True)
subprocess.run(['cp', '-r', f'{diff_dir}/.', keep_diff_dir])
print(f"📁 Diff images saved to: {keep_diff_dir}")
# Exit with appropriate code
This code writes a .temp-config.json file derived from the user's config, which may include URLs or server settings, but there is no disclosure that an additional config artifact will be created during execution. For code files, file writes should have some visible user disclosure unless they are clearly communicated; here only the later capture step is logged, not the temp file creation itself.
No suspicious patterns detected.