AI and LLM security

Unexpected code execution through AI agent workflows

Bounded actions: agent, tools, gate arranged to illustrate unexpected code execution through ai agent workflows.

Unexpected code execution can arise when model-generated content reaches a shell, interpreter or privileged runtime. Understanding unexpected code execution through AI agent workflows helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

An agent combines a model with tools, identity and the ability to progress through a task. Permissions and approvals need to constrain the actual operations performed, regardless of how convincingly the agent explains its plan.

Why it matters

Consider a realistic failure: an agent turns untrusted issue text into a local command.

A broad tool credential can turn an instruction-following failure into access to files, records or business actions. Persistent memory and delegated work can extend the effect beyond the original request or conversation.

AI testing needs recorded model and application conditions because outputs can vary. The important evidence is the protected information, decision or tool operation affected in the deployed workflow.

How penetration testers check for it

Trace source content to generated code, execution permissions and filesystem or network effects.

  • Map tools, identities and delegated capabilities.
  • Compare proposed actions with submitted parameters and effects.
  • Test untrusted inputs and changes to persistent state.
  • Review cancellation, revocation and containment.

How to fix it

Use constrained execution environments and validate intended operations before running code.

  • Expose narrow, validated tools and scoped credentials.
  • Bind important approval to the exact action and values.
  • Separate users and trust levels in memory and messaging.
  • Provide independent limits and shutdown mechanisms.

Human approval is useful only when the person can see and verify the consequential operation. A generic confirmation prompt is not a substitute for precise authority and trustworthy action binding.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your AI applications and agent workflows.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo