Risk · R-053 · Agentic & Autonomous Systems
Unexpected code execution by agents
An agent generates and runs code or commands that were never reviewed, allowing injected instructions or model error to execute on the host or in connected systems.
- Severity
- Critical
- Audience
- Heads-of · Practitioner
- Frameworks
- AML.T0050 · AML.T0105 · ASI05
- Responsible AI domain
- Lifecycle stage
- Reviewed
- 2026-11-10
What it is
Many agents write code and run it as part of their work: analysis scripts, shell commands, database queries, configuration. Whatever reaches that execution path runs with the agent's privileges on whatever machine the agent occupies. The risk is unreviewed execution. Vulnerable code that a person accepts from an assistant and ships is a different risk, covered in insecure AI-generated code.
How it happens
- Content the agent reads contains text that ends up inside a command it runs.
- The agent installs a package to complete a task, and the package is hostile.
- Generated code deserialises or evaluates data it was given.
- The agent runs on a developer's workstation or a build server with broad access.
Why it matters
Code execution is the most general capability an attacker can obtain. From it follow credential theft, movement to other systems, destruction of data and persistent access. It is rated critical because the consequence is not limited to the agent's own task.
Warning signs
- Agents execute code outside an isolated environment.
- The execution environment can reach the internal network or the internet without restriction.
- Agent processes start child processes that no task explains.
- Packages are installed at run time.
Who owns it
Security architecture owns the isolation standard. Engineering owns each agent's execution environment. The owner of the platform the agent runs on is accountable for what that environment can reach.
In practice
A data analysis agent is asked to chart a spreadsheet received from a third party. A cell contains text that the agent incorporates into the script it writes, and the script reads the environment's access keys and posts them to an external site. The same pattern generalises to any agent that turns untrusted input into something executable.
Mitigating controls
Primary controls
- Agent sandboxing and isolation Preventive
- Runs agent-generated code in an isolated environment with restricted access. Code execution and tool use by agents run in isolated environments with restricted network, file and system access, so that a failure is contained where it occurs.
Supporting controls
- Approval gates for high-impact agent actions Preventive
- Requires approval for execution outside the sandbox. Before an agent takes an action above a defined impact threshold, or one that cannot be reversed, a designated person reviews the exact action and approves or rejects it.
- Least-privilege agent identity and permissions Preventive
- Limits the privileges the code runs with. Each agent has its own identity, with permissions scoped to its task and to the user it is acting for, short-lived and reviewed like any other entitlement.
- Review of AI-generated code Detective
- Reviews generated code that will persist. Code produced with an AI assistant passes the same human review, security scanning and dependency checks as any other code before it is merged.
Framework and clause references
| Framework | Clause | Title |
|---|---|---|
| MITRE ATLAS | AML.T0050 | Command and Scripting Interpreter Command and scripting interpreter. |
| MITRE ATLAS | AML.T0105 | Escape to Host Escape to host. |
| OWASP Top 10 for Agentic Applications | ASI05 | Unexpected Code Execution The entry this risk is named for. |
Sources
- MITRE ATLAS MITRE · framework
Related terms
How to cite
Axiom Verity (2026). Unexpected code execution by agents. Reference Library, R-053. https://axiom-verity.com/risks/unexpected-code-execution-by-agents. Reviewed 2026-11-10.
Found an error or a better source? Report a correction.