AI-Agent Security: A Practical Guide for Engineering and Security Leaders

A practical threat model for AI agents with tools and credentials, plus controls for pipelines, code review and real-world deployments.

By Prathamesh Dabir

AI-agent security is the practice of controlling what an AI system can read, decide and do once it has tools, credentials and the ability to act without a human approving each step. It is less about whether a model says something offensive and more about whether an agent that reads untrusted text can be talked into pushing code, leaking a secret or calling a tool it should never have touched.

If your teams use coding agents, PR-review bots or agents wired into internal systems, you already run software that takes instructions from content it reads. This guide covers the threat model, the public frameworks worth anchoring on, a control checklist you can apply this quarter, and how to review the code your agents ship.

Why agents need their own security model

A chat model produces text. An agent produces actions. The moment a model can run a shell command, open a pull request, query a database or send a message, its mistakes stop being wrong answers and start being changes to your systems.

The core problem is that language models do not have a reliable boundary between instructions and data. OWASP's Top 10 for Agentic Applications (2026) puts it directly in its first entry: "agents and the underlying model cannot reliably distinguish instructions from related content." Everything an agent reads — an issue, a README, a web page, a tool's output — is potentially an instruction.

Simon Willison's framing of the lethal trifecta is the simplest test I know for whether an agent design is dangerous. If one agent has access to private data, exposure to untrusted content, and a way to communicate externally, an attacker who controls the content can usually get the data out. Most useful coding agents have all three by default.

The threat model for coding and agentic agents

It helps to think in five boundaries an agent crosses: input (what it is told), context (what it reads and remembers), identity (whose credentials it holds), tools (what it can call) and action (what actually changes in the world). Most real failures are a hostile input travelling across all five.

1. Prompt injection, direct and indirect

Direct injection is a user typing hostile instructions. Indirect injection is the version that matters for agents: the hostile text sits inside content the agent fetches on someone else's behalf. The idea was formalised in Greshake et al.'s 2023 paper, "Not what you've signed up for", and it is LLM01 in the OWASP Top 10 for LLM Applications.

A public example: in May 2025 Invariant Labs showed how a malicious GitHub issue could hijack an agent using the GitHub MCP server and get it to copy data from the user's private repositories into a public pull request. The tools worked exactly as designed. The agent was simply told to misuse them by text it read.

2. Tool misuse and excessive agency

OWASP's LLM Top 10 lists Excessive Agency (LLM06) and traces it to three root causes: excessive functionality, excessive permissions and excessive autonomy. The agentic list adds Tool Misuse and Exploitation (ASI02) and Identity and Privilege Abuse (ASI03).

In practice this looks like a PR-review bot that has a token able to push to main, or an agent with a general-purpose shell when it only needed to read three files. Injection is how the attacker gets in; excessive agency is what decides how bad the outcome is.

A related failure is an agent changing its own guardrails. Johann Rehberger's write-up of CVE-2025-53773 showed that a prompt injection could make GitHub Copilot in VS Code write a setting that auto-approved its own tool calls, then run commands. Microsoft fixed it in the August 2025 Patch Tuesday release. The lesson generalises: if an agent can write the file that defines its permissions, it does not really have permissions.

3. Supply chain: models, rules files, packages and tools

Agents pull in more third-party material than traditional code does. That includes model weights, MCP servers, prompt templates and agent configuration files such as CLAUDE.md, AGENTS.md and editor rules files. OWASP covers this as LLM03 Supply Chain and ASI04 Agentic Supply Chain Vulnerabilities.

Three patterns are worth knowing by name:

  • Poisoned rules files. Pillar Security's "Rules File Backdoor" research showed hidden Unicode instructions in Cursor and Copilot rules files steering the assistant to generate malicious code.
  • Tool poisoning. Invariant Labs documented MCP tool-poisoning attacks, where instructions hidden in a tool's description manipulate the agent.
  • Hallucinated packages. A 2024 study of code-generating models, "We Have a Package for You!", analysed how often models recommend packages that do not exist — names an attacker can register.

4. Secrets and sensitive data

Agents run where secrets live: developer laptops, CI runners, cloud shells. OWASP's LLM02 Sensitive Information Disclosure covers the model side, but for agents the bigger risk is ambient credentials — environment variables, .git/config, cloud metadata endpoints and CLI login caches the agent can read with one command.

The August 2025 Nx "s1ngularity" incident shows how close this already is. According to Nx's own postmortem, the malicious package versions ran a post-install script that scanned machines for sensitive data and "attempted to use local AI tools (like Claude and Gemini)" as part of that search. Local agents with broad file access became part of the attacker's toolkit.

5. CI/CD and automated agents

The fastest-growing exposure is agents running inside pipelines, triggered by events that outsiders can create: opened issues, pull requests, comments. Aikido Security's PromptPwnd research and the 2026 GitInject paper both show agents in GitHub Actions following instructions planted in PR and issue text, with access to repository tokens. GitInject's authors report that every provider they tested was susceptible to at least one high-severity attack in the configurations they studied. That attack path deserves a dedicated CI/CD threat review.

Pipeline credentials are also how agent tooling itself gets compromised. AWS's security bulletin AWS-2025-015 describes an inappropriately scoped GitHub token in the CodeBuild configuration for the Amazon Q Developer VS Code extension. An attacker used it to commit malicious code that was automatically included in a release (version 1.84.0). AWS says the code failed to execute because of a syntax error.

The public frameworks worth anchoring on

You do not need to invent a framework. These are free, current and widely referenced:

A practical control checklist

Use this as a starting review for any agent that can act. It is ordered roughly by how much risk each item removes per hour of effort.

Identity and credentials

  • Give each agent its own identity. Do not let it act as a human's personal token.
  • Use short-lived, narrowly scoped tokens (per repository, per job). Never give an agent a long-lived personal access token.
  • Keep secrets out of the agent's reachable environment: no plaintext keys in config files, no credentials persisted in .git/config, and block cloud metadata endpoints where possible.

Tools and permissions

  • Allow-list tools and commands instead of granting a general shell. Read-only by default.
  • Separate "reads untrusted content" from "holds write access" wherever you can. Breaking one leg of the lethal trifecta is the most effective single control.
  • Make the agent's own permission and configuration files unwritable by the agent.

Inputs and context

  • Treat every external text source — issues, PR bodies, commit messages, docs, web pages, tool output — as untrusted.
  • Do not load agent instruction files (CLAUDE.md, AGENTS.md, rules files) from untrusted branches or forks.
  • Scan rules and config files for hidden Unicode characters, and review them as you would executable code.

Actions and egress

  • Require human approval for irreversible or externally visible actions: merges, releases, deletions, payments, outbound messages.
  • Restrict network egress from agent sandboxes to known destinations.
  • Fail closed. If the policy or approval service is unreachable, the agent should stop, not proceed.

Pipelines

  • Avoid running agents on pull_request_target or similar privileged triggers with untrusted code checked out; follow GitHub's guidance.
  • Restrict who can trigger an agent workflow, set minimal permissions:, and cap input size and run count to limit denial-of-wallet abuse.

Evidence

  • Log every tool call with arguments, the identity used and the content that preceded it.
  • Re-test after every model, prompt, tool or permission change. A result from last month describes last month's system.

How to review code your agents ship

Agent-written pull requests deserve the same review as a new contributor's, plus a few checks specific to how agents fail. A human glancing at a tidy diff is not enough, because the risky part is often not in the diff's main logic.

  1. Check the diff for security-relevant files first. Changes to CI workflows, dependency manifests, lockfiles, agent configuration (.vscode/, CLAUDE.md, AGENTS.md, rules files), permission settings or auth code should get a named human reviewer, every time.
  2. Verify every new dependency exists and is the one you meant. Hallucinated or typo-squatted package names are a known agent failure mode.
  3. Look for new network calls, new secrets handling and new shell execution. Unexpected outbound URLs, eval-style execution or reads from environment variables are the usual signs of an injected change.
  4. Compare what the agent did with what it was asked to do. Read the task, then the transcript or tool-call log, then the diff. Scope creep in an agent PR is a signal, not a bonus.
  5. Run the same SAST, secret scanning and dependency checks you use for human code. Agents do not get an exemption because they are fast.
  6. Keep a record. Which agent, which model version, which prompt and tools, who reviewed and what was checked. Without that record, you cannot tell later whether a change was reviewed or merely approved.

A passing model evaluation is not a ship decision for the system around it. I wrote more on that distinction in The Open-Weight Model Passed. Can the System Ship?, and on testing the tool-call moment itself in Before the tool call.

Testing agents, not just models

Controls are claims until you test them. Agent testing differs from model benchmarking in one important way: you test the system's boundaries — what it can reach, what it will do with hostile input, and whether the containment around it holds — not the model's average behaviour on a fixed question set.

At Arica we run this kind of adversarial testing in our lab. In our published research sweep of ten open-weight models, one harness made 1,021 attempts and produced 320 findings. Those figures are lab research — raw detector findings for analyst review, not confirmed vulnerabilities in anyone's production system. The point is not the number. It is that a fixed, repeatable battery gives you something you can re-run after every change and compare.

Containment needs the same discipline. The Sealed Test describes a twelve-check record for proving that an evaluation or agent sandbox actually holds.

Where Arica Redline fits

Arica Redline is a hosted, adversarial assessment of an AI agent across those five boundaries: input, context, identity, tools and action. A fixed assessment plan runs against your endpoint, you get deterministic verdicts and a report you can re-run, and when the run passes you receive a signed attestation of a run, issued only when it passes, signed by two people at Arica.

That attestation is a record of what was tested and what happened in that run. It is not a certification, and it is not a guarantee that the system is safe after it changes. It is evidence you can show your own security team, your customers or your board, and re-earn when the system moves.

Redline is in private preview. If you run agents that can act on your systems and want them tested against a fixed plan, you can request access at aricatech.xyz.

FAQ

What is AI-agent security?

AI-agent security is the practice of controlling what an AI system with tools and credentials can read, decide and do. It focuses on prompt injection, tool misuse, excessive permissions, supply chain risk and leaked secrets, rather than only on what a model says.

How is AI-agent security different from LLM security?

LLM security mostly concerns a model's inputs and outputs. AI-agent security adds what happens when the model can act: calling tools, using credentials, changing code and taking multi-step decisions. OWASP publishes separate Top 10 lists for each because the risks differ.

What is the biggest security risk with AI coding agents?

Indirect prompt injection combined with excessive permissions. An agent that reads untrusted text, such as issues, PRs or docs, while holding write access or secrets can be instructed by that text to misuse its access.

How do you secure an AI agent in CI/CD?

Do not let untrusted contributions trigger privileged agent runs. Use minimal, short-lived tokens, never load agent config files from untrusted branches, restrict the agent's tools, cap input size, and require human approval before merges or releases.

Which frameworks cover AI-agent security?

The main public references are the OWASP Top 10 for LLM Applications (2025), the OWASP Top 10 for Agentic Applications (2026), the OWASP AI Agent Security Cheat Sheet, MITRE ATLAS, and the NIST AI Risk Management Framework with its Generative AI Profile.

Is a signed attestation the same as a certification?

No. A Redline attestation is a signed attestation of a run, issued only when it passes, signed by two people at Arica. It records one specific run against a fixed plan. It is not a certification or an audit opinion, and it does not cover the system after it changes.


Related: The Sealed Test · Before the tool call · The Open-Weight Model Passed. Can the System Ship?

Need this in your own environment?

Arica Tech Security runs VAPT, ISO 27001 readiness support, and digital forensics engagements for teams in India and beyond.

Talk to our team Explore services