Part 7 · Agentic AI Security
ASI05: Unexpected Code Execution
When an agent can write and run code, a sentence can become a program on your system.
What it is
Agentic systems, including coding assistants, often generate and execute code. Attackers can exploit these features to escalate into remote code execution, local misuse, or compromise of internal systems. Because code is generated in real time, it can bypass traditional security controls.
How the attack unfolds
The path runs from untrusted text, through the agent's file access, to code running on the machine.
Real-world case
CurXecute (CVE-2025-54135) affected the Cursor editor. Researchers showed that indirect prompt injection could write to an MCP configuration file and trigger command execution. It was fixed in 2025.
Defenses
- Sanitize generated code. Treat it as untrusted output.
- Ban unsafe evaluation. Avoid
evalin production agents. - Sandbox execution. Never run as root, and restrict network and file access.
- Separate from production. Do not let agents execute directly in live systems.
- Approve sensitive operations. Protect configuration files and privileged commands.
- Scan and monitor. Check code and packages, and log execution.
Common misconception
"Code execution only matters for coding agents."
Any agent with an interpreter, plug-in system, or unsafe deserialization path can be affected.
Key takeaways
- Generated code can turn prompt injection into code execution.
- Sandbox execution and remove unnecessary privileges.
- Protect sensitive files and configuration from automatic changes.