An AI agent is a language model that can act: it reads your tickets, calls your APIs, writes to your CRM and, increasingly, runs commands on a laptop. That makes it closer to a new employee with a login than to a chatbot. Most security programs were built to control people and servers, not software that takes instructions from whatever text it reads. This guide covers how agents are attacked in practice, the controls that limit the damage, how to handle agents on staff endpoints, and what to do when one misbehaves.
What changes when a model becomes an agent
A chat model is text in, text out. If it is tricked, the worst outcome is usually a bad answer. An agent adds three things: tools (APIs, a browser, a shell, email), memory that persists between sessions, and authority to act on someone's behalf. Each one turns a wrong answer into a wrong action.
The practical consequence is that the agent's permissions, not the model's cleverness, decide your blast radius. An agent that can read every mailbox and send email as the CEO is a far larger risk than one that can only draft replies for a person to approve, whatever model sits behind it.
The attack patterns that matter most
The OWASP Top 10 for LLM Applications names prompt injection as the first risk and excessive agency as one of the most serious for agents. In real assessments the same few patterns come up again and again:
- Indirect prompt injection: a web page, PDF, email or ticket contains instructions the agent follows, such as forwarding data through a tool it already holds.
- Confused deputy: the agent runs with more privilege than the user asking it, so a user can talk it into actions they could not take themselves.
- Memory poisoning: an attacker plants text in long-term memory or a shared knowledge base that changes the agent's behaviour later.
- Hidden payloads: zero-width characters, HTML comments or white text that a human reviewer never sees but the model reads.
- Tool and plugin supply chain: a third-party tool, MCP server or browser extension the agent trusts is malicious or gets compromised.
- Runaway actions: a loop or a bad plan that deletes records, sends mass email or racks up cloud spend before anyone notices.
Controls that hold up in production
No filter reliably stops prompt injection today, so design on the assumption that the agent will sometimes be fooled. The goal is that a fooled agent cannot do much harm.
For an independent check of these controls on a real deployment, an AI and LLM penetration test attacks the agent the way an outsider would, including injection through the documents and tools it reads.
- Run tools under the requesting user's permissions, never under a broad service account.
- Give each agent its own identity, scoped API keys and a short token lifetime, so you can see and revoke what it does.
- Put a deterministic policy layer between the model and its tools that rejects calls outside the task, for example sending email to external domains.
- Require a human approval step for anything irreversible: payments, deletions, permission changes and messages to customers.
- Restrict network egress so an agent can only reach the domains its job needs.
- Strip hidden characters and markup from untrusted input, and treat model output as untrusted before it reaches a browser, shell or database.
- Log every tool call, memory write and prompt change with the same care you give admin activity.
Securing AI agents on endpoints
Desktop assistants and coding agents can now read files, operate a browser and run terminal commands on a staff laptop. That is useful, and it means the agent inherits whatever that user can reach: saved browser sessions, SSH keys, cloud credentials and synced drives.
Treat an endpoint agent as privileged software. Allow only the agents you have approved through your device management tool, and turn off auto-approval of commands. Keep secrets out of plain files the agent can read, and use a separate, low-privilege profile or virtual machine for agents that browse the open web. Your EDR should alert when an agent process spawns shells, touches credential stores or makes unusual outbound connections. Review the agent's permissions after every major update, because vendors add capabilities quickly.
Shadow AI and agent sprawl
The agents you approved are rarely the problem. The risk is the browser extension a sales rep installed, the automation a contractor connected to your Google Workspace with full drive access, or the coding assistant with a personal API key. Each is an unreviewed integration holding real data.
Start with an inventory. Review OAuth grants in Microsoft 365 or Google Workspace, list browser extensions through device management, and ask teams which AI tools they use. Then publish a short approved list with a simple request route, because people route around policies that only say no. The same review also covers the data that leaves through AI tools, which is often the bigger exposure.
When an agent misbehaves: incident response
Add AI agents to your incident response plan before you need it. Every production agent should have a kill switch that revokes its tokens and stops its jobs in one step, and someone on call who knows where that switch is.
Investigation depends on the logs you kept. You need the prompts and documents the agent read, the tool calls it made and the data it returned. Without them you cannot tell whether an event was a bug, a misconfiguration or an attack, and you cannot say which records were exposed. Automated response can help here, for example disabling an agent's credentials when it calls a tool it has never used before, but keep a person in the loop for anything that affects customers. A 24x7 SOC can watch agent activity alongside the rest of your telemetry, and our incident response team can help when something has already gone wrong.
Where to start this quarter
Pick the one agent with the most access. Write down its tools, data sources, identity and the worst action it could take. Then run a short tabletop: an attacker plants instructions in a document the agent reads. What happens, who notices, and how fast can you stop it?
Fix what that exercise finds, then repeat it for the next agent. If AI risk now sits across several teams and no one clearly owns it, a virtual CISO can set the policy, the approved list and the review cycle.
Frequently asked questions
Can prompt injection be stopped completely?
How do we secure AI agents on staff laptops?
Is agent security different from normal application security?
Should agents be pentested separately from the APIs?
Find out what your agents can really do
We test AI agents and LLM applications the way an attacker would, including injection through the documents and tools they read, and report what a fooled agent could reach.

