
LLM Penetration Testing: How to Test AI Chatbots, RAG Apps and Agents
Quick answer: LLM penetration testing is an authorized security test of applications built on large language models, such as customer chatbots, AI assistants, retrieval-augmented generation (RAG) search tools and AI agents that call other systems. Testers try to make the application leak data, ignore its instructions, take actions it should not take or expose the systems around it, then explain how to fix each weakness. Because LLM behavior is driven by natural language rather than fixed code paths, these tests need techniques that traditional application testing does not cover.
Businesses are adding AI features faster than almost any technology before. A support bot answers customer questions using internal documents, a sales assistant drafts emails from CRM data, an agent books meetings or updates tickets on a user's behalf. Each of these connects a model that can be persuaded by text to data and tools that matter. That combination creates a new class of risk.
This guide explains what LLM testing covers, the main risks, how a test works, what good findings look like and how to prepare. It is about testing AI applications themselves. For AI used as a tool to run penetration tests, see our separate guide to AI penetration testing.
What Is LLM Penetration Testing?
LLM penetration testing, sometimes called AI application penetration testing or LLM red teaming, applies attacker techniques to an application that uses a large language model. The target is not just the model but everything around it: the system prompt, the data the model can retrieve, the tools and APIs it can call, the way its output is used by other systems and the permissions of the users talking to it.
The result is a report of proven weaknesses, examples of the inputs that triggered them, the business impact and practical fixes, followed by a retest after changes are made.
Why LLM Applications Need Their Own Testing
Instructions and data share one channel: the model reads user input, retrieved documents and system instructions as text, so hostile content can be mistaken for instructions.
Behavior is probabilistic: the same input can produce different outputs, so testers must try many variations rather than one payload.
Models are connected to real systems: agents can read email, query databases, call APIs or change records, so a manipulated model can take real actions.
Sensitive data is close at hand: RAG systems pull internal documents into answers, which can expose information to the wrong user.
Traditional scanners miss the problem: most LLM weaknesses are about meaning and context, not malformed requests.
The OWASP Top 10 for LLM Applications
The OWASP GenAI Security Project publishes the Top 10 for LLM Applications, the most widely used reference for this kind of testing. The 2026 edition, released in August 2026, keeps prompt injection and sensitive information disclosure at the top, and for the first time was shaped by real-world incident data as well as expert input. OWASP also maintains a separate Top 10 for Agentic Applications covering autonomous agents. A good LLM penetration testing engagement maps its test cases and findings to these lists so results are easy to compare and prioritize. For the traditional OWASP lists, see our guide to OWASP penetration testing.
Main Risks Tested in LLM Applications
| Risk | What testers try to prove |
|---|---|
| Direct prompt injection | A user can override the application's instructions and make it do something it should refuse |
| Indirect prompt injection | Hidden instructions in a web page, email or document change the model's behavior when it reads that content |
| Sensitive information disclosure | The model reveals personal data, internal documents, credentials or another user's information |
| System prompt leakage | Confidential instructions, business rules or secrets in the system prompt can be extracted |
| Excessive agency | An agent can be talked into calling tools or taking actions beyond what the user is allowed to do |
| Improper output handling | Model output is passed unchecked into browsers, databases or shells, leading to cross-site scripting, injection or code execution |
| Vector and embedding weaknesses | RAG retrieval ignores access controls or can be poisoned with planted content |
| Data and model poisoning | Training, fine-tuning or knowledge-base data can be manipulated to change answers |
| Supply chain | Third-party models, plugins, libraries or connectors introduce weaknesses |
| Unbounded consumption | Missing limits let attackers run up costs or exhaust capacity |
Prompt Injection in Practice
Prompt injection is the risk most teams have heard of and the one most often found. In a direct attack, a user writes input designed to make the model ignore its instructions, for example to reveal hidden rules or produce content the business has forbidden. In an indirect attack, the instruction is planted somewhere the model will later read, such as a support ticket, a shared document or a web page an AI browsing tool visits. When the model processes that content, it may follow the planted instruction instead of the user's request.
Indirect injection is especially dangerous for agents, because the planted text can tell the model to send data elsewhere or call a tool. LLM penetration testing checks both forms, using many phrasings, languages and encodings, because a filter that blocks one wording often misses another.
Testing RAG and Data Access
Retrieval-augmented generation lets a model answer questions using your own documents. It also creates a new data access path. Testers check whether a user can retrieve documents they should not see, whether access controls from the source system are enforced at retrieval time, whether one customer's data can surface in another customer's answers and whether planted documents can change what the model says. Multi-tenant SaaS products need special attention here. Our guide to SaaS penetration testing covers tenant isolation more broadly.
Testing AI Agents and Tool Use
Agents turn model output into actions: sending messages, querying databases, creating tickets, running code or calling internal APIs. The key questions are what each tool can do, whose permissions it runs with and whether a manipulated model could misuse it. Testers look for agents that run with broad service credentials instead of the user's own permissions, tools that accept free-form input without validation and missing human approval for high-impact actions. Because agents call APIs, this work overlaps heavily with API penetration testing.
The Application Around the Model
Many serious findings in LLM applications are classic web and API issues: broken authentication on the chat endpoint, missing authorization on conversation history, exposed API keys for the model provider, unsafe file uploads or model output rendered as HTML without encoding. A complete LLM penetration testing engagement therefore includes standard web application penetration testing of the interface, the backend and the integrations, not just conversations with the bot.
How an LLM Penetration Test Works
Scope and threat model: identify the model provider, system prompt, data sources, tools, user roles and the worst outcomes the business wants to prevent.
Map the architecture: document how input flows to the model, what it can retrieve, what it can call and where its output goes.
Test the conversation layer: run direct and indirect prompt injection, jailbreak attempts, system prompt extraction and data leakage tests.
Test data and retrieval: check access controls on RAG sources, cross-user leakage and content poisoning.
Test tools and agents: try to trigger unauthorized actions and check permissions, validation and approvals.
Test the surrounding application: authentication, authorization, APIs, output handling and secrets management.
Report and retest: document findings with reproducible examples, business impact and fixes, then retest after changes.
These steps follow the same structure as any professional engagement. See our guide to penetration testing methodology for the broader framework.
Automated Testing and Human Testers
Automated tools can send thousands of attack prompts and are useful for regression testing every time a prompt, model or data source changes. They are good at breadth. Human testers are still needed for depth: understanding the business context, chaining a small leak into a serious exposure, crafting indirect injection that fits a real workflow and judging which outputs actually matter. The strongest programs combine both. Privaxi's AI pen testing platform pairs automation with analyst review, and our guide to continuous penetration testing explains why repeat testing matters for systems that change often.
Common LLM Penetration Testing Findings
System prompts containing API keys, internal URLs or business rules that can be extracted.
Chatbots that reveal other users' conversations or data through retrieval.
Agents that can send email, change records or call APIs without user confirmation.
Tools running with administrator-level service accounts.
Model output rendered as HTML or passed to queries without sanitization.
Guardrails that block obvious attacks but fail against rephrased or encoded input.
No rate limits or spending caps on model usage.
Conversation logs storing sensitive data without retention limits or access controls.
Remediation Priorities
Assume the model can be manipulated: design so that a fooled model cannot cause serious harm on its own.
Enforce permissions outside the model: check authorization in code before retrieving data or running a tool, using the end user's own rights.
Keep secrets out of prompts: never place credentials or sensitive rules where the model can repeat them.
Limit agent power: give tools the minimum permissions they need and require human approval for high-impact actions.
Treat output as untrusted: encode, validate and sanitize model output before it reaches browsers, databases or shells.
Monitor and cap usage: log prompts and tool calls securely, alert on abuse and set spending and rate limits.
For a structured approach to closing findings, see our guide to penetration testing remediation.
LLM Testing and AI Governance
Customers, regulators and auditors increasingly ask how AI features are secured. Frameworks such as ISO/IEC 42001 for AI management systems and the NIST AI Risk Management Framework expect organizations to identify and manage AI risks, and LLM penetration testing provides concrete evidence that controls work. Existing obligations still apply too: if a chatbot can reach health, payment or personal data, HIPAA, PCI DSS and privacy laws cover that data just as they would any other system. Our guide to ISO 42001 AI governance explains the management side.
How to Prepare for an LLM Test
Describe the application's purpose and the outcomes that would harm the business most.
Share the architecture: model provider, system prompt, data sources, tools and integrations.
Provide test accounts for each user role, including different customers or tenants if relevant.
Agree on limits for actions agents may take during testing and set spending caps on model usage.
Use a staging environment with realistic but non-production data where possible.
Plan time to fix findings and retest, especially before a public launch.
Clear boundaries keep testing safe and focused. Our guide to penetration testing scope explains how to document them.
When to Run LLM Penetration Testing
Run LLM penetration testing before a new AI feature goes live, after major changes such as a new model, new data sources or new agent tools, and at least once a year for AI features that handle sensitive data or take actions. Because prompts and models change often, automated regression testing between full assessments helps catch new weaknesses early.
Common Mistakes to Avoid
Relying on the model provider's safety filters as the only control.
Testing only the chat window and ignoring retrieval, tools and APIs.
Trying a handful of known jailbreaks and calling the system secure.
Giving agents broad service permissions for convenience.
Putting secrets or sensitive business logic in the system prompt.
Skipping retesting after prompt or model changes.
Frequently Asked Questions About LLM Penetration Testing
What is LLM penetration testing?
LLM penetration testing is an authorized security test of applications built on large language models, focused on prompt injection, data leakage, unsafe agent actions and weaknesses in the surrounding application.
Is LLM testing different from AI penetration testing?
Yes. LLM testing assesses the security of AI applications themselves, while AI penetration testing usually refers to using AI to help perform penetration tests.
Can prompt injection be fully prevented?
Not reliably today. The safer approach is to limit what a manipulated model can do by enforcing permissions in code, restricting tools and requiring approval for high-impact actions.
Does the model provider handle security?
Providers secure their models and platforms, but you are responsible for your prompts, data access, tools, integrations and how output is used.
What standard is used for LLM testing?
Most testers map findings to the OWASP Top 10 for LLM Applications, and to the OWASP Top 10 for Agentic Applications for systems that use autonomous agents.
How often should LLM applications be tested?
Before launch, after major changes to models, prompts, data sources or tools, and at least annually for features that handle sensitive data.
Final Thoughts
LLM penetration testing shows whether your AI features can be talked into leaking data or taking harmful actions. Test the model, the data it can reach, the tools it can use and the application around it, design so a fooled model cannot cause serious damage and retest whenever the system changes.
To plan an assessment of your AI applications, explore Privaxi's testing and assessment services.
Related Articles
Secure Your Business's Future
Contact us today for a personalized consultation and see how we can tailor a security solution that fits your business needs perfectly.


.jpg)

