Command Execution

Skills that run arbitrary system commands, giving attackers a shell on your machine through your AI agent

12 detection rules 89 skills affected →

What is command execution?

Command execution vulnerabilities occur when a skill can run arbitrary operating system commands on the host machine. This is the most direct path from compromised skill to compromised computer. A skill that invokes shell-level functions (exec, eval, popen, system calls) or uses process-spawning libraries with attacker-influenced input gives the attacker a shell.

In the AI agent context, the attacker-influenced input is often the agent itself. The agent interprets a prompt-injected instruction, then passes it to a skill with command execution capabilities. The skill dutifully runs whatever the agent tells it to.

Aguara detects both direct patterns (skills that invoke shells or process-spawning APIs) and indirect ones (skills that build command strings from template variables, use eval-like constructs, or chain together in ways that produce command execution as an emergent behavior). The INDIRECT_010 rule specifically catches cases where command execution arises from the interaction between multiple skills rather than a single one.

Why this matters for AI agents

Most AI agent frameworks run on the user local machine or in a cloud environment with broad permissions. The agent typically has the same file system access, network access, and credential access as the user who launched it. When a skill executes a command, that command runs with all of those permissions.

This is fundamentally different from a web application vulnerability. A command injection in a web app is limited by the web server user permissions, network segmentation, container isolation. An AI agent running on a developer laptop can read SSH keys, access cloud credentials, modify source code. There is usually zero isolation between the agent and the developer full environment.

The compounding risk with MCP is that users connect agents to multiple servers simultaneously. A skill from a trusted MCP server might be perfectly safe on its own, but when combined with a malicious skill from another server that injects commands through the agent, the trusted skill becomes the execution vector.

Real-world examples

A file management skill accepts a path parameter and passes it directly to a system-level call (like running "ls -la " concatenated with the user-provided path). An attacker crafts a path value containing shell metacharacters to chain additional commands. The agent does not understand shell metacharacters. It just passes the string through.

A code runner skill wraps Python eval() and advertises itself as a safe sandbox. But it does not restrict imports, does not block OS-level calls, and does not limit file system access. An agent using this skill can be tricked into running dangerous imports through a prompt injection in an unrelated skill.

A DevOps automation skill constructs docker commands from user parameters without sanitization. An attacker skill injects a --privileged flag and a volume mount of the host root filesystem through the agent context, turning a container management utility into a host compromise vector.

How to protect against it

If your skill needs to execute commands, use allowlists rather than blocklists. Define exactly which commands are permitted, with exactly which arguments, and reject everything else. Never construct commands by concatenating strings. Use parameterized execution (pass arguments as arrays, not shell strings) and validate every input against a strict schema.

Sandboxing matters. If your skill runs code, run it in a container, a VM, or at minimum a restricted user account with no network access and a read-only filesystem. The overhead is worth it. A skill that can only write to /tmp and cannot reach the network is dramatically safer than one that inherits the user full permissions.

As a user, be deeply skeptical of any skill that requests shell access or code execution capabilities. Check whether it invokes shell-level functions or process-spawning APIs. If it does, verify that inputs are validated and execution is sandboxed. If you cannot verify these things, do not install the skill.

Aguara detection rules (12)

MEDIUM
Shell subprocess with shell=True CMDEXEC_001

Detects subprocess calls with shell=True which enables shell injection

MEDIUM
Dynamic code evaluation CMDEXEC_002

Detects eval() or exec() used for dynamic code execution

MEDIUM
Python subprocess execution CMDEXEC_003

Detects Python subprocess and os.system calls for command execution in skill descriptions

MEDIUM
Node.js child process execution CMDEXEC_004

Detects Node.js child_process methods for command execution

HIGH
PowerShell command execution CMDEXEC_007

Detects PowerShell Invoke-Expression, Start-Process, and related execution commands

MEDIUM
Terminal multiplexer command injection CMDEXEC_008

Detects tmux/screen send-keys used to inject commands into terminal sessions

MEDIUM
Agent shell tool usage CMDEXEC_009

Detects skills instructing agents to use Bash/shell tools for command execution

MEDIUM
MCP code execution tool CMDEXEC_010

Detects MCP tools that execute arbitrary code

MEDIUM
Cron or scheduled command execution CMDEXEC_011

Detects cron jobs or scheduled tasks that execute commands

LOW
Chained shell command execution CMDEXEC_012

Detects chained commands using shell operators with dangerous operations

LOW
Shell script file execution CMDEXEC_013

Detects execution of shell script files via bash/sh command or direct invocation

LOW
Unscoped Bash tool in allowed tools INDIRECT_010

Detects skills that include unscoped Bash in their allowed tools list (not Bash(cmd:*) scoped)

Want to check if your skills have command execution issues?

Scan now (free, runs in your browser)