Command Injection via Agent Approval is an attack pattern where an AI agent is tricked into approving or executing a harmful command through manipulated prompts, tool output, or delegated instructions. It affects agent workflows that can call tools, run shell commands, or trigger actions, and it exploits weak approval boundaries, poor command validation, or overbroad runtime authority.
How Command Injection via Agent Approval Works
This attack pattern abuses the moment an AI agent seeks or receives approval, because that boundary often feels like a human control even when the underlying command text, arguments, or tool output has already been influenced. The danger is not only execution of a bad command, but also the false confidence created when a review step exists but does not actually validate what the agent will do.
In practice, the attacker tries to shape the command path before approval is granted, or to smuggle harmful intent through a payload that looks routine at review time. That makes approval itself part of the attack surface, especially when the agent can generate shell commands, chain tools, or convert untrusted text into executable action.
Why Approval Boundaries Fail
Approval fails when the reviewer sees an abstract summary instead of the exact command, when arguments are assembled after approval, or when the agent is allowed to reinterpret the approved intent. A weak boundary can turn a human checkpoint into a rubber stamp, especially if the workflow rewards speed over scrutiny.
Agent approval is also vulnerable to prompt injection and tool-output manipulation. If a malicious instruction reaches the agent through retrieved content, tickets, documents, logs, or upstream tool responses, the agent may treat that instruction as context rather than attacker-controlled input, then propose a command that preserves the injected meaning while appearing legitimate.
The safest approval model is the one that binds the decision to the final executable action, not to a loose natural-language intention. When that binding is absent, approval becomes a governance signal instead of an actual control.
Command Validation and Runtime Authority
Command injection through approval is especially dangerous where the agent has broad runtime authority. A shell-enabled agent, a privileged automation runner, or a tool that can reach internal systems can turn one bad command into file access, data exfiltration, account changes, or destructive action.
Validation has to cover the exact command structure, not just the surrounding text. That means treating separators, flags, path arguments, environment expansion, and chained subcommands as security-relevant, because attackers often use them to transform a seemingly safe request into a different operation.
NHIMG’s Command Injection Guide is the most direct reference for understanding why OS command injection remains so effective across agent workflows, CI/CD systems, and other automation paths.
Detection and Post-Approval Review
Even with strong guardrails, organisations should assume some commands will be proposed and occasionally executed under suspicious conditions. Detection should therefore focus on mismatches between the approved intent and the actual command, unusual parent-child process chains, unexpected network activity, and tool calls that occur after a prompt or output source has been tainted.
Post-approval review matters because an approved command can still be malicious if the approval step was manipulated. That review should ask whether the command was derived from untrusted content, whether the arguments changed between review and execution, and whether the agent’s tool trail shows signs of injected control flow or hidden delegation.
For broader injection patterns, the Web Application Attacks Guide and the OWASP Top 10 A05 Guide help place command injection in the wider family of injection failures that begin with untrusted input and end with unintended execution.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V8 — Authorization | Agent approval is an authorization decision over tool execution. |
| Recommendation — Bind approval to the exact executable action and enforce least-privilege authorization before the tool runs. | ||
| CIS Controls v8 | CIS-6 — Access Control Management | Commands through agents succeed when execution rights are broader than needed. |
| CIS-16 — Application Software Security | The pattern is an injection flaw in an automation/application control flow. | |
| Recommendation — Restrict agent execution paths to only the tools and commands required for the task. Validate untrusted input before it reaches command construction or execution logic. | ||
| MITRE ATT&CK | T1059 — Command and Scripting Interpreter | The attack executes harmful OS commands through an interpreted command path. |
| Recommendation — Map agent command execution paths to T1059 and hunt for abnormal process creation. | ||
Practitioner Guidance
Why practitioners should care: Approval is only protective when it is bound to the exact action that will execute. If the agent can rephrase, reassemble, or defer command construction after the review step, the approval is not really controlling execution, it is only observing intent.
What to watch for: Treat any design that approves “what the agent should do” rather than the final command as suspect. Stronger patterns require the reviewer to see the exact arguments, the target tool, and the execution context before the action is released.
NHIMG’s Synchronous Approval vs Asynchronous Review of Agent Actions is useful when deciding which agent actions deserve a hard stop versus a later audit.
NHIMG’s AI Agent Action Approvals and Spending Limits Guide adds the practical control lens for defining approval boundaries, escalation thresholds, and action-level constraints.
NHIMG’s AML.T0102 Generate Malicious Commands is a strong companion for understanding how agents and malware can be pushed toward harmful command generation and why validation must happen before execution.
External guidance is especially helpful here, because the threat is part agent security and part classic injection defense. The OWASP Agentic AI Top 10 captures the approval, tool misuse, and privilege-abuse patterns that make this attack pattern so persistent, while the MITRE ATLAS adversarial AI threat matrix provides the technique-level lens for tracking how hostile inputs alter agent behaviour.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 16, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org