
RAG Prompt Injection: Test Document Trust Before Launch
A new knowledge connector can change an AI product’s security boundary without changing its chat interface. A supplier PDF, support attachment or shared-drive page may become part of the context used to answer customers. The launch question is whether that content can also change what the assistant is allowed to do.
Indirect prompt injection in RAG occurs when instructions inside retrieved material influence model behavior beyond the material’s intended role as evidence. A document may be legitimate to retrieve while remaining untrusted as an instruction source. Testing should establish whether that distinction survives ingestion, retrieval, generation and any downstream action.
For a CTO, CISO or AI product owner, the useful result is a bounded release decision: which document paths were tested, which controls stopped prohibited behavior, what remains unverified and which changes require another assessment.
Indirect prompt injection in RAG starts with document trust
Retrieval-augmented generation supplies an AI application with information from external knowledge sources. A typical implementation extracts document content, divides it into chunks, indexes those chunks and retrieves relevant passages for a model request. Some systems combine vector search with keyword search, reranking or direct file processing.
The security boundary appears when source content enters the model’s context. Product documentation may describe a refund policy; it should not grant permission to issue refunds. A support attachment may contain customer facts; it should not redefine the assistant’s instructions or choose where customer information is sent.
OWASP LLM01:2025 Prompt Injection includes indirect instructions arriving through external sources. RAG improves access to relevant information, but does not itself eliminate this risk. Reachability and impact depend on the deployed workflow.
Hidden PDF text is one possible carrier. Visible paragraphs, extracted tables, OCR text and imported page content may also matter if the pipeline actually processes them. A payload in metadata that never reaches the model is an unexercised delivery path, not evidence of successful injection.
Separate document trust from retrieval authorization
Two different questions often get combined. Retrieval authorization asks whether the current user may receive a particular document or chunk. Document trust asks whether retrieved content can override application instructions or influence an unauthorized operation.
A user could legitimately access a policy document that contains hostile instructions. Conversely, a search filter could disclose another tenant’s document without any prompt injection. Either failure matters, but their causes, fixes and validation evidence differ.
Use RAG retrieval-layer security testing for the companion scope covering collection permissions, ownership filters and cross-tenant retrieval. This guide focuses on the document-led path from source material to behavior. Where that path reaches a protected resource, the assessment should test both boundaries and report them separately.
Define the document paths before agreeing scope
Start with a source inventory. Name each upload portal, documentation repository, shared drive, crawler, email integration and knowledge connector. Record who can introduce or edit content, which approval process applies, how updates reach the index and which users can retrieve the result.
For each source, identify accepted formats and the production parsing route. OCR, HTML conversion, chunking, deduplication and reranking can change which instructions survive. Testing a plain text substitute does not necessarily exercise the deployed PDF route.
The scope should also identify the model deployment, prompt configuration, retrieval settings, application build, user roles, service identities, output destinations and available tools. Agree access to representative test documents, retrieval traces and downstream logs. If those traces are unavailable, record the resulting limits rather than implying that a black-box answer proves the entire path.
Use synthetic records and controlled destinations in an authorized environment. Agree request and cost limits, stop conditions, evidence handling and prohibited actions before testing. For broader inclusions and exclusions, see what an AI penetration test covers.
Document trust-boundary matrix for a buyer scope
The following matrix turns architecture into testable claims. It is a recommended scoping aid, not a record of completed testing.
| Boundary | Question to test | Evidence to request |
|---|---|---|
| Source to ingestion | Can a lower-trust contributor introduce or replace searchable material outside the approved route? | Contributor role, source version, ingestion event and approval outcome. |
| Parser to index | Which visible, hidden or transformed content survives extraction and chunking? | Source hash, extracted text, chunk identifiers and index version. |
| Retrieval to context | Does document content remain evidence rather than become application authority? | Retrieved passages, assembled context and behavioral result for the same run. |
| Model to output | Can influenced output create an unsafe link, rendering behavior or downstream request? | Generated output, rendering or validation result and destination trace where applicable. |
| Model to action | Does the receiving service reject prohibited actions under the actual user and resource policy? | Tool arguments, effective identity, authorization decision and resulting state. |
| Removal to reuse | Can retired content still influence results through chunks, caches or derived memory? | Removal record, subsequent retrieval attempts and checks of relevant retained copies. |

Validate the complete path and classify the outcome
A useful assessment follows a controlled document through the same processing route used by the product. Establish a benign baseline, introduce the agreed adversarial variation, confirm that relevant content reached context, then observe the answer and any downstream effects.
Repeat representative cases under the deployed configuration and record the number and conditions of attempts. Model behavior can vary, while application authorization may be independently testable. Neither one unusual answer nor a single refusal establishes the reliability of the whole control chain.
Report outcomes using explicit distinctions:
- Not reached: the relevant content did not enter context. Document the delivery limitation; the instruction boundary was not exercised.
- Reached and resisted: the model received the content without the prohibited behavior being observed in the recorded attempts.
- Behavior influenced, consequence blocked: the model attempted a prohibited output or action, but an independent control prevented the defined impact.
- Impact confirmed: the agreed security boundary failed, with evidence of the resulting disclosure, unsafe processing or unauthorized state change.
- Inconclusive: missing traces or environmental restrictions prevent a reliable conclusion.
These are reporting outcomes, not universal severity ratings. Severity should reflect reachable impact, required access, affected users and the controls that actually operate in the tested environment.

Hypothetical example of a document-led action attempt
Consider an internal support assistant that reads policy documents and drafts account updates. An approved test contributor adds a document containing ordinary policy material plus instructions that conflict with the permitted workflow. A test user asks a normal policy question that retrieves the altered passage.
If the assistant merely quotes the passage while explaining that it cannot authorize an update, no unauthorized action has been demonstrated. If it proposes an update, the assessor must check whether the proposal reaches a tool and whether the receiving service enforces the user’s permissions.
A blocked request demonstrates a functioning action boundary for that case, even though the model’s behavior may still require remediation. A completed prohibited change demonstrates a different outcome and needs the request trace and before-and-after state.
This is a hypothetical scoping example, not a client finding. It does not assume that every RAG assistant has write access or that a malicious document automatically leads to data theft.
Test output handling and action authorization separately
A read-only assistant still has an output boundary. Generated links, HTML, Markdown, exports or structured fields may reach a browser or another service. Validate handling for the actual destination, including context-appropriate encoding and restrictions on external requests. A suspicious URL in generated text does not by itself prove exfiltration.
For action-taking workflows, name each permitted operation and its resource constraints. The receiving application or service should enforce authorization independently of the model’s interpretation. Confirm that the effective identity, tenant, target record and parameters are checked when the action executes.
Where approval is required, test whether it identifies the specific action and target, and whether changing material parameters invalidates that approval. If the assistant operates through browser sessions, add computer-use agent security testing for session isolation, alternate navigation paths and business actions.
Match controls and OWASP mappings to the failure
Limit ingestion permissions, preserve source provenance and inspect the content produced by parsers. Clearly separate retrieved passages from application instructions. These measures reduce opportunities for misuse; they should complement independent output and action controls.
Document scanning and prompt wording cannot establish authorization. Keep tool capabilities narrow, validate arguments and enforce resource permissions downstream. Logs should connect the source version and retrieved chunks to the response, attempted action and enforcement decision, while protecting sensitive content.
Use the 2025 OWASP LLM Top 10 identifiers consistently:
- LLM01:2025 Prompt Injection: external document instructions redirect model behavior.
- LLM05:2025 Improper Output Handling: insufficient handling of generated output exposes a downstream component.
- LLM06:2025 Excessive Agency: excessive functionality, permissions or autonomy enables harmful actions.
- LLM08:2025 Vector and Embedding Weaknesses: the demonstrated failure concerns vector or embedding storage, retrieval or isolation.
Apply only categories supported by the finding. LLM04:2025 Data and Model Poisoning may also be relevant to manipulation of embedding or other model-development data, but it should not replace the specific instruction-following and retrieval analysis. An OWASP mapping is a risk classification, not compliance certification.
Require evidence that supports a release decision
The report should identify the tested build, model configuration, source versions, roles and ingestion paths. Each material finding needs enough evidence to connect the source content, retrieved context, observed behavior, enforcement decision and business consequence. Document exclusions and cases that could not be exercised.
After remediation, replay the original path and relevant adjacent variations. Check that legitimate retrieval still works and that removal reaches the stores actually used by the workflow. If content was saved as persistent memory, use a separate agent memory poisoning assessment for later-session influence and repair.
Leadership can then approve the tested configuration, restrict particular sources or capabilities, or hold release while material failures are addressed. An inconclusive high-impact path needs an explicit decision and owner. It should not disappear inside a general statement that the chatbot passed.
Review scope whenever a new upload source, knowledge connector or write-capable workflow changes the trust boundary. Model, parser, prompt, retrieval and permission changes can also invalidate earlier evidence. Use AI pentest retesting after model and tool changes to distinguish targeted regression work from expanded scope.

Frequently asked questions
Is indirect prompt injection the same as cross-tenant retrieval?
No. Indirect prompt injection concerns instructions in external content influencing behavior. Cross-tenant retrieval concerns content reaching an unauthorized user. They can form one attack path, but either can occur independently.
Does passing a document scanner prove the RAG workflow is safe?
No. A scanner result covers its own checks. Validation must also examine what survives parsing, reaches model context and influences outputs or actions in the deployed workflow.
Can testing prove prompt injection will never work?
No. Testing supports conclusions about defined paths, configurations and recorded attempts. It should state limitations and independently verify the controls that restrict security consequences.
What should we provide for a pre-launch assessment?
Provide the source inventory, ingestion architecture, representative formats, test accounts, model and application configuration, available tools, permission rules and relevant logs. Agree on controlled data, destinations and stop conditions.
Scope document trust before enabling the next source
Bring your source inventory, parser route, retrieval design and proposed actions to an AI penetration testing scoping review. Pentest Testing Corp’s AI engagements currently start from $9,500, with final pricing determined by the agreed architecture and testing depth. Confirm reporting and retest terms in the engagement agreement.
The objective is a documented decision about this release: what content can enter, what authority it can influence and what evidence demonstrates the remaining boundaries.

