Lesson 3 of 5 · 20 min

Testing Agents for Prompt Injection and Tenant Leaks

Practical tests to run before every release of an AI agent feature.

In this lesson1. Where injected instructions hide2. A release test set3. Tenant isolation

Where injected instructions hide

Agents read documents, emails, tickets and web pages. Any of these can contain text written to look like instructions. The rule is simple: content the agent retrieves is data, never instructions. Tests should prove the agent behaves that way.

A release test set

Keep a fixed set of adversarial cases and run them on every change to prompts, tools or models.

  • A document that asks the agent to email its contents elsewhere.
  • A ticket that asks for another customer's records.
  • A page that tells the agent to ignore earlier rules.
  • Inputs that try to trigger long, costly loops.

Tenant isolation

Vector stores and caches can mix data between customers if keys or filters are wrong, which OWASP covers under Vector and Embedding Weaknesses, LLM08. Test that a query in one tenant can never return another tenant's chunks, and enforce the filter in code, not in the prompt.

Key takeaways
  • Treat retrieved content as data, never instructions.
  • Run a fixed adversarial test set on every change.
  • Enforce tenant filters in code.
Try it

Write five adversarial test inputs for one agent and record how it responded to each.

Check your understanding

1. How should an agent treat text inside a retrieved document?

2. Where should tenant filters be enforced?

3. When should the adversarial test set run?

← PreviousLeast-Privilege Tools and Human Approval for AgentsNext lesson →Logging and CERT-In Incident Reporting for AI Features
XDQ xAgents · AI lab for your company
While you sleep, your AI agents keep working.

From USD 49 or INR 2,999 a month. A person approves every step.

Start free, 14 days →See every agent300 credits · no card needed · prices include taxes🚀 Startup? Free landing page for 30 days →Need custom software or a security review? Send a brief →