Zero-Leak RAG Lab: Identity-Aware Enterprise Grounding & RLS Studio
Pre-Retrieval IAM & ACLsBigQuery Row-Level SecurityHybrid BM25 + Vector RRFPrompt-Injection & Citation GuardrailsLocal Ollama + Cloud LLMs
Enterprise RAG • Identity & RLS • Hybrid Search

Zero-Leak RAG Lab: Identity-Aware Enterprise Grounding & RLS Studio

Summary

Zero-Leak RAG Lab is a zero-dependency, local-first Enterprise AI Grounding & Security Architecture Workbench (Port 8111) built to demonstrate and stress-test how production Retrieval-Augmented Generation (RAG) pipelines defeat the “Confused Deputy” data-leakage anti-pattern. Rather than indexing enterprise stores behind a single over-privileged backend service account and hoping a system prompt hides restricted context, Zero-Leak RAG Lab enforces Pre-Retrieval Identity Propagation, BigQuery Row-Level Security (RLS), Hybrid Search (Sparse BM25 + Dense Semantic Vector + Reciprocal Rank Fusion), and Citation Grounding Verification.

Key Features

  • Side-by-Side Naive (“Confused Deputy”) vs. Zero-Leak Identity-Propagated RAG: Runs both retrieval pipelines concurrently in a ThreadPoolExecutor across 4 caller personas (US-West Sales Rep, Principal SRE, VP Finance, and CEO — Least-Privilege HR Test), contrasting leaked M&A, out-of-region ARR, and HR/HIPAA records (DOC-MNA-004, BQ-ROW-103, DOC-HR-006) against zero-leak pre-filtered retrieval.
  • Multi-Connector Pre-Retrieval ACLs & BigQuery Row-Level Security (RLS): Evaluates OAuth/OIDC group memberships and regional warehouse row predicates (US-WEST, US-EAST, EMEA) before scoring or ranking across 3 unified enterprise connectors: an Enterprise Document Store, a BigQuery RLS Warehouse, and an Issue Tracker MCP Connector.
  • Hybrid BM25 + Dense Vector + Reciprocal Rank Fusion (RRF) Retrieval: Demonstrates why pure dense vector embeddings miss exact alphanumeric ticket IDs (SEC-401, OPS-209) while pure keyword search misses semantic synonyms (acquisition ↔ M&A), fusing active rankers cleanly via RRF.
  • RAG vs. Long-Context (1M+) vs. Fine-Tuning Trade-Off Calculator & Connector Bug Hunt: Models corpus token scale (250K–50M+), update frequency, query load, citation needs, and per-user ACL feasibility alongside 4 interactive Python/SQL security bug reviews (Post-Filter Top-K Starvation, Dense-Only Ticket ID Miss, Unscoped Semantic Cache Bleed, and Static Service-Account Keys + SQLi).
  • Local Onboard Ollama Default + Optional Cloud APIs & Citation Verifier: Auto-detects local Ollama models (:11434) out of the box with optional volatile-session support for Google Gemini, OpenAI, and Anthropic Claude APIs, paired with prompt-injection pattern screening and [ID] citation validation.

Tech Stack

  • Retrieval & Security Core: Python 3.10+ Standard Library (Zero External Dependencies), Pre-Retrieval IAM/OIDC Claim Filter, Regional BigQuery RLS Predicate Evaluator, Sparse BM25 + Dense Concept Embedder + Reciprocal Rank Fusion (RRF)
  • Guardrails & Grounding: Prompt-Injection & Privilege-Escalation Screen, Strict [DOC-*] / [BQ-ROW-*] / [SEC-*] Citation Grounding Verifier, Architecture Trade-Off Modeling Engine
  • LLM Runtime Support: Local Ollama Onboard Engine (http://127.0.0.1:11434 Default) + Optional Cloud APIs (Google Gemini, OpenAI, Anthropic Claude) + Transparent Deterministic Offline Mode
  • Verification Suite: 14-test automated unittest suite (tests/test_raglab.py) verifying zero cross-persona leaks across all personas/strategies, regional RLS isolation, RRF exact-ID ranking, and trade-off consistency

Theory & Architecture

A system prompt is never an access-control boundary. Once an unauthorized M&A term sheet, out-of-region revenue row, or HR medical record enters an LLM context window via a shared service account, prompt injection or indirect summarization can exfiltrate it—and filtering after vector search starves Top-K slots. Zero-Leak RAG Lab enforces caller identity predicates prior to candidate scoring so unauthorized chunks are mathematically excluded from both ranking and context assembly.