What security safeguards to put around an AI agent
Facts checked on
The short answer
Treat every document, email and web page the agent reads as untrusted input that can carry instructions. Give the agent its own least-privilege identity, only the tools it needs, and a human approval step before anything leaves the company. Put a gateway in front of the model with token limits and content filters, keep full logs in your own store, and test prompt injection before go-live. OWASP, ANSSI, BSI, NCSC and NIST all point the same way.
Why an agent needs more than chatbot security
A chatbot answers. An agent reads your mail, opens files, calls tools and takes actions. Every new tool is a new way for a bad instruction to become a real action. That is why Anthropic advises starting with the simplest design that works and building an agent only when a fixed workflow cannot do the job (Building effective agents). The fewer things an agent can do, the fewer things can go wrong.
The safeguards below draw on the main public guidance: OWASP's two Top 10 lists, OpenAI's and Anthropic's builder guides, Mistral's guardrails, Microsoft Foundry's controls, NIST, ENISA, ANSSI (France), BSI (Germany) and the UK NCSC.
The threats specific to AI agents
| Threat | What it looks like | Named by |
|---|---|---|
| Prompt injection, direct | A user types instructions that override the agent's rules ("ignore your instructions and...") | OWASP Top 10 for LLM; Claude docs on jailbreaks |
| Prompt injection, indirect | Hidden instructions sit in an email, PDF, web page or ticket the agent reads, and the agent obeys them | OWASP; Anthropic research on browser-use agents |
| Excessive agency | The agent has more tools, rights or autonomy than the task needs, so one mistake does real damage | OWASP Top 10 for LLM and for Agentic Applications |
| Data leakage and exfiltration | The agent reads confidential data, then sends it out through a web search, an email or a link | OWASP; Mistral private data guard; Defender for AI alerts |
| Tool misuse | A legitimate tool (payments, file delete, CRM update) is called with the wrong arguments or for the wrong person | OWASP agentic list; Mistral guardrails |
| Supply chain | A model, plugin, MCP server or library you did not build behaves badly or changes under you | NIS2 Art. 21(2)(d); NCSC guidelines; ETSI EN 304 223 |
| Cost abuse | Loops, long prompts or abuse run up tokens with no ceiling | Microsoft: Azure OpenAI has no hard spend limit |
Indirect prompt injection is the one most teams underestimate. Any agent that reads outside content (customer emails, supplier PDFs, web pages) will meet it. No model vendor claims to have solved it: Anthropic describes measuring and reducing it with classifiers, training and red teaming (prompt injection defenses). Design so that a fooled agent still cannot do much harm.
Safeguards: control, what it stops, how, who owns it
| Control | What it stops | How to implement | Owner |
|---|---|---|---|
| Own identity per agent, least privilege | Excessive agency, lateral movement | Entra Agent ID or a dedicated service account; read-only by default (agent identity) | IT / identity team |
| Tool allow-list per agent | Tool misuse | List each tool and its allowed arguments; block the rest with policy guardrails (Mistral guardrails) | Product owner |
| Human approval before external actions | Injection turning into real damage | Approval step for send, pay, publish, delete, decide about a person | Business owner |
| Input and output guardrails | Direct injection, harmful output | Prompt Shields and content filters (content filters), Mistral moderation (moderation), Agents SDK tripwires (guardrails) | Engineering |
| No internet after private data | Exfiltration | Disable web search once the agent has read private data (private data guard) | Engineering |
| Per-user authorisation in the app | One user reading another's threads | Check rights in your code: Foundry Agent Service "doesn't enforce per-user authorization on conversations" (baseline) | Engineering |
| AI gateway with token limits | Cost abuse, runaway loops | API Management llm-token-limit per key or team (AI gateway) | IT ops / Finance |
| Private network, egress filtering | Data leaving by unknown routes | Private endpoints, firewall with FQDN allow-list | IT ops |
| Runtime threat detection | Jailbreak, data leakage, credential theft | Defender for AI services alerts (Defender for AI) | CISO / SOC |
| Full logs in your own store | Undetected misuse, no evidence | Prompts, tool calls, approvals and outputs to your log workspace | CISO |
| Red-team before go-live | Known attacks reaching production | Adversarial tests incl. injected documents (OpenAI safety practices) | Security + product |
| Model and vendor file | Supply-chain surprises | Per model: provider, version, hosting, data terms, change notice | DPO / procurement |
The three zones of agent actions
Sort every action an agent can take into one of three zones before it goes live, and write the list down. OpenAI's guide treats human intervention as a core part of agent design (practical guide); this is how we make it concrete.
| Zone | Rule | Examples |
|---|---|---|
| Automatic | Reversible, internal, read-only or draft | Search documents, summarise a thread, draft a reply, fill an internal field, create a ticket |
| Needs human approval | Leaves the company, moves money, deletes, or affects a person | Send an email, publish, pay or refund, delete records, change access rights, any decision about an employee or customer |
| Never | Banned by law or by your policy | Practices prohibited by AI Act Art. 5 (such as social scoring or emotion recognition at work), final decisions about people with no human sign-off, actions on systems outside the agent's list |
Logging and incident response
Log, in your own store: who asked, the prompt, the documents retrieved, every tool call with arguments, every approval and who gave it, the output, the model and version, token counts. On Azure, API Management can send prompts and completions to Azure Monitor, and all diagnostics belong in your Log Analytics workspace. For high-risk uses, the AI Act requires deployers to keep logs "of at least six months" (Art. 26); we use six months as the floor for every agent.
- Stop: a kill switch that disables the agent or one tool in minutes, owned by a named person.
- Contain: revoke the agent's credentials and tokens; block the gateway key.
- Read the logs: which inputs, which tool calls, which data left, to whom.
- Report: check NIS2, GDPR breach and, for high-risk systems, AI Act serious-incident duties with your DPO and counsel.
- Fix and retest: add the attack to your red-team suite before switching back on.
What ANSSI, BSI, NCSC and the others say
| Source | What it is | Use it for |
|---|---|---|
| ANSSI (France, 2024) | 35 recommendations for securing a generative AI system across training, deployment and production | The French reference your RSSI will ask about |
| BSI (Germany) | Opportunities and risks of generative AI models, with threats and countermeasures | Threat list for German IT and works council discussions |
| NCSC guidelines (UK, with CISA) | Secure AI development across design, develop, deploy, operate | Lifecycle structure |
| AI Cyber Security Code of Practice / ETSI EN 304 223 | 13 principles from design to end of life; the UK code became a European standard (v2.1.1, Dec 2025) | Supplier questionnaires |
| ENISA FAICP | Layered good practices for AI security | Mapping AI onto your existing security programme |
| NIST AI RMF and AI 600-1 | Govern, Map, Measure, Manage; 12 generative AI risks with about 200 actions | Governance structure |
| OWASP LLM Top 10 and Agentic Top 10 | Ranked risks for LLM and agentic apps | Test cases for your red team |
Our opinion: pick one as your backbone (ANSSI in France, BSI in Germany, NCSC/ETSI in the UK, NIST or ENISA elsewhere) and use OWASP for testing. Mixing all of them produces paperwork, not security.
A 20-item checklist before production
- Written purpose and scope for the agent, with a named business owner.
- A fixed workflow was considered first and rejected for a stated reason.
- The agent has its own identity, not a person's account.
- Its rights are read-only except where a write is listed.
- Tool allow-list with allowed arguments for each tool.
- Every action sorted into automatic, approval or never.
- Approval screens show the action and the data before the click.
- Outside content (email, files, web) is treated as untrusted input.
- Web access is off once private data has been read.
- Input and output filters are on and tested.
- Per-user authorisation is enforced in the app.
- Model calls go through a gateway with token limits.
- Network is private; egress is limited to listed destinations.
- Prompts, tool calls, approvals and outputs are logged in your store for at least six months.
- Runtime alerts go to the team that answers security alerts.
- A kill switch exists, is tested and has a named owner.
- Red-team run done, including injected documents and emails.
- Model and vendor file written: provider, hosting, data terms, retention.
- DPIA checked with the DPO; workers' representatives informed where required.
- Users know they are dealing with AI and have had training (AI Act Art. 4 and Art. 50).
What regulators expect
- AI Act, now: Art. 5 prohibitions apply since 2 February 2025; Art. 4 (supporting staff AI literacy) and Art. 50 (telling people they are dealing with AI) apply today (Service Desk timeline).
- AI Act, human oversight: Art. 14 and Art. 26(2) set the oversight duties for high-risk systems. For Annex III uses (recruitment, employee evaluation, credit scoring, essential services) they apply from 2 December 2027, as amended by Regulation (EU) 2026/1744. Deployers must assign oversight to people with "the necessary competence, training and authority", monitor and suspend on risk, report serious incidents and keep logs (Art. 26, AI Act). The date moved; the duties did not go away.
- NIS2: for medium and large entities in covered sectors, supply-chain security (Art. 21(2)(d)) pulls AI and cloud vendors in through your contracts, and management bodies must approve the measures and are liable (Art. 20). In force in Germany since 6 December 2025 and the Netherlands since 15 August 2026; in France the transposition bill was in parliamentary debate from 10 November 2026.
- DORA (financial firms, since 17 January 2025): a model API or agent platform supporting a critical or important function is an ICT third-party service, with contract clauses (Art. 30), exit strategy and the register of information. Microsoft, AWS and Google Cloud were among the 19 critical providers designated on 18 November 2025 (ESAs); that does not reduce your own accountability.
- UK: no AI act; the NCSC guidelines and ETSI EN 304 223 are the security baseline, and UK firms selling into the EU are caught by the EU AI Act.
Velok is not a law firm: check scope and dates with your counsel. For the full list of deployer duties, see what the AI Act requires from deployers.
Frequently asked questions
What security controls do we need before giving AI agents access to email and documents?
A dedicated least-privilege identity for the agent, a tool allow-list, input filters for injected instructions, no web access after private data is read, and human approval before anything is sent. Log every tool call in your own store and run a red-team test with poisoned emails and PDFs before go-live.
How do we stop prompt injection and data exfiltration in AI agents?
You reduce it; nobody has fully solved it. Filter inputs (Prompt Shields, Mistral moderation), limit tools, cut internet access once private data is in context, and require approval for outbound actions. Then a fooled agent cannot do much.
What does the ANSSI, BSI or NCSC guidance say we must do to secure a generative AI system?
ANSSI gives 35 recommendations across training, deployment and production; BSI lists threats and countermeasures for generative models; the NCSC and the ETSI EN 304 223 standard set 13 principles from design to end of life. They are guidance, not law, but auditors and NIS2 supervisors use them as the reference.
How do we log and audit what an AI agent did on our systems?
Log the request, retrieved documents, every tool call with arguments, approvals, output, model version and tokens, in a store you control. Keep at least six months, the AI Act floor for high-risk deployers. On Azure, API Management and Log Analytics cover the model side; your app must log approvals.
Does zero data retention really mean nothing is stored?
Not always. Zero retention or modified abuse monitoring usually covers prompts kept for abuse review, while stateful features such as threads, files and vector stores are stored until you delete them. On Azure, check the resource shows ContentLogging=false and list which features hold data.
How do we connect AI agents to our systems without giving them too much access?
Give each agent its own identity with read-only rights by default, list the tools and arguments it may use, and route writes through an approval step. Review the rights every quarter, as you would for a contractor.
Sources
- Anthropic: Building effective agents (read on 17 November 2026)
- Anthropic: prompt injection defenses (read on 17 November 2026)
- Claude docs: mitigate jailbreaks and prompt injections (read on 17 November 2026)
- OpenAI: A practical guide to building agents (PDF) (read on 17 November 2026)
- OpenAI: safety best practices (read on 17 November 2026)
- OpenAI Agents SDK: guardrails (read on 17 November 2026)
- Mistral docs: agent guardrails (read on 17 November 2026)
- Mistral docs: safety and moderation (read on 17 November 2026)
- Mistral cookbook: private data guard (read on 17 November 2026)
- Microsoft Learn: agent identity (Entra Agent ID) (read on 17 November 2026)
- Microsoft Learn: content filters and Prompt Shields (read on 17 November 2026)
- Microsoft Learn: Defender for Cloud threat protection for AI services (read on 17 November 2026)
- Microsoft Learn: Zero Trust for agentic systems (read on 17 November 2026)
- Microsoft Learn: AI gateway capabilities in API Management (read on 17 November 2026)
- Microsoft Learn: baseline Foundry chat reference architecture (read on 17 November 2026)
- Microsoft Learn: data, privacy and security for models sold by Azure (read on 17 November 2026)
- Microsoft Learn: plan and manage costs for Microsoft Foundry (read on 17 November 2026)
- OWASP Top 10 for LLM Applications (read on 17 November 2026)
- OWASP Top 10 for Agentic Applications 2026 (read on 17 November 2026)
- NIST AI Risk Management Framework (read on 17 November 2026)
- NIST AI 600-1: Generative AI Profile (PDF) (read on 17 November 2026)
- ENISA: multilayer framework for good cybersecurity practices for AI (read on 17 November 2026)
- ANSSI: security recommendations for a generative AI system (read on 17 November 2026)
- BSI: Generative AI models, opportunities and risks (read on 17 November 2026)
- NCSC: guidelines for secure AI system development (read on 17 November 2026)
- UK government: AI Cyber Security Code of Practice (read on 17 November 2026)
- ETSI EN 304 223 v2.1.1 (PDF) (read on 17 November 2026)
- EU AI Act, Regulation (EU) 2024/1689 (EUR-Lex) (read on 17 November 2026)
- AI Act Article 26 (deployer obligations), consolidated reading (read on 17 November 2026)
- AI Act Service Desk: implementation timeline (read on 17 November 2026)
- ESAs: designation of critical ICT third-party providers under DORA (read on 17 November 2026)
Velok is not a law firm. This guide documents technical choices and public sources; it does not replace advice from your DPO or counsel.