T09 · Insecure Skill Coding Practices
- Location
SKILL.md:23- Finding
Shell Command Injection Through User-Controlled Calculator Argument
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 23-26
Vulnerability Type: OS command injection
Risk Level: HighThe skill instructs the agent to place a user-supplied mathematical expression into a shell command executed through the
exectool. The documented example is:bash python /root/.openclaw/workspace/skills/my_tools/calc.py “23 * 45 + 100”Technical Analysis
The expression originates from an untrusted user and is inserted into a shell command without a required validation or escaping procedure. Moreover, the example uses typographic quotation marks (
“and”), which Unix shells do not recognize as quoting characters. Shell metacharacters contained in the expression can therefore be interpreted by the shell rather than passed exclusively tocalc.py.Even if an implementation replaces the typographic marks with ordinary quotation marks, command injection remains possible if it builds a command string by direct concatenation and an attacker includes a matching quote in the expression.
Attack Path
- An attacker submits a calculation request containing shell syntax, such as
1; id; #. - The agent follows
SKILL.mdand interpolates that expression into the documented command. - The shell treats the semicolons as command separators because the typographic marks provide no shell quoting.
calc.pyis invoked with the first fragment, after which the injectedidcommand executes.- An attacker could replace the proof-of-concept command with commands that read or alter files, inspect environment variables, or invoke other locally available programs.
Impact Assessment
Successful exploitation permits arbitrary command execution with the operating-system privileges of the agent or
execworker. The attacker could access any files, credentials, environment variables, and services available to that account, modify the workspace, or use the host's network access. This ...[truncated 156 chars]- An attacker submits a calculation request containing shell syntax, such as
- Remediation
View remediation
Remediation Suggestions
- Do not construct a shell command by concatenating user input.
- Invoke the interpreter through a structured argument array with shell processing disabled, equivalent to:
python subprocess.run( ["python", "/root/.openclaw/workspace/skills/my_tools/calc.py", expression], shell=False, check=True, capture_output=True, text=True, ) - Update the skill instructions to explicitly prohibit
shell=True, command-string interpolation, and typographic quotation marks. - Validate the expression against a strict arithmetic grammar before invoking any process.
- Apply length, numeric-size, execution-time, memory, and output-size limits.
- Run the calculator under a dedicated, unprivileged account with minimal filesystem and network access.
