Red teaming RAG applications with promptfoo

Learn how promptfoo tests retrieval-augmented chatbots and search assistants for injection, data exfiltration, fabricated citations and context overflow, and what your team must prepare.

On this page

Why red teaming RAG applications needs its own test plan

If your team is shipping a chatbot or search assistant that answers from internal documents, you need evidence that it resists attack before launch. promptfoo red teaming sends adversarial inputs to your RAG application and grades the responses for failures such as prompt injection, data leakage and fabricated answers. A RAG system is not just a model behind a prompt, so a generic jailbreak suite will miss the paths that matter most: the documents it retrieves, the embeddings used to find them, and the data it returns to the user.

RAG adds three surfaces that a plain chat application does not have. The first is the retrieval layer, where a user's query can pull in content they should never see if access checks are missing from the index or the query path. The second is the document corpus itself, where text inside a file can carry instructions the model follows (OWASP LLM01 Prompt Injection). The third is the embedding and vector store, which the OWASP Top 10 for LLM Applications 2026 covers as LLM09 Vector and Embedding Weaknesses. The same edition lists LLM02 Sensitive Information Disclosure and LLM08 Hidden Context Exposure, which together describe what leaks when retrieved context is returned or echoed. Your test plan should name each of these surfaces and state which control is expected to stop it.

promptfoo runs locally on your machine and talks directly to the LLM under test, so the test traffic and the grading path are yours to inspect. Confirm with your security team which model provider receives test prompts and retrieved content, because that determines where the data goes during a scan.

Which RAG failure modes promptfoo can probe

Injection in a retrieval application arrives in two places: the user's message and the text the retriever pulls into the prompt. Indirect injection is the harder case, because a document in the knowledge base can carry instructions that the model treats as commands. The OWASP LLM Top 10 2026 lists prompt injection as LLM01, and a RAG test should cover both routes.

  • Direct injection: the test sends user messages that try to override the system prompt, change the assistant's role or reveal its instructions.
  • Indirect injection: the test places instructions inside content the retriever would return, such as a policy page or a support article, and checks whether the answer follows them.
  • Pass condition: the assistant keeps its task, answers from the permitted sources and does not act on instructions found in retrieved text.
  • Failure pattern: the assistant summarizes the document, then adopts the document's instructions as its next action.
  • Scope note: whether your retriever can carry a test payload into the prompt depends on how the application builds context, so confirm that path with your application team before writing the test.

Before running these checks, confirm which fields of your application are attacker-controllable, because those define where injected text can enter.

Choosing end-to-end or component-level red team targets

This table compares red teaming the full chatbot end to end against testing the retriever, prompt template and generator on their own, along with how to decide which retrieved documents count as controlled test data. Read each row as a trade-off: end-to-end tests show what a user can actually reach, while component tests locate the cause of a failure. Most teams need both, with end-to-end runs as the release gate and component runs for diagnosis.

Decision pointEnd-to-end through the full chatbotComponent tests (retriever, template, generator)
What it catchesInjection that survives retrieval and reaches the answer, leaked data from the live index, and fabricated citations in the final responseRetriever returning out-of-scope or other-tenant chunks, template ordering that lets retrieved text override instructions, generator behavior on a fixed context
What it missesThe component responsible for a failure, and attacks that only occur with retrieval results you did not plantInteractions between components, such as a retrieved chunk that changes how the generator cites sources
Setup effort driversTarget connector to the chatbot endpoint, session and identity handling, and access to a test index that mirrors productionA separate harness per component, fixture data for each stage, and agreed inputs and outputs for each call
Which documents are controlled test dataPlant poisoned or canary documents in a dedicated test index, never in a live corpus with real customer recordsSupply fixed chunks directly to the generator so the context is known, and vary only one retrieved item per case
Evidence it producesFinal answers, cited sources and the documents that were retrieved, useful for audit-style reportingRetrieved chunk lists and generator outputs per stage, which make root cause analysis faster
When it fitsRelease gating, pre-deployment reviews and checks that matter to a customer security questionnaireDiagnosing a failing end-to-end case, testing a template change, or testing a retriever before the generator is attached
Ask your team or partner to confirmWhether the chatbot endpoint can return retrieved chunks with the answer for gradingWhether the generator can be called without the retriever, and whether the retriever can run against the test index

How to set up a promptfoo RAG red team

This sequence takes a team from a scoped question about its retrieval-augmented application to a graded set of red team results. Each step ends with a check so the team knows what it has and what to fix before the next step.

  1. Confirm purpose and scope

    The security or product owner and the application team agree on what the red team is for, such as pre-release testing, a customer security review or ongoing regression checks. They list the in-scope data sources, user roles, document types and actions the assistant can take, and they name who receives the results. The step is done when this scope is written down and signed off by both groups. Ask the owner to confirm which hosted model providers may receive test traffic and which documents may be used, since these choices affect every later step.

  2. Install promptfoo on a test workstation

    An engineer installs the promptfoo CLI on a machine that can reach the application under test. The current npm release, 0.124.1, was published on 8 October 2026 and requires Node.js 22.22.0 or newer, so the engineer checks the Node.js version first. Evals run locally and call the model directly, so the workstation needs network access to the model provider as well as the application. The step is done when the CLI reports its version and a trivial config runs to completion.

  3. Define the RAG application as a target

    The engineer configures promptfoo to send attack prompts to the application, using an HTTP endpoint, a provider the team already runs or a custom script. The target must return the answer and, where possible, the retrieved passages and cited sources, because grading for context injection and fabricated citations depends on them. Test identities should be created for each user role so authorization results are meaningful. The step is done when one normal question returns a complete response with its context visible to promptfoo.

  4. Build a synthetic test knowledge base

    The team creates a small corpus of synthetic documents that mirror the real structure of the knowledge base without containing customer or regulated data. The corpus should include ordinary documents, documents with sensitive-looking fields that are fictional, and a few documents with planted instructions for injection tests. The ingestion pipeline of the test environment indexes this corpus so the retriever behaves as it does in production. The step is done when a query for a known fact retrieves the expected synthetic document and the team can list every document in the index.

  5. Choose plugins and strategies for RAG risks

    The engineer selects red team plugins that match the risks in the scope, such as prompt injection, sensitive information disclosure, misinformation and fabricated citations, and check them against the OWASP Top 10 for LLM Applications 2026, which lists LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure, LLM07 Misinformation and LLM09 Vector and Embedding Weaknesses. Strategies such as injection through documents are added so attacks arrive through retrieved content as well as the user message. The step is done when the configuration file lists each chosen plugin with the risk it tests and the reviewer has approved the list.

  6. Run the red team scan

    The engineer runs the red team scan from the CLI against the configured target and keeps the output directory with the configuration, the version and the date. Scan size and the number of probes used should be recorded, because the Community edition includes 10k probes per month. The team should watch for errors from the endpoint, since failed requests can look like passing results. The step is done when the run completes without transport errors and the output file contains a result for every planned probe.

  7. Review graded results and retest fixes

    The team opens the report, reads the failing probes with their retrieved context and answers, and sorts them by risk and by component, such as retriever, prompt template or generation. Each confirmed finding gets an owner and a fix, and the same scan is rerun after changes to confirm the failure is gone and no new failure appeared. Grader decisions should be spot-checked by a person, since automated graders can be wrong in both directions. The step is done when every finding is either fixed and retested or accepted in writing by the owner.

How the test knowledge base and documents shape results

A RAG red team is only as meaningful as the documents the application retrieves during the test. The same attack prompt can pass against one corpus and fail against another, because the model answers from whatever chunks the retriever returns. Before running a scan, decide which knowledge base the target will query, who owns it, and how closely its structure matches production: document types, chunk sizes, metadata fields, access tags and the way files are ingested. Build that corpus from synthetic or sanitized documents that copy the layout of real content, such as policy pages, product manuals, ticket exports and contracts with invented names, figures and identifiers. Real customer records should not enter a test store, and the team should confirm that the test environment has its own vector index, not a shared one with production.

Injected text reaches the model through retrieval, not only through the user's message. A poisoned or instruction-bearing passage in a document is embedded, ranked, selected and then placed into the prompt as context, often with formatting and surrounding text that the model reads as authoritative. That is why a RAG test must reproduce the full path: the same embedding model, the same chunking rules, the same top-k setting and reranker, and the same prompt template that wraps retrieved text. If the test harness calls the generation model with hand-written context, it skips the step where the attack either survives or disappears. Record which chunks were retrieved for each test case, because a failed attack often traces back to a chunk that was never selected rather than to the model refusing.

This topic does not cover the detailed mechanics of the attack payloads. For how poisoned documents are generated, added to a test knowledge base and checked for compliance, see the topic on testing RAG document poisoning with promptfoo. For placing injected instructions in documents, emails and web pages and deciding what a pass looks like, see the topic on testing indirect prompt injection with promptfoo. Confirm with your own engineers which retrieval settings and ingestion steps your production system uses, since those settings are the inputs that make the corpus representative.

Data handling and operational risks during RAG testing

A RAG red team sends prompts, retrieved passages and model responses through several systems, and some of them may not be yours. The cards below cover the places where test data can leave your control, the corpus you load, the limits of self-hosted promptfoo, and the outputs your pipelines store.

Hosted judge and target traffic

When a hosted model acts as the target, the judge or the attacker model, every test prompt and retrieved passage is sent to that provider. promptfoo runs on your machine, but the model calls it makes are not local when the provider is a cloud service. Before the first run, list each provider in the config, confirm its data retention and training terms with the vendor, and decide which corpus content is allowed to appear in a request. A local or self-hosted model for grading is one option to evaluate.

promptfoo introduction

Real documents in the test corpus

Loading production documents into a test knowledge base copies customer records, contracts or internal files into a second store that may have weaker access rules. Use synthetic or redacted documents that keep the structure of the real corpus, such as the same chunk sizes, metadata fields and document types. Where real content is needed to reproduce a retrieval failure, restrict the test index to the same people who can already read the source, and delete it when the test ends.

Test execution model
Local

Self-hosted server limits

The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas, has no RBAC, no horizontal scaling and no built-in authentication or SSO. It is not recommended for production use. Put it behind your own identity-aware proxy or network controls, keep it on a single instance with backed-up storage, and confirm with the vendor whether your use needs the Enterprise or On-Premise edition instead.

Self-hosting docs

Credentials in CI pipelines

Red team jobs need model API keys and sometimes access to the application under test. Store them in your CI secret manager, scope each key to the test environment and a spending limit, and avoid echoing configuration in job logs. Check that pull requests from forks cannot read the secrets. Rotate keys after any run that used a production endpoint, and confirm that your runner image does not cache credentials between jobs.

Sensitive output in reports

Red team reports quote the prompt, the retrieved context and the answer for each failing case. A single report can therefore contain personal data or internal text from the corpus. Decide who can open reports, where artifacts are stored and how long they are kept, and redact retrieved passages before sharing findings outside the security team. Treat exported JSON and HTML results as sensitive records in your retention policy.

Questions teams ask before red teaming a RAG application

What does a RAG red team cost, and who gets paid for what?

The cost depends on who runs the work and how wide the scope is. promptfoo Community is free under the MIT license and includes red teaming with 10k probes per month, with community support, according to the promptfoo pricing page. Your team also pays for the model calls the scan makes against your application and for any hosted grader or generator models, which bill by usage with your provider. If you hire a partner, you pay for scope, setup, test design, analysis of findings and retesting, and a quote should separate those items. Ask whether the price covers one scan or a recurring cycle, since scans repeat after every change to prompts, retrieval settings or the corpus.

Can our own team run a promptfoo red team on a RAG chatbot?

Yes, if an engineer can call the application from a script and someone can judge whether a response is a real leak or a false alarm. The CLI and library run locally, so evals execute on your machine and talk directly with the model, according to the promptfoo documentation. The hard parts are not the tool but the setup: choosing plugins that match your data, writing a target that returns the retrieved context and citations, and reading results without accepting every automated grade. Teams often start in-house for a narrow scope and bring in a partner for the first full assessment or for an independent review.

How long does a first RAG red team scan take?

The duration depends on scope, not on the tool. The main drivers are how many data sources and document types the retriever uses, how many plugins and strategies you enable, how many probes you run per plugin, and how quickly the application responds. A single-endpoint chatbot over one corpus is far smaller than a search assistant that spans several indexes with user-specific filters. Ask any partner for a written timeline tied to a defined scope, and confirm how many probes your Community allowance leaves for the first run, since Community includes 10k probes per month.

What must our team provide before testing starts?

Expect to provide three things. First, a test endpoint that accepts a question and returns the answer along with the retrieved chunks, sources and any tool output, ideally in a staging environment with production-like data. Second, a test corpus: documents you are willing to expose to scanning, including some planted sensitive records so exfiltration can be detected, and a copy of the index settings. Third, test identities for each access level, such as a standard user, a user from another department and an administrator, so authorization across documents can be checked. Agree in writing who approves use of production model keys and where results are stored.

Is promptfoo Community enough for a RAG application in production?

Community is enough for many engineering teams that want repeatable scans and no license fee, because it includes all evaluation features, all model providers and integrations, and red teaming with 10k probes per month. It does not include team sharing, SSO, role-based access, continuous monitoring or priority support, which are part of Enterprise, per the promptfoo pricing page. The self-hosted app is not recommended for production: its SQLite database cannot be shared across replicas and it lacks RBAC and built-in authentication. Decide based on whether you need shared access control and evidence trails across several teams.

What does a RAG red team not prove?

A passing scan is evidence about the probes you ran, not a guarantee that the application is secure. Automated attacks cover known patterns, so a novel injection phrasing, a rare document layout or a multi-step scenario outside the plugins may still succeed. Scans also depend on the model, the retriever settings and the corpus at the time of testing, so a model upgrade, a new document or a changed filter can reopen a gap. Graders can miss leaks or flag harmless text. Treat results as a snapshot to repeat after changes. Independent audits and certifications are issued by auditors and certification bodies, not by a test run.

Should we test the whole RAG pipeline or each component separately?

Test end to end first when you need to know what a user can extract, because that catches failures that only appear when retrieval, prompting and generation interact. Test components separately when a finding needs a cause: the retriever returns documents a user should not see, or the generator ignores its instructions when context is long. The OWASP Top 10 for LLM Applications 2026 lists LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure and LLM09 Vector and Embedding Weaknesses, which map to different layers, so a useful plan covers both views.

Limits to confirm in your environment before scanning

A promptfoo red team scan depends on your edition, your target, your model provider and the model that grades results. Each of these changes what a scan can test and what its results mean, so confirm them before you run anything against a RAG application.

Probe quotas on your edition

The Community edition is free and includes red teaming with 10k probes per month, with community support. Count the probes a RAG scan needs across plugins, strategies and repeat runs, because a full scan of retrieval paths can exhaust a monthly allowance quickly. Confirm the quota applies to your account, and whether Enterprise or On-Premise terms change it before you schedule recurring scans.

Promptfoo pricing

Plugins and strategies that fit the target

Injection, exfiltration and citation plugins only produce useful results when the target actually has the surface they probe. A chatbot without retrieval, document ingestion or tool access will not exercise document-based attacks, so select plugins to match the pipeline you deploy. Document the plugin list and strategies in the red team config so reviewers can see why each one was chosen.

Provider permission for attack traffic

Automated red teaming sends large volumes of adversarial prompts to the model. Hosted model providers have acceptable use terms, and some restrict or require notice for automated probing of their services. Check your provider agreement and account limits, and whether your organization needs an internal approval for this traffic, before the first run so a scan does not trigger account suspension mid-test.

Grading model choice and data exposure

promptfoo uses a model to judge whether a response is harmful or leaked data. That grading model receives the attack prompts and the application's responses, which may include retrieved documents with personal or confidential data. Decide which grader is used, whether it is hosted or local, and what retention terms apply. Record the choice, since it determines where test data leaves your environment.

Local execution and target access

The software runs on your machine and talks directly with the model, so the scanning host needs network reach to the RAG endpoint, the vector store and the model provider. Confirm which environments the scan may reach, whether staging data is representative, and who holds the credentials used by the target, since a misconfigured run can touch production retrieval.

Promptfoo introduction

Test results are not compliance evidence

A passing or failing red team report shows what was probed on one date against one configuration. It does not establish that a system is compliant with the OWASP LLM Top 10, the NIST AI Risk Management Framework or the EU AI Act, and it does not replace an independent assessment. Treat the report as one input to your control evidence and state its scope, date and limits when you share it.

Deciding whether your team or a partner runs the RAG red team

Keep the red team in-house when the application is stable, the retrieval corpus has a clear owner, and your engineers already run evals against it. In that situation, the work is mostly maintenance: adding probes for new document sources, rerunning the scan after each change to the retriever, reranker or system prompt, and reviewing failures with people who already know the knowledge base. promptfoo is MIT licensed and the Community edition includes red teaming with 10k probes per month, so the tooling cost is not what separates the two options. What matters is whether someone on your team can write a meaningful target configuration, decide which injected documents and fabricated-citation checks reflect your data, and interpret the results without a vendor's help.

A partner fits better at first launch, when the application handles regulated data, or when nobody owns the test corpus. In those cases the expensive part is not running promptfoo but deciding what to test: which document sources carry untrusted text, which records a user should never see through retrieval, and what counts as a failed citation in your domain. A fixed-scope engagement with DeployOpen would normally agree these items in writing before work starts: the target and its access model, the plugins and strategies in scope, the document and identity test data, the grading criteria, the findings report with fixes, and a retest. Ask for the scope and deliverables in the quote, and confirm with the partner which of these are included and which need your staff.

Be clear about what the partner produces. DeployOpen runs the tests and prepares systems, test records and evidence for your compliance and security reviewers, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so your evidence file should be built to be reviewed by them. Whichever option you choose, keep the scan configuration, corpus version and results under your own control, so future reruns can be compared with the first run.

How promptfoo reaches the RAG pipeline under test

The run starts on the test machine, where the promptfoo CLI reads the test corpus and sends each attack or question to the application's entry point, not directly to the model. The application's retriever, vector store, prompt assembly and generator then run inside the client's environment before the answer returns. Check where the grading model sits, because graded answers and retrieved context may leave the trust boundary when hosted providers are used. Reports are written back to the test machine.

Data path from the promptfoo CLI through the RAG app to hosted providers.

How DeployOpen scopes and delivers RAG red teaming

DeployOpen starts every RAG red team with a written scope that names the target chatbot or search assistant, its retrieval path, the document sources it indexes, the identities it runs under and the attack classes in play. Scoping also settles which RAG configurations are tested, whether the team tests the end-to-end application, individual components such as the retriever or reranker, or both, and whether test data may leave the client's network for a hosted generation model. Deliverables, the test environment, the client contacts who approve test accounts and the timeline are agreed in writing before any test runs. Most engagements are fixed-scope, so the agreement states what is tested and what is handed over, and a quote follows from that document.

The red team runs inside the client's infrastructure. DeployOpen installs promptfoo on machines the client controls, points it at a staging copy of the application and a seeded knowledge base, and uses the self-hosted promptfoo app only where a shared results view is needed, given its documented limits on replicas, RBAC and authentication. Findings come back as a report that maps each failure to the affected component, the reproducing test case and a proposed fix, such as stricter retrieval filters, citation checks or input isolation. DeployOpen then retests the fixed configuration and reports what changed. Clients who want to keep testing after each knowledge base update or model change can move to a retainer for continuous testing, with the scope and cadence agreed in advance.

Ask for the scope document, the list of test identities and data handling terms before signing. Confirm with DeployOpen who approves any hosted model calls and where logs and test artifacts are stored. DeployOpen does not publish a price list. A quote follows from the written scope, and the main cost drivers are the number of components and document sources in scope, the number of test identities, how many retest rounds are included and whether ongoing retainer support is needed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.