T09 · Insecure Skill Coding Practices
- Location
scripts/model_manager.py:8- Finding
Shell Command Injection Through Unvalidated Model IDs
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a coherent OpenClaw model manager, but its script can turn a crafted model name into arbitrary local shell command execution.
Review before installing. Only use trusted, exact model IDs, and do not pass model names copied from untrusted text. The publisher should replace shell=True with argument-list subprocess calls, validate model IDs, and add a confirmation or policy check for model-changing commands.
scripts/model_manager.py:8Shell Command Injection Through Unvalidated Model IDs
This is a tool-parameter abuse issue because the tool exposes a shell execution primitive whose effective behavior is controlled by caller-supplied parameters. In a model-management skill, that is especially risky because user-facing parameters that should only select a model can instead be abused to escape the intended command and execute arbitrary system actions.
def run_cmd(cmd):
"""Run command and return output"""
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=True)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
return f"Error: {e.stderr.strip()}"
set_model, add_fallback, and remove_fallback interpolate model_id directly into a shell command string that is later executed by subprocess.run with shell=True. This creates straightforward command injection: a crafted model_id containing characters like ';', '&&', '$()', or backticks could run arbitrary OS commands, not just model-management operations.
The skill instructs the agent to execute shell commands but does not declare any explicit tool scope such as allowed-tools or permissions. This creates a governance gap: an agent/runtime may permit broader shell use than intended, making it easier for a prompt-influenced invocation path to run commands without clear policy boundaries. Because the skill manages configuration files and model selection, misuse could alter service behavior, increase cost, or disrupt availability.
The helper executes arbitrary shell strings with shell=True, which is dangerous because several callers build that string using untrusted model_id input. An attacker who can influence model_id can inject shell metacharacters and execute arbitrary commands with the privileges of the skill process.
def run_cmd(cmd):
"""Run command and return output"""
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=True)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
return f"Error: {e.stderr.strip()}"
This skill performs state-changing model operations immediately once invoked, with no in-script confirmation, warning, or policy enforcement. In an agent environment, that increases the chance of unintended configuration changes, especially because the metadata says the skill should only be used after explicit user instruction, but the code itself does not enforce that requirement.
No suspicious patterns detected.