Skip to content
USE CASE: RAG PIPELINES

Secure your RAG pipelines

Your RAG system retrieves documents from various sources. PromptGuard ensures retrieved content doesn't contain hidden malicious instructions.

SCANNED BEFORE ASSEMBLYschematic
queryretrieveryour corpuschunk 1chunk 2chunk 3chunk 4chunk 5dropped — hidden instructioncontext assembledpromptthe scan is the same guard call your user messages make
Each retrieved chunk is scanned on its own, before assembly. Once a poisoned passage is inside the context it is indistinguishable from your own instructions — after concatenation there is nothing left to attribute it to.

Where a RAG pipeline is exposed

  1. 01

    Untrusted-Content Marking

    Wrap retrieved chunks in provenance markers before the model reads them, so an instruction inside a document cannot read as an instruction from you. Measured 47-100% reduction in adaptive attack success across six frontier models, at no measurable utility cost. Opt-in, per project.

  2. 02

    Document Scanning

    Scan retrieved documents for hidden instructions, invisible text, and other indirect prompt injection techniques.

  3. 03

    Source Validation

    Validate document sources and flag content from untrusted or potentially compromised sources.

  4. 04

    Content Sanitization

    Clean retrieved content to remove potential threats while preserving useful information.

  5. 05

    Embedding Protection

    Protect your vector database from poisoning attacks that could inject malicious content.

  6. 06

    Query Protection

    Scan user queries for injection attempts before they reach your retrieval system.

  7. 07

    Response Validation

    Ensure LLM responses based on retrieved content don't leak sensitive information.

Why PromptGuard for RAG?

  • Specialized indirect injection detection
  • Document-level threat scanning
  • Vector DB poisoning protection
  • Full pipeline security
  • Works with any RAG framework

How it works for RAG

  1. 01

    Query

    User query comes in. PromptGuard scans for injection attempts before retrieval.

  2. 02

    Retrieve & Scan

    Documents are retrieved from your vector DB. Each document is scanned for hidden threats.

  3. 03

    Generate Safely

    Clean, validated context is passed to the LLM. Response is validated before returning.

Secure a RAG pipeline

python
from promptguard import PromptGuard
from langchain.retrievers import VectorStoreRetriever

pg = PromptGuard(api_key="your-api-key")

# Retrieve documents
documents = retriever.get_relevant_documents(query)

# Scan each document for hidden threats
safe_documents = []
for doc in documents:
    scan_result = pg.scrape.scan(
        content=doc.page_content,
        content_type="text/plain"
    )

    if scan_result.is_safe:
        safe_documents.append(doc)
    else:
        print(f"⚠️ Blocked document: {scan_result.threats}")

# Use only safe documents for generation
response = llm.generate(context=safe_documents, query=query)

The controls this sector runs on

Secure your RAG pipeline

Stop indirect prompt injection attacks. Protect your knowledge base and your users.