rag-cag-security

Implement multi-tenant isolation, access control, and sanitization for RAG and CAG pipelines.

14|1|Updated Dec 5, 2025
One-click install
npx skills add https://github.com/jpoutrin/product-forge --skill rag-cag-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rag-cag-security
Source: https://github.com/jpoutrin/product-forge/tree/main/plugins/rag-cag/skills/rag-cag-security
Command: npx skills add https://github.com/jpoutrin/product-forge --skill rag-cag-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensuring data privacy, access control, and protection against prompt injection in Retrieval-Augmented Generation (RAG) and Cache-Augmented Generation (CAG) systems, especially in multi-tenant environments, is a complex and critical challenge. This Skill provides robust security patterns.

Core Features & Use Cases

  • Multi-Tenant Architecture: Strategies for tenant isolation, including namespace isolation, metadata filtering, and separate collections in vector stores.
  • Access Control: Patterns for implementing document-level permissions based on user roles, groups, and data classification.
  • Prompt Injection Prevention: Techniques and code examples for sanitizing retrieved content before it's included in an LLM prompt.
  • Data Classification: Guidelines for categorizing data (Public, Internal, Confidential, Restricted) and handling it securely.
  • Use Case: Designing a secure multi-tenant RAG system, implementing document-level access control for retrieved content, sanitizing retrieved chunks before prompt inclusion, or classifying sensitive data in an AI pipeline.

Quick Start

Use the rag-cag-security skill to generate a Python code snippet for filtering vector store results by tenant_id.

Frequently Asked Questions about rag-cag-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement multi-tenant isolation in a RAG system?

Multi-tenant isolation in RAG separates tenant data through namespace isolation, metadata filtering, and separate vector store collections per tenant. This prevents one tenant's documents from being retrieved for another tenant's queries, ensuring data privacy and access control at the retrieval layer.

What techniques prevent prompt injection attacks in RAG pipelines?

Prompt injection prevention in RAG involves sanitizing retrieved context before including it in LLM prompts. Sanitization removes or escapes malicious content from retrieved chunks, blocking attackers from manipulating the model's behavior through compromised documents in the knowledge base.

How do I apply document-level permissions to retrieved content?

Document-level permissions in RAG filter retrieved chunks based on user roles, groups, and data classification before passing them to the LLM. Implement role-based access control and metadata filtering to ensure users only see documents they're authorized to access.

Can I use access control with vector databases for multi-tenant applications?

Yes, vector databases support multi-tenant access control through namespace isolation, per-tenant collections, and metadata-driven filtering. This allows you to store embeddings for multiple tenants while enforcing strict data separation and permission boundaries at query time.

What data classification categories should I use for AI security?

Standard data classification for AI security uses four tiers: Public, Internal, Confidential, and Restricted. Each tier determines encryption requirements, access controls, and audit logging levels, enabling consistent handling of sensitive data across RAG and CAG systems.

Why is encryption and audit logging necessary in multi-tenant AI systems?

Encryption at rest protects sensitive documents in vector stores and databases from unauthorized access, while audit logging tracks who accessed what data and when. Together they satisfy compliance requirements and enable detection of security incidents in multi-tenant environments.