Command Injection
Agent passes unsafe user/tool input into shell/API commands.
19 patterns for this goal
Security-autonomy fails when agents with broad tool access, file handling, and code-execution capabilities are compromised via prompt injection, tool-output injection, or supply-chain attackβexecuting unauthorized commands, exfiltrating data, or escalating privileges before detection. An agent designed to autonomously complete tasks gets a prompt-injected request embedded in retrieved document and executes a data-exfiltration command, an agent chaining tool outputs together does not validate intermediate outputs and an attacker injects malicious commands via tool output that agent blindly executes, and an agent updates dependencies without verification and a supply-chain-poisoned package introduces backdoors into agent reasoning. Security-autonomy failures matter precisely because autonomy amplifies the impact of compromises: a compromised agent that can execute code, invoke tools, handle files, and escalate privileges is far more dangerous than one with limited autonomous capabilities.
Effective security-autonomy requires treating autonomous capability as privilege requiring defense in depth: every autonomous action (file access, code execution, tool invocation, command execution) must be preceded by validation, authorization, and sandboxing. The shared lesson is that autonomy without verification is dangerous: an agent that can invoke any tool without authorization, execute any code without sandboxing, or handle any file without validation is fundamentally exploitable. The fix is restricting autonomous actions to a pre-approved, minimal set, validating every input (user, file, tool-output) before autonomous action, and sandboxing code/command execution so compromised agents cannot escalate impact beyond their sandbox.
Input validation and sandboxing are required: (1) mark user input as untrusted, (2) separate user-input from trusted system prompts using structural markers, (3) validate user input against patterns (reject input containing suspicious tokens like “ignore above instructions”), (4) limit autonomous action based on user input alone (require additional human approval or automated verification before executing user-suggested actions), (5) test adversarial inputs to verify injection attempts are caught.
Tool sandboxing limits what a tool can do, but does not prevent tool-output injection: if an agent receives tool output and executes commands embedded in that output, sandboxing does not help. Defense requires: (1) tool-output validation (parse tool output for expected schema, reject malicious patterns), (2) separating data from commands (tool output is data, not executable code), (3) restricting what commands an agent can execute (allowlist of pre-approved commands only, reject novel commands).
File handling requires defense in depth: (1) validate file type and size before processing, (2) scan files for malicious patterns (malware, suspicious embeddings), (3) parse files safely without executing embedded code or instructions, (4) isolate file content from agent reasoning (file data is input, not executable instructions), (5) restrict agent file-system access (read-only access to quarantined directory, no write access to system files).
Audit agent credential usage: what credentials does agent currently use, what resources does agent access with those credentials, what resources could agent access (permissions) that it actually doesn’t use. Down-scope credentials to minimal set actually needed. Implement just-in-time credential provisioning: agent requests temporary access to resource, receives scoped credential for specific action only, credential expires after action completes. This limits blast radius if credentials are compromised.
| Pattern | Mechanism | Frequency |
|---|---|---|
| Command Injection | Attacker injects malicious commands via input parameters | Common |
| Credential Leakage In Logs | Credentials leak via logs or error messages | Common |
| Cross Tenant Data Leak | One agent’s actions leak sensitive data from another tenant | Occasional |
| Data Exfiltration | Compromised agent exfiltrates data via autonomous tool invocation | Common |
| Direct Prompt Injection | Attackers inject malicious instructions via user input | Common |
| Fine-Tuning Data Poisoning | Training data is poisoned to introduce unsafe behavior | Occasional |
| Indirect Prompt Injection | Attackers inject malicious instructions via retrieved context or files | Common |
| Insecure Output Handling | Agent output containing sensitive data exposed to unauthorized parties | Occasional |
| Malicious File Handling | Agent processes malicious files and executes embedded attacks | Occasional |
| Model Denial Of Service | Attacker sends input crafted to exhaust model compute | Occasional |
| Over Scoped Credentials | Agent has overly broad permissions enabling damage when compromised | Common |
| Privilege Escalation | Compromised agent escalates permissions to perform unauthorized operations | Occasional |
| Prompt Injection Via User Context | User context or history contains injected malicious instructions | Common |
| Secret Exposure | Secrets (API keys, passwords) exposed via agent output or logs | Common |
| Supply Chain Vulnerability | Compromised dependencies or malicious packages introduce unsafe behavior | Occasional |
| Tool Output Injection | Attacker injects malicious commands via tool output that agent executes | Common |
| Uncontrolled Destructive Actions | Agent takes destructive actions without approval or validation | Occasional |
| Uncontrolled Tool Chaining Attack | Agent chains tools without validating intermediate outputs | Occasional |
| Unsafe Code Execution | Agent executes code without sandboxing or input validation | Common |
Total: 19 patterns
Agent passes unsafe user/tool input into shell/API commands.
API Keys, Passwords, Tokens Exposed in Logs or Error Messages
Agent mixes data across customers/accounts.
Agent leaks private or sensitive data.
User prompt manipulates agent to ignore instructions.
Poisoned Training Data Causes Agent to Behave Maliciously or Unreliably After Fine-Tuning
Malicious webpage/email/PDF/doc controls agent through retrieved content.
Downstream system executes unsanitized LLM output.
Agent processes adversarial/weaponized documents or files.
Input causes excessive cost/latency or service exhaustion.
Agent has broad access when narrow scope was enough.
Agent gains or uses higher permissions than intended.
Attacker Injects Malicious Instructions Through User-Provided Input Without Sanitization
API keys/tokens/private URLs leak through answer/log/tool.
Agent uses compromised tool, plugin, package, MCP server, or model dependency.
Tool response includes instructions that agent follows.
Agent Executes Irreversible Operations (Delete, Destroy, Drop) Without User Approval
Attacker Chains Legitimate Tools in Unintended Sequences to Bypass Controls
Agent runs generated code without sandboxing.