LangChain CVE-2025-68664: आपकी RAG Pipeline से PII कैसे Leak होती है
2026 के लिए अपडेट किया गया।
LangChain में 2025 के अंत में एक critical flaw मिली। CVE है CVE-2025-68664। CVSS score है 9.3 (Critical)।
यह LangChain के serialization code को target करती है।
CVE-2025-68664 क्या करती है
LangChain में दो serialization functions हैं: dumps() और dumpd()। ये Python objects को text में convert करते हैं।
Flaw closure handling में है।
जब LangChain एक callable को serialize करता है, तो यह closure context capture करता है।
एक attacker जो LLM response को नियंत्रित करता है, dumps() को trigger कर सकता है। Function तब Python process से environment variables पढ़ता है।
परिणाम data exposure है। API keys, database strings, JWT secrets, और AWS credentials model output में प्रकट हो सकते हैं।
जो attacker एक RAG source document में text inject करता है वह आपके production secrets पढ़ सकता है।
प्रभावित versions: LangChain 0.3.22 से नीचे (Python)। Version 0.3.22 में fix है।
PyPI data मार्च 2026 तक पुराने versions का व्यापक उपयोग दिखाता है।
RAG Pipelines में PII कैसे Leak होती है
CVE-2025-68664 dramatic है। लेकिन यह एक बड़ी समस्या का सिर्फ एक मामला है।
RAG pipelines से data routinely leak होता है। किसी attacker की जरूरत नहीं।
यहाँ एक standard enterprise RAG setup है।
पहला, ingestion। आप company documents को एक vector store में index करते हैं। Support tickets, customer emails, contracts, और HR records सोचें।
सामान्य vector stores हैं Pinecone, Weaviate, और pgvector।
अगला, retrieval। एक user सवाल पूछता है। System store से पाँच सबसे relevant chunks pull करता है।
फिर, generation। वे chunks एक LLM — GPT-4o, Claude, या Gemini — को context के रूप में जाते हैं।
दूसरा चरण समस्या है। Retrieved chunks में वही है जो source documents में था। इसमें शामिल हैं:
- Customer names, email addresses, और phone numbers
- Contract values, account numbers, और tax identifiers
- Employee salary data और performance review notes
- Clinical notes में patient names
- Immigration files में National ID numbers
वह data LLM को as-is जाता है। यह model output में प्रकट हो सकता है।
LLM provider इसे log करता है। यह आपकी conversation history में बैठता है। यह आपके observability stack में flow होता है।
कोई attack नहीं चाहिए। RAG इसी तरह design द्वारा काम करता है। Design real privacy risk पैदा करता है।
Enterprise Document Stores में 68 Secret Patterns
Security tooling 68 ज्ञात secret patterns track करती है। ये उम्मीद से ज़्यादा बार appear होते हैं।
सबसे सामान्य:
- AWS Access Key IDs (
AKIA...) - OpenAI API keys (
sk-...) - Anthropic API keys (
sk-ant-...) - Database URIs (
postgresql://user:password@host/db) - JWT tokens (base64-encoded headers)
- GitHub Personal Access Tokens
- Stripe secret keys (
sk_live_...) - SendGrid API keys
- Twilio account SIDs और auth tokens
- Private key PEM blocks
एक support ticket में debug session से customer API key हो सकती है।
एक contract में technical handoff से database credentials हो सकती हैं।
गलती से index किया गया config file पूरा secrets store उजागर कर सकता है।
जब ये files sanitization के बिना vector store में जाती हैं, तो हर query secrets LLM को pass कर सकती है।
वे end user तक भी पहुँच सकते हैं।
Fix: Embedding से पहले Anonymize करें
सही approach documents को chunking और embedding से पहले anonymize करती है।
यह step customer data handle करने वाले किसी भी system के लिए अनिवार्य है।
यहाँ anonym.legal API का उपयोग करके एक Python example है:
import requests
import os
ANONYM_API_KEY = os.environ["ANONYM_API_KEY"]
ANONYM_BASE_URL = "https://anonym.legal/api"
def anonymize_before_embedding(text: str) -> tuple[str, dict]:
"""Embedding से पहले PII anonymize करें।"""
response = requests.post(
f"{ANONYM_BASE_URL}/presidio/anonymize",
json={
"text": text,
"language": "en",
"anonymizers": {
"DEFAULT": {"type": "replace", "new_value": "[REDACTED]"},
"PERSON": {"type": "mask", "masking_char": "*", "chars_to_mask": 4, "from_end": False},
"EMAIL_ADDRESS": {"type": "replace", "new_value": "[EMAIL]"},
"PHONE_NUMBER": {"type": "replace", "new_value": "[PHONE]"},
"CRYPTO": {"type": "replace", "new_value": "[SECRET]"},
"URL": {"type": "keep"},
}
},
headers={"Authorization": f"Bearer {ANONYM_API_KEY}"}
)
result = response.json()
return result["text"], result.get("items", [])
def build_rag_index(documents: list[str], vectorstore):
"""केवल clean documents के साथ RAG index बनाएँ।"""
anonymized_docs = []
for doc in documents:
clean_text, entities = anonymize_before_embedding(doc)
anonymized_docs.append(clean_text)
print(f"Document से {len(entities)} PII entities हटाई गईं")
vectorstore.add_texts(anonymized_docs)
anonym.legal API 285+ entity प्रकारों को cover करती है। नाम, emails, phone numbers, national IDs, API keys, और database URIs सभी पकड़े जाते हैं।
कोई भी sensitive चीज़ vector store तक नहीं पहुँचती। इसलिए कुछ भी sensitive users तक leak नहीं हो सकता।
LangChain और LlamaIndex setup patterns के लिए developer guide देखें।
अभी CVE-2025-68664 Fix करें
यदि आप LangChain 0.3.22 से नीचे चला रहे हैं, अभी update करें:
pip install "langchain>=0.3.22" "langchain-core>=0.3.22"
Patching के बाद, injection risk के लिए अपने chain configs जाँचें। तीन steps:
पहला, retrieved chunks validate करें। LLM तक पहुँचने से पहले।
Content को strip करें जो injection patterns से match करे जैसे ignore previous instructions, system:, या <INST>।
दूसरा, embedding से पहले anonymize करें। यह attack surface को कम करता है।
यदि injection होती भी है, तो sensitive data वहाँ extract करने के लिए नहीं है।
तीसरा, chain permissions restrict करें। LangChain chains को जरूरत से ज़्यादा environment variables नहीं पढ़ने चाहिए।
Minimal scope वाले service account का उपयोग करें।
Math सरल है
CVSS score 9.3 है। Fix प्रति document एक API call है।
CVE-2025-68664 और general RAG data risk का combination एक real liability है।
समाधान स्पष्ट है: query time पर नहीं, ingestion पर anonymize करें।
Enterprise RAG requirements के लिए security and compliance overview देखें।
स्रोत
- NVD CVE-2025-68664, CVSS 9.3, LangChain serialization vulnerability
- LangChain security advisory, langchain-ai/langchain GitHub, 2025
- OWASP LLM Top 10: LLM01 Prompt Injection, LLM06 Sensitive Information Disclosure
- anonym.legal entity type documentation — 285+ supported entity types