fix: RAG keyword fallback leaked owner-less documents across users (#1722)
VectorRAG.search() filters with ChromaDB where={"owner": owner}, returning only
documents whose owner equals the requesting user. The keyword fallback
(_keyword_search_fallback, used when the primary query raises) guarded with
`if doc_owner and doc_owner != owner: continue`, so a document with a
missing/empty owner fell through and was returned to whichever user issued the
query — a cross-user information leak on the fallback path.
Match the primary path's strict filter: skip any doc whose owner != the
requested owner, including owner-less docs.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -260,8 +260,11 @@ class VectorRAG:
|
||||
for i, doc in enumerate(all_docs["documents"]):
|
||||
meta = all_docs["metadatas"][i]
|
||||
if owner:
|
||||
doc_owner = meta.get("owner")
|
||||
if doc_owner and doc_owner != owner:
|
||||
# Match the primary path's strict where={"owner": owner}
|
||||
# filter. The old `if doc_owner and doc_owner != owner`
|
||||
# let docs with a missing/empty owner fall through, leaking
|
||||
# owner-less documents into another user's results.
|
||||
if meta.get("owner") != owner:
|
||||
continue
|
||||
doc_lower = doc.lower()
|
||||
score = sum(1 for w in query_words if w in doc_lower)
|
||||
|
||||
Reference in New Issue
Block a user