Hiding in Plain Sight: Exploiting a RAG Knowledge Base From the Inside
A hidden instruction in a shared document was indexed into a RAG knowledge base, causing the chatbot to disclose a planted admin password when asked a security-related question. The attacker could leak sensitive information by adding a malicious document to the indexed folder.
Will Giles | Cybersecurity Follow
Published on wgilescyber.medium.com
RAG stands for Retrieval Augmented Generation. It is a technique that enriches large language models with more accurate and context-aware information.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the system indexed any document without validation or access control, and the model followed instructions embedded in retrieved content without guardrails.
Impact
An attacker could cause the chatbot to disclose sensitive information, such as an admin password, to any user asking a related question.
What the attacker needed
Ability to add a document to the indexed folder; chatbot indexes documents automatically; no validation or access control on indexed files
The fix
The system should validate and sanitize documents before indexing, strip hidden formatting, sanitize model outputs, and enforce access controls.
How it was found
- Add a malicious document containing a hidden prompt to the Google Drive folder that is automatically indexed.
- Wait for the document to be indexed into the Pinecone vector database.
- Ask the chatbot a security-related question.
- Observe the chatbot leak the planted admin password as instructed by the hidden prompt.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A RAG chatbot answers questions by looking up documents you give it. Here, someone put a secret instruction in a document, hidden as white text on a white background. When the chatbot read that document to answer a question, it followed the hidden instruction and revealed a password.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.