AI security
How we attack-test an AI agent before launch
Our AI agent testing follows the same path on every project: a written scope and threat model, a test plan, manual and automated attacks, a severity rating for each finding, fixes and a retest. This post explains each step, what you receive, how long it takes and how we keep real personal data out of the tests. It describes our method, not results from client projects.
By the KDS security engineering teamPublished 7 min read
Key takeaways
- We test the whole agent: model, prompts, tools, data sources and hand-offs, on every input it reads.
- Each finding comes with evidence and a fix your developers can apply, rated by impact and likelihood.
- Tests run in your environment on test accounts with synthetic data, so they don't touch real customer records.
- We retest after fixes and again when the model, prompts, tools or permissions change.
On this page
Our AI agent testing method at a glance
We attack-test an agent the way an attacker would: we try to make it leak data, ignore its rules or misuse its tools, then help you close each gap. Our AI red teaming guide covers the background of this kind of testing. This post shows how we run it, in seven steps:
- Agree on scope, rules and a threat model.
- Write a test plan with a pass or fail condition for each case.
- Attack the agent by hand and with automated tools.
- Rate each finding by impact and likelihood.
- Work with your team on fixes, then retest.
- Deliver the report, the evidence and the test cases.
- Retest when the agent changes.
Step 1: scope, rules and threat model
Before any test, we agree in writing on what we test and how. The scope names the agent version, the channels (chat, voice or email), the tools and data sources, the test environment and the test dates. The rules say what testers must not do, such as trigger real payments or contact real customers, and whom to call if something breaks.
Then we build a threat model. We list who might attack the agent (customers, outsiders who send email, insiders), what they want (data, money, free services or damage to your reputation) and every path into the agent: user messages, uploaded files, retrieved documents, tool outputs and other agents. An agent that can read private data, process untrusted content and send data out gets the deepest tests, because that combination gives an attacker the most to work with. For agents we build, the threat model starts from the risk map of our opportunity and risk audit.
Step 2: a test plan with clear pass and fail rules
Each threat becomes a set of test cases. A test case states the input, the channel and the result that counts as a failure, for example an order from another account appearing in a reply. We check coverage against the OWASP Top 10 for LLM Applications 2026 (opens in a new tab) and the OWASP Top 10 for Agentic Applications (opens in a new tab), so each finding maps to a category your auditors and customers recognize.
Step 3: manual and automated attacks
Security engineers test by hand first. They chain steps, change approach when a defense holds and combine weaknesses, such as an instruction planted in a support ticket that leads to a data export. Chained attacks like this are hard to find with scripts alone.
Automated tools then send large sets of attack prompts in many variations, encodings and languages and record which ones succeed. The NIST Generative AI Profile (opens in a new tab) notes that human-led and AI-led testing may each be better at finding different kinds of harm, so we use both. Model output varies from one attempt to the next, so we repeat each successful attack and record how often it works.
What our AI agent testing covers
We test every input the agent reads and every action it can take. The main areas:
- Prompt injection: hidden instructions in chat messages, emails, files, web pages, retrieved documents and tool outputs. Our post on prompt injection examples describes the patterns we try.
- Data leaks: the system prompt and any secrets in it, other customers' records, internal documents and data carried over from earlier conversations.
- Tool misuse: refunds above a limit, changes to the wrong account, deletions, exports and messages to outside addresses without approval.
- Identity checks: whether the agent confirms who the customer is before it shares account details.
- Jailbreaks and false promises: role-play, long conversations and other languages that push the agent to break your rules or promise a discount outside your policy.
- Hand-off abuse: planted instructions or false claims in the summaries your staff read.
- Cost abuse: very long inputs, tool loops and repeated requests that run up AI usage costs, and whether rate limits and spend caps react.
Step 4: severity ratings
We rate each finding by impact and likelihood, the two factors of the OWASP Risk Rating Methodology (opens in a new tab). Impact depends on what the agent can reach. A reply that drifts off topic is minor. A tool call that moves money or shows another customer's data is not.
| Rating | Typical finding |
|---|---|
| Critical | An attacker can move money, export many records or act on other accounts without approval |
| High | One customer's personal data, or a credential stored in the prompt, can be exposed |
| Medium | Internal rules or filter logic leak and make other attacks easier |
| Low | Off-topic or off-brand replies with no data or action involved |
Likelihood covers the skill and access an attack needs and how often it succeeded in our repeated tries. A high-impact attack that works only now and then can still rank near the top of the list.
Step 5: fixes and retest
We walk your developers through each finding and recommend a fix. Stronger prompt wording helps, but attackers can often talk around it, so we prefer controls outside the model: narrower permissions, approval steps, checks on each tool call in application code and separate data access for each user. The UK National Cyber Security Centre advises designs that limit what the model can reach (opens in a new tab), because prompt injection may never be fully mitigated. Our guide to AI agent permissions shows how to set those limits.
After your team applies a fix, we rerun the original attack and its variants. A finding closes only when the retest passes.
Step 6: the report and what you receive
The report serves two audiences: leadership, who decide what to fix first, and developers, who need to reproduce each issue. You receive:
- A plain-language summary of the overall risk and the most important findings.
- The scope and method: agent version, tools, data sources, dates and what we did not test.
- Each finding with the exact inputs and outputs, steps to reproduce, its success rate, severity, business impact and a recommended fix.
- The OWASP category for each finding.
- The attacks that failed, so you know which controls work.
- Retest results for each finding.
- The test cases, so your team can rerun them as a regression set after each release.
- A short briefing for your leadership team.
Step 7: retesting after changes
A test describes the agent on the day it ran. A new model version, a changed prompt, a new tool or data source and wider permissions can each reopen a closed gap. We retest after each significant change, and the automated regression set runs after every release to catch known attacks that start working again. For agents in our run-and-improve stage, we also track new public attack techniques and add them to the set.
How we keep real personal data out of tests
Attack testing tries to make the agent leak data, so we plan the tests to work without real personal data:
- A test copy in your environment: we test a copy of the agent connected to test accounts and sandbox systems on your own infrastructure, not to live customer records.
- Synthetic test data: made-up customers, orders, tickets and documents that look realistic but belong to no one.
- Marker values: unique invented values, such as a fake account number, placed in restricted test records. If one appears in a reply, we have proof of a leak without exposing a real person.
- Written rules for live systems: when a test must touch a live system, we agree on it in writing first, use read-only access where we can and stop and report if real data appears.
- Evidence stays with you: transcripts and logs from the tests remain in your environment.
This supports the data minimization principle in Article 5(1)(c) of the GDPR (opens in a new tab): personal data should be limited to what is necessary for the purpose. Our post on synthetic data for AI testing explains how to build a realistic test set.
How long AI agent testing takes
For agents we build, attack testing is part of the secure launch stage, which usually takes 2–4 weeks. That stage also covers hardening, monitoring setup and staff training, and it leaves time to fix findings and retest before the agent talks to a single customer. The exact time depends on the number of tools, channels and data sources and on how quickly fixes are applied.
For agents built by another team, we agree on the timing in the written scope. Our AI security consulting service runs these tests on chatbots and agents, whoever built them, with your permission.
Sources
- 1.OWASP Top 10 for LLM Applications 2026, OWASP GenAI Security Project, 2026-08-03 (opens in a new tab)
- 2.OWASP Top 10 for Agentic Applications for 2026, OWASP GenAI Security Project, 2025-12-09 (opens in a new tab)
- 3.Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1), NIST, 2024-07-26 (opens in a new tab)
- 4.OWASP Risk Rating Methodology, OWASP Foundation (opens in a new tab)
- 5.Prompt injection is not SQL injection (it may be worse), UK National Cyber Security Centre, 2025-12-08 (opens in a new tab)
- 6.Regulation (EU) 2016/679 (General Data Protection Regulation), Article 5, EUR-Lex, 2016-04-27 (opens in a new tab)
