Red Teaming AI Agents: Uncovering Security Vulnerabilities in Production Systems

casco · Tech · 2025 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production AI agent security and red teaming

Casco tested live production AI agents and found that developers were treating agent security as mostly prompt-injection or model-safety work, while real compromises came from ordinary web and infrastructure flaws exposed through agent tools.

Constraints:

Architecture

Casco's red-team method first extracted system prompts and tool definitions, then inverted the stated constraints to test what the agent could actually access. The assessment found three recurring failure classes: cross-user data access through IDOR, arbitrary code execution and lateral movement through weak sandboxes, and SSRF-style credential theft from private repositories. The recommended architecture treats agents as users, applies external authorization, sanitizes inputs/outputs, and uses real code sandboxes rather than custom containers.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["Production agent front end"] --> B["API server"]
  A --> C["LLM runtime"]
  C --> D["System prompt"]
  C --> E["Tool definitions"]
  B --> E
  B --> F["Authorization layer"]
  B --> G["Data sources"]
  F --> G
  E --> G
  E --> H["Code execution sandbox"]
  H --> I["Infrastructure metadata endpoints"]
  G --> J["Private repository fetcher"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Production agent front end User-facing entry point for interacting with the deployed agent. API server, LLM runtime
API server Server-side layer that exposes tools and data access to the agent. Production agent front end, Tool definitions, Authorization layer, Data sources
LLM runtime Model execution context that reads prompts and chooses tool actions. Production agent front end, System prompt, Tool definitions
System prompt Natural-language instructions and constraints that attackers inspect and invert. LLM runtime
Tool definitions Callable agent capabilities such as user lookup, document retrieval, database creation, and code execution. API server, LLM runtime, Data sources, Code execution sandbox
Authorization layer External checks that validate both token authenticity and resource-level access. API server, Data sources
Data sources User records, documents, BigQuery/customer data, and private repositories reachable from agent tools. API server, Authorization layer, Private repository fetcher
Code execution sandbox Isolated compute environment for generated code or tool execution. Tool definitions, Infrastructure metadata endpoints
Infrastructure metadata endpoints Internal service metadata/token endpoints that can enable lateral movement if exposed to weak sandboxes. Code execution sandbox
Private repository fetcher Tool path that retrieves private GitHub schemas and can leak credentials through SSRF. Data sources

Data flow

Casco selected live agents, started a 30-minute timer, extracted system prompts, inspected tool definitions, and then tried to exploit whatever the tools could access. In the IDOR case, leaked user/document IDs flowed through agent tools into other users' data. In the sandbox case, write/read/execute capabilities let the attacker modify protections, discover metadata, and move laterally. In the SSRF case, a tool that fetched private GitHub schemas sent credentials to an attacker-controlled repository. Fixes sit around the agent: authenticate and authorize each request, sanitize inputs and outputs, and isolate code execution with enterprise sandboxes.

3 supporting quotes
“let's just set a timer for 30 minutes we don't want to waste too much time on this”transcript, stated
“let's let's figure out what their system prompts are and just kind of understand how they're working”transcript, stated
“we looked at, oh, what kind of tool definitions do they have, right? Like, you know, what is it supposed to do?”transcript, stated

Why this architecture

Casco frames agent security as an end-to-end systems problem because the damaging paths are often in the arrows between LLMs, tools, APIs, sandboxes, credentials, and data. Treating the agent like a user forces authorization, sanitization, and sandboxing to be implemented outside natural-language prompts.

3 supporting quotes
“agent security is bigger than just LM security. Make sure you understand how these threat vectors apply inside your overall system.”transcript, stated
“agents actually act like users um not API servers.”transcript, stated
“your LM should probably not determine authorization pattern that that that's bad.”transcript, stated

Models used: Large Language Models · Claude

Scale

Alternatives considered (roads not taken)

Treat agent security as primarily prompt injection and harmful-content filtering

Rejected because: The compromises came from ordinary authorization, sandbox, credential, and network paths around the LLM.

“primary discussions around LM security really like hey is it um can you do prompt injection? Can you get it to do harmful content?”transcript, stated
“the reality with security is you need to look at all the different errors in your system and that is typically where real damage happens”transcript, stated

Let the agent act with service-level permissions

Rejected because: Agents should inherit user-like authorization boundaries rather than broad server/service privileges.

“agents are like users right so everything that applies to users apply to agents too”transcript, stated
“it should probably not act with service level permission.”transcript, stated

Roll a custom code execution sandbox

Rejected because: Sandboxing arbitrary compute safely is hard, and weak isolation can expose metadata, service tokens, and internal resources.

“making sure you have code sandboxes correctly is very hard because you can move laterally across the infrastructure”transcript, stated
“Don't roll your own code sandboxes please. Like it's it's just very hard.”transcript, stated

Patterns

safety-policy-enforcement (security)

The core recommendation is to enforce authentication, authorization, sanitization, and sandbox controls outside the LLM rather than trusting natural-language constraints.

“You need to think about how do you authenticate but also authorize the request. It's really two checks, right?”transcript, stated
“always sanitize your inputs and outputs. This could be like a webdev conference from 20 years ago.”transcript, stated

tool-use-orchestration (architecture)

The red-team methodology centers on agent tool definitions because tools determine data access, code execution, database creation, and private repository fetches.

“what kind of tool definitions do they have, right? Like, you know, what is it supposed to do? Is it supposed to access data, supposed to run code”transcript, stated
“there are a lot of code tools that agents use”transcript, stated

privacy-preserving-processing (security)

Casco's IDOR example shows that agent data access must preserve user/resource boundaries even when the agent has a valid token.

“we were able to find their personal information including their email, nickname, whatever.”transcript, stated
“make sure that you have some sort of access control matrix somewhere that checks that it matches up with whoever is making the request.”transcript, stated

observability-tracing (operations)

Casco recommends production-grade sandboxes with built-in observability so agent code execution is isolated and inspectable.

“They have observability built in. They boot up super quickly.”transcript, stated

Tradeoffs

Agent permission model

Chose user-like permissions and external authorization over service-level agent permissions or LLM-decided access control.

Rationale: Agents act on behalf of users and can be manipulated; letting them inherit service permissions turns model/tool mistakes into broad data access.

“agents actually act like users um not API servers.”transcript, stated
“your LM should probably not determine authorization pattern that that that's bad.”transcript, stated

Code execution isolation

Chose purpose-built sandbox solutions over custom Python/container apps.

Rationale: Sandbox correctness is difficult and failures enable lateral movement across infrastructure.

“don't roll your own code signbox. That is just so dangerous”transcript, stated
“if you just use containers, by the way, that's not an isolation layer in case anybody's wondering.”transcript, stated

Local agent safety UX

Chose permission prompts or constrained modes over full local YOLO execution.

Rationale: The speaker frames local agent operation as an industry split between full autonomy and asking every time, implying a safety/usability tradeoff.

“locally uh I think right now the industry is either you go full yolo mode or you ask every time”transcript, stated

Gotchas (what bit them)

Valid authentication is not enough for agent tools.

Root cause: The API checked token validity but not whether the authenticated user could access the specific resource ID.

Resolution: Apply a resource-level authorization matrix on every agent-mediated request.

“It's basically when you make a request and you validate that, hey, the token is valid and you just let the request through”transcript, stated
“some sort of access control matrix somewhere that checks that it matches up with whoever is making the request.”transcript, stated

Natural-language prompt constraints reveal what attackers should invert.

Root cause: System prompts often describe exactly what developers do not want the agent to do, but do not enforce it technically.

Resolution: Treat prompts as clues for red-team testing and enforce sensitive constraints through code and infrastructure controls.

“you try to basically invert what the system prompt is saying because that is exactly what the developer didn't want you to do”transcript, stated

Custom code sandboxes can become lateral-movement paths.

Root cause: Arbitrary compute in a container can discover metadata, tokens, network resources, and internal services.

Resolution: Use hardened sandbox products and avoid plain containers as isolation boundaries.

“arbitrary code execution once you're inside a container is that you can do many things like um there's this thing called service endpoint discovery”transcript, stated
“if you just use containers, by the way, that's not an isolation layer in case anybody's wondering.”transcript, stated

SSRF-style tool calls can leak private repository credentials.

Root cause: A tool fetched database schemas from a private GitHub repository using credentials, but accepted attacker-controlled repository strings.

Resolution: Sanitize tool inputs/outputs and audit each arrow where credentials are attached to downstream requests.

“it pulls the database schema from a private GitHub repository.”transcript, stated
“let's set up a badacctor.com test.git git repo and just see what credentials come through and yep it comes across with the git credentials”transcript, stated

Evaluation

Casco evaluated agent security through a constrained live red-team exercise: 16 production agents, 30 minutes per agent, system-prompt/tool inspection, and exploit attempts categorized by recurring vulnerability classes.

Metrics: 16 live production agents tested · 30 minutes per agent · 7 agents compromised · 3 recurring vulnerability classes identified

3 supporting quotes
“we hacked uh out of 16 agents that were launched within 30 minutes each.”transcript, stated
“We were hacked uh we hack we hacked seven of them.”transcript, stated
“there are three common issues we see across all of these ones.”transcript, stated

Outcomes

The evidence is a limited but concrete red-team sample of 16 live agents. The findings are qualitative vulnerability classes rather than a statistical industry benchmark.

3 supporting quotes
“And there are three common issues we see across all of these ones.”transcript, stated
“first thing is agent security is bigger than just LM security.”transcript, stated
“treat agents as users and that applies to authentication to sanitization of user inputs and many of the other things.”transcript, stated