AI Agents & Automation

AI application security: testing LLM apps and agents as attackers would

Securing an AI application means assuming the model can be talked into anything and making sure that, even then, it cannot reach data or take actions the user is not entitled to. Prompt injection has no complete fix today, so the protection lives in permissions, tool design, output handling and human approval rather than in the prompt. This page covers the main risks, the OWASP Top 10 for LLM Applications and how we test.

Request a questionnaire review

Treat the model as an untrusted user

A language model reads instructions and data in the same stream of text and has no reliable way to tell them apart. Anyone who can put text in front of it, whether a customer, an email sender or the author of a web page, can try to steer it. So the useful design question is not 'how do we stop the model being fooled?' but 'what could it do if it were?'

The answer should be: nothing the current user could not do anyway. Authorisation is enforced in code, inside the tools, against the real user's identity. The model asks; the tool layer decides. A security rule that exists only in the system prompt is a suggestion, not a control.

Prompt injection, direct and indirect

Prompt injection is direct when a user types instructions to override the rules, and indirect when the instructions hide in content the agent reads: an email, a support ticket, a PDF, a product review, a calendar invite, text inside an image or the description of a tool. Indirect injection is the more dangerous kind, because the person harmed is not the person who wrote the attack.

Imagine an assistant that summarises a shared inbox and can send email. A message arrives with hidden text telling it to forward the latest invoices to an outside address. If one agent can read private data, reads untrusted content and can send data out, the attack has everything it needs. Break that combination for each task:

  • Give the step that reads untrusted content no access to private data or outbound tools.
  • Allow outbound actions only to approved destinations, or only after a person approves them.
  • Keep untrusted content away from the steps that plan actions, and label it as data when it must be passed on, knowing that a label alone does not stop an attack.

The OWASP Top 10 for LLM Applications

The OWASP Top 10 for LLM Applications (2025 edition) is the usual checklist, a sibling of the OWASP Top 10 for web applications. This is what we check for each risk:

RiskWhat we check
Prompt injectionDirect and indirect attacks through every input the model reads
Sensitive information disclosureWhether replies, logs or errors reveal personal data, secrets or other users' records
Supply chainWhere models, datasets, plugins and tool servers come from, and who can change them
Data and model poisoningWho can add to training data, fine-tuning sets and the documents the agent retrieves
Improper output handlingWhether model output reaches a browser, database, shell or URL fetcher without escaping or validation
Excessive agencyTools, permissions and autonomy beyond what the task needs
System prompt leakageSecrets or security rules placed in the prompt, which should be assumed readable
Vector and embedding weaknessesDocument-level permissions in the index, and leakage between customers
MisinformationUngrounded answers people may act on, and how the interface shows uncertainty
Unbounded consumptionRate limits, step limits and spending caps that stop abuse and runaway cost

Excessive agency and unsafe tool use

The damage an attack can do is set by what the agent is allowed to do. Keep that small:

  • Narrow tools. 'Look up this order for this customer' rather than 'run any database query'. Each tool does one job with typed arguments.
  • The user's permissions, not a master key. The agent acts with the signed-in user's rights through scoped, short-lived credentials, following least privilege.
  • Checks in the tool, not the prompt. The tool confirms that the order belongs to this customer and the amount is within the limit, whatever the model asked for.
  • Read before write. Start agents read-only, add write actions one at a time, and have a person approve the irreversible ones.
  • Third-party tool servers. A Model Context Protocol server or plugin is code running with your permissions, and the model reads its tool descriptions, so a malicious one can carry instructions. Review and pin them like any dependency.

Data leakage and secrets

  • Retrieval permissions. If the index ignores document permissions, any user can retrieve the HR file by asking the right question. Filter by the user's access at query time.
  • Customer separation. Caches, conversation memory and indexes must never mix one customer's data with another's.
  • Secrets out of reach. API keys live in a secrets manager, and only the tool layer uses them. The model never sees them, so it cannot reveal them.
  • Exfiltration through the interface. An injected instruction can make the model write an image link whose address carries private data; when the chat renders it, the browser sends the data away. Do not render images or links to unapproved domains, and set a content security policy.
  • Provider settings. Check how your model provider retains and uses prompts and outputs, and choose the settings your data rules require.

Model output is untrusted input

Whatever the model writes becomes input to something else, so handle it like text from a stranger. Escape it before it reaches a page, or you have cross-site scripting. Never build a database query or shell command from it; pass values as parameters to fixed operations. If the agent fetches URLs, restrict the hosts it may reach so it cannot be pointed at internal systems. If it runs code, run it in a sandbox with no network access and no secrets. Validate structured output against a schema and reject anything that does not fit.

How we test an LLM application

  1. Threat model first. Map what the system reads, what it can do and who can put text in front of it, as in our threat modelling practice.
  2. Injection suites. Direct attacks, plus indirect ones planted in the documents, emails and web pages the agent will read.
  3. Permission tests. Two test accounts in separate organisations, each trying to reach the other's data through the agent.
  4. Exfiltration and output tests. Attempts to leak data through links, images, tool calls and rendered markup.
  5. Abuse and cost. Floods, very long inputs and loops that test rate limits and spending caps.
  6. Report and retest. Findings with severity, evidence and a specific fix, then a retest. The attack cases join the regression suite described in AI agent testing.

The AI layer sits on an ordinary web application and API, which still need penetration testing and secure code review. Both are part of our cybersecurity service, and our security checklist for AI agents is a short version to work through.

No test proves that an AI application cannot be manipulated. It shows which attacks failed within the time and scope agreed, so the design must limit the damage of the attacks nobody tried.

A small first step

Send us your next security questionnaire

Share the questionnaire or security review a buyer sent you. On a short call we show which answers you already have evidence for, which gaps to fix first, and what can be automated next time.

Message us on WhatsApp

Questions we get asked

  • Not today. Filters and careful prompts make attacks harder, but no known method reliably separates instructions from data inside a model. Design so that a successful injection cannot do much: the agent works with the user's permissions, tools check every request, untrusted content stays away from the steps that act, and risky actions need a person's approval.

  • No. It may stop casual attempts, but attackers rephrase, hide instructions in documents or split them across messages. Treat the prompt as guidance for behaviour, never as a security control. Access rules, limits and approvals belong in code that the model cannot talk its way past.

  • Yes. An AI feature runs on an ordinary web application, API and cloud setup with the usual risks: broken access control, injection, exposed secrets and weak configuration. Test the AI-specific risks and the conventional ones together, because attackers combine them.

  • The provider secures its own platform. Your application is yours: which data the model can reach, which tools it can use, how its output is handled, what is logged and who can see it. Read the provider's data and retention terms, choose the settings your rules require, and test your own system.

Keep exploring

Ready to build something secure?

Tell us about your product. We will reply with a clear plan.

Start a project

We would like to use Microsoft Clarity to see how visitors use the site, so we can improve it. It sets cookies and is off unless you accept. Cookie policy