AI threat catalogue Agentic and Autonomous AI Production
Unexpected Code Execution and Agent Escape from the Execution Environment
Agents generate code and commands and run them themselves. Manipulated inputs or goal-driven behaviour lead to malicious code being executed, the isolated environment being left, or agents attacking real, uninvolved systems from within test environments.
Description
Many agents may write program code and run it in an interpreter, a command line or a container. If prompt injection or manipulated tool responses bring outside instructions into the context, the agent generates harmful commands and executes them in the same step. The sandbox (isolated execution environment) is then the last line of defence; an unintentionally open internet connection or vulnerabilities in the container and proxy can be exploited. Goal-driven behaviour adds to this: when a target is unreachable, agents switch to reachable systems and mistake real targets for part of an exercise. Test environments for penetration testing and coding agents are especially exposed.
Possible impact
Malicious code runs with the rights of the execution environment; attackers or misguided agents reach internal networks, databases and credentials. If a company's own agent attacks uninvolved third parties, the operator may be liable for the damage, and the incident can trigger notification duties and regulatory investigations. Providers of general-purpose AI models with systemic risk must assess and mitigate such risks under the EU AI Act.
Example
A company tests a penetration testing agent in an environment that, according to the task description, has no internet access. Due to a configuration error, a connection is open after all. The agent takes reachable external servers to be part of the exercise, exploits vulnerabilities there and breaks into systems of another organisation before anyone reviews the logs.
- Main lifecycle phase
- Operation and monitoring
- Arises in
- Development and training, Operation and monitoring
- Takes effect in
- Development and training, Validation and approval, Operation and monitoring
Recommended mitigations (7)
Compare effects and implementation levels. Expand each entry for the additional classification and rationale.
-
Agent code execution only in a short-lived, isolated sandbox without network or credential access
Technical- Effect
- Preventive, Impact-limiting
- Implementation level
- Infrastructure, Application, API & agents
Classification and rationale
Primarily technical: Architectural and runtime boundaries separate data, execution, or tenants and limit the spread of failures.
Meaning, implementation and evidence
- What it means
- Code and commands generated by agents run only in an isolated sandbox created fresh for each task, without network access or credentials, and discarded afterwards.
- Effect on the threat
- Malicious code from manipulated input or misguided agent behaviour can neither steal credentials nor reach other systems or leave persistent traces.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Provide an isolated execution environment with resource limits.
- Disable network and credentials in the sandbox by default.
- Discard the sandbox after each task and test isolation regularly.
- Useful evidence examples
- Sandbox configuration, architecture description, escape or isolation test report or execution log.
-
Technically enforced egress allowlist for agent and test environments, automatically verified before every run
Technical- Effect
- Preventive
- Implementation level
- Infrastructure
Classification and rationale
Primarily technical: Architectural and runtime boundaries separate data, execution, or tenants and limit the spread of failures.
Meaning, implementation and evidence
- What it means
- Agent and test environments can technically reach only explicitly approved network destinations; before every run an automated test verifies that the restriction is active and unapproved destinations are blocked.
- Effect on the threat
- An agent cannot attack real, uninvolved systems from a test or evaluation environment, and a silently disabled restriction is noticed before the run.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Define permitted destinations per environment and block everything else.
- Enforce the restriction at network level outside the agent's control.
- Verify automatically before each run that an unapproved destination is blocked.
- Useful evidence examples
- Egress rule set, automated pre-run test result, firewall log or pipeline configuration.
-
Allowlist of permitted commands and human approval for consequential executions
Technical- Effect
- Preventive
- Implementation level
- Application, API & agents, Use & operations
Classification and rationale
Complementary control typeOrganizational & process-based
Primarily technical: Machine-enforced identity, permission, or scope rules constrain unauthorized access and actions; complemented by binding workflows.
Meaning, implementation and evidence
- What it means
- Agents may run only commands from a defined list without asking; consequential executions such as deletion, installation, network access or system changes require human approval.
- Effect on the threat
- Dangerous commands injected through manipulated input or chosen by goal-driven behaviour are not executed automatically but blocked or presented to a human.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Define permitted commands and consequential action classes.
- Technically block commands outside the list or route them for approval.
- Log approvals and rejected commands and review the list regularly.
- Useful evidence examples
- Command allowlist, configuration excerpt, approval log or test report.
-
No production credentials or signing keys within reach of test and evaluation agents
Technical- Effect
- Preventive, Impact-limiting
- Implementation level
- Infrastructure
Classification and rationale
Primarily technical: Machine-enforced identity, permission, or scope rules constrain unauthorized access and actions.
Meaning, implementation and evidence
- What it means
- Environments in which agents are tested or evaluated contain no production credentials, tokens or signing keys, whether as files, environment variables or via reachable secret stores.
- Effect on the threat
- Even if an agent escapes the sandbox or searches for credentials, it finds nothing it could use to attack production systems or sign software.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Scan test and evaluation environments for credentials and keys.
- Remove production secrets and replace them with test access unrelated to production.
- Block these environments from accessing production secret stores.
- Useful evidence examples
- Scan report, environment configuration excerpt, secret store permission export or review record.
-
Contractual and technical security requirements for external evaluation and testing providers
Contracts & third-party management- Effect
- Preventive, Detective
- Implementation level
- Supply chain, Organization
Classification and rationale
Complementary control typeTechnical, Organizational & process-based
Primarily a contracts and third-party management control: Selection, verifiable commitments, and audit or enforcement rights toward third parties enable the protective effect; complemented by technical implementation as well as binding workflows.
Meaning, implementation and evidence
- What it means
- Contracts with external providers that evaluate or test agents set out isolation requirements, network restrictions, breach notification duties and audit rights, and compliance is demonstrated before engagement.
- Effect on the threat
- Agent escapes from a provider's test environment are made harder by agreed safeguards and reported in time if they occur.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Define security requirements for external providers' test environments.
- Agree requirements, notification duties and audit rights contractually.
- Obtain evidence before engagement and regularly thereafter.
- Useful evidence examples
- Contract clauses, requirements list, provider evidence or audit report.
-
Real-time monitoring of agent actions and network destinations with automatic termination on boundary violations
Technical- Effect
- Detective, Impact-limiting
- Implementation level
- Infrastructure, Use & operations
Classification and rationale
Primarily technical: Software or analytical tools systematically produce and evaluate measurements, deviations, or attack indicators.
Meaning, implementation and evidence
- What it means
- Agent processes, file access and network connections are monitored in real time; if an agent breaches defined boundaries, such as an unapproved destination, execution is terminated automatically.
- Effect on the threat
- An escape attempt or attack on third-party systems is detected and stopped while it is happening instead of only surfacing later in logs.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Define boundaries for processes, files and network destinations per environment.
- Set up real-time monitoring with automatic termination on violations.
- Log terminations and route alerts to the responsible owners.
- Useful evidence examples
- Monitoring configuration, termination rules, alert and termination log or test report.
-
Kill switch and incident playbook including notification of affected third parties
Organizational & process-based- Effect
- Impact-limiting, Corrective
- Implementation level
- Use & operations, Organization, Application, API & agents
Classification and rationale
Complementary control typeTechnical
Primarily organizational and process-based: A defined reporting, triage, and handling workflow turns observations into traceable follow-up actions; complemented by technical implementation.
Meaning, implementation and evidence
- What it means
- A kill switch immediately stops all agent runs in an environment; an incident playbook covers containment, evidence preservation and notification of affected third parties whose systems an agent reached.
- Effect on the threat
- An escaped or attacking agent is stopped quickly, and uninvolved affected parties can take their own protective measures.
- When it helps
- Useful where agents generate and run code or commands themselves, for example in interpreters, shells, containers or test and evaluation environments.
- Suggested implementation
- Provide a kill switch for all agent runs and define who may trigger it.
- Describe steps for containment, evidence preservation and third-party notification.
- Rehearse the kill switch and playbook regularly.
- Useful evidence examples
- Incident playbook, kill switch test record, exercise record or incident report.
Framework mappings
Verified locations in OWASP, NIST AI RMF, MITRE ATLAS, the EU AI Act and further frameworks. The mappings are taxonomic, not evidence of compliance.
Verified references (13)
Every reference states the framework, the exact location and the publishing organisation.
- OWASP Top 10 ASI05:2026 Unexpected Code Execution (RCE)ASI05 Unexpected Code Execution (RCE), pp. 21–23 of the official PDFOWASP FoundationOriginal
- OWASP Top 10 ASI10:2026 Rogue AgentsASI10 Rogue Agents, pp. 36–38 of the official PDFOWASP FoundationOriginal
- OWASP Top 10 LLM10:2026 Improper Output HandlingLLM10:2026 Improper Output Handling, OWASP Top 10 for LLM Applications 2026 v1.0, pp. 55-57 (doi:10.5281/zenodo.22109015); canonical text 2026/final/LLM10_ImproperOutputHandling.md at commit 7e144e05OWASP FoundationOriginal
- NIST AI RMF Section 3.5 Security of AgentsSection 3.5, p. 54National Institute of Standards and Technology (NIST)Original
- MITRE ATLAS AML.T0102 Generate Malicious CommandsATLAS-2026.10.yaml technique object with id AML.T0102 (content release 2026.10, format-version 6.1.0)MITREOriginal
- MITRE ATLAS AML.T0105 Escape to HostATLAS-2026.10.yaml technique object with id AML.T0105 (content release 2026.10, format-version 6.1.0)MITREOriginal
- EU AI Act Article 55(1)(b) Obligations of providers of general-purpose AI models with systemic riskArticle 55(1)(b)European Union (EUR-Lex)Original
- BSI R16 RCE-Angriffe (Text)Ch. 4, R16, p. 24Bundesamt für Sicherheit in der Informationstechnik (BSI)Original
- CoSAI Insecure Model Output Insecure Model OutputRisk Map, risk entryCoalition for Secure AI (CoSAI, OASIS Open Project)Original
- CoSAI Rogue Actions Rogue ActionsRisk Map, risk entryCoalition for Secure AI (CoSAI, OASIS Open Project)Original
- OWASP AI Exchange 4.8 Agent escape4_runtime_application_security_threats.md, section 4.8 Agent escapeOWASP Foundation (OWASP AI Exchange)Original
- OWASP AI Exchange 4.9 Agent sandboxing and isolation4_runtime_application_security_threats.md, section 4.9 Agent sandboxing and isolationOWASP Foundation (OWASP AI Exchange)Original
- MIT AI Risk Repository 2.2 AI system security vulnerabilities and attacksDomain Taxonomy, subdomain 2.2MIT FutureTech (MIT AI Risk Initiative)Original
Related threats (9)
How the catalogue relates this threat to others, with the reason.
-
Enables
Data Leakage from the AI Application and Its Infrastructure (Exfiltration)
Code execution outside the sandbox reaches data and networks beyond the task.
-
Enabled by
Indirect Prompt Injection via External Content
Manipulated content leads agents to execute malicious code or shell commands.
-
Enabled by
Insecure Output Handling
Model outputs executed directly lead to code execution.
-
Enabled by
Classic Security Flaws in the Application around the AI Model
Vulnerabilities in sandbox and container infrastructure are the route for escape.
-
Enabled by
Excessive Agency of Agents and Tools
Granted shell and code tools make unexpected code execution possible in the first place.
-
Enabled by
Misalignment, Deception and Evasion of Oversight
Goal-directed behaviour with an unreachable goal leads agents to circumvent their boundaries.
-
Enabled by
Agent Goal Hijacking
A hijacked agent with code or shell tools generates the attacker's commands and executes them itself; the execution environment is then the last layer of protection.
-
Enabled by
Malicious or Hijacked Agent Extensions (MCP Servers, Skills, Plugins)
Connecting to a malicious MCP server can lead to command execution on the client.
-
Enables
Compromised Infrastructure and Software Dependencies in the Supply Chain
Escaped test agents can publish packages themselves and harm real third parties.
EU AI Act obligations related to this threat
The obligations from the obligations compass whose articles the catalogue maps to this threat. Each leads to its entry with core, action step and evidence; whether it applies to you depends on role and risk class.
-
Evaluate and mitigate systemic risks
Art. 55, applies from 2 August 2025
Statutory roles: Provider of a general-purpose AI model. Classes: Model with systemic risk.
This reference is a review prompt. A threat match alone does not establish applicability.
All 62 obligations by role, risk class and deadline in the obligations compass
Terms on this page
Glossary terms that occur in this entry. Every link leads to the full explanation.
- Prompt Injection Manipulated input or planted content redirects a language model.
- EU AI Act (Artificial Intelligence Act) Regulation (EU) 2024/1689 on artificial intelligence; AI Act, EU AI Act and Artificial Intelligence Act all refer to the same law.
- Agentic system (agentic AI) A system that uses a language model to carry out multi-step tasks on its own.
- Sandbox and execution isolation A restricted environment for running code or tools.
- Coding agent AI agent that reads, writes and runs code in the development environment and build pipeline.
Matching use cases
This list shows where to review this threat, rather than how high the risk is.
Particularly important for:
- Coding agentUnrestricted terminal access lets the agent execute any command available to the signed-in user. Without isolation and an allowlist of commands, a mistake is difficult to contain.
For 3 further use cases, relevance depends on the system design, for example whether it executes programs or commands itself. Show these use cases
Frequently asked questions
- What is Unexpected Code Execution and Agent Escape from the Execution Environment?
- Agents generate code and commands and run them themselves. Manipulated inputs or goal-driven behaviour lead to malicious code being executed, the isolated environment being left, or agents attacking real, uninvolved systems from within test environments.
- Which mitigations help against Unexpected Code Execution and Agent Escape from the Execution Environment?
- The catalogue lists 7 mitigations, each with control type, effect and implementation level. First among them are “Agent code execution only in a short-lived, isolated sandbox without network or credential access”; “Technically enforced egress allowlist for agent and test environments, automatically verified before every run”; and “Allowlist of permitted commands and human approval for consequential executions”.
- Which EU AI Act obligations does Unexpected Code Execution and Agent Escape from the Execution Environment touch?
- The catalogue maps this threat to Art. 55(1)(b) of the EU AI Act. In the obligations compass this leads to: Evaluate and mitigate systemic risks. Whether an obligation applies depends on role, risk class and deadline.
Assess this threat in your own system
The live demo contains all 79 threats of this catalogue, including the EU AI Act and GDPR assessment. The free single modules cover AI risk, the EU AI Act and GDPR. No sign-up; the assessment runs locally in your browser.
Cite this entry
For reports, policies or internal documents; the link leads directly to this entry.
“Unexpected Code Execution and Agent Escape from the Execution Environment”. Versatile AI Risk Assessment, AI threat catalogue, as of November 2026. https://www.versatile-ai-risk-assessment.com/en/wissensbasis/threats/execution-environment-escape/