T09 · Insecure Skill Coding Practices
- Location
tools/exec.js:5- Finding
Unrestricted Shell Command Execution Through Caller-Controlled Input
- Content
View full analysis
Vulnerability Details
File Location:
tools/exec.js, lines 5-11
Vulnerability Type: OS command injection and unrestricted shell execution
Risk Level: HighVulnerable Code
js module.exports = async (command, options = {}) => { try { const { stdout, stderr } = await execAsync(command, { cwd: options.cwd || process.cwd(), env: { ...process.env, ...options.env }, timeout: options.timeout || 30000 });Technical Analysis
The exported tool passes the caller-controlled
commandstring directly to Node.jschild_process.exec. This API executes the supplied string through a system shell, so shell operators and constructs such as command chaining, pipelines, redirects, variable expansion, and command substitution are interpreted.No executable allowlist, argument validation, shell-metacharacter rejection, authorization check, or confirmation mechanism is implemented. The caller may also override the working directory and add or replace environment variables. Although
SKILL.mdstates that sensitive operations require confirmation, this requirement is not enforced by the code.Attack Path
- An attacker directly supplies, or causes prompt-injected content to influence, the
commandtool argument. - The Agent invokes the exported
exectool with the attacker-influenced string. execAsyncpasses that string to a system shell without validation.- The shell interprets all included commands, substitutions, redirects, and chained operations.
- The commands execute with the operating-system privileges of the process hosting the Skill.
For example, input presented as a benign diagnostic command could append an additional command through shell chaining. No second authorization boundary prevents execution of the appended operation.
Impact Assessment
Successful exploitation permits arbitrary command execution with the privileges of the host Agent ...[truncated 370 chars]
- An attacker directly supplies, or causes prompt-injected content to influence, the
- Remediation
View remediation
Remediation Suggestions
- Replace
child_process.execwithexecFileorspawnusing a fixed executable and a separately constructed argument array. - Define a narrow allowlist of permitted executables and validate every argument against command-specific rules.
- Do not accept arbitrary shell syntax. Reject shell metacharacters, redirects, substitutions, and command separators if shell execution cannot be completely removed.
- Require explicit, independently verified user approval before any destructive, sensitive, or state-changing operation.
- Restrict
cwdto approved directories and prevent arbitrary environment-variable overrides. - Run the Skill in a sandboxed, least-privileged account with constrained filesystem and network access.
- Add security tests covering command chaining, command substitution, redirects, malicious environment values, and unauthorized working directories.
- Replace
