Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: user selected documents don't intersect with available docs

Marc Seitz82ff438c4578
diff --git a/ee/features/ai/lib/chat/send-message.ts b/ee/features/ai/lib/chat/send-message.ts
index e641269d..d01fcfe4 100644
--- a/ee/features/ai/lib/chat/send-message.ts
+++ b/ee/features/ai/lib/chat/send-message.ts
@@ -78,6 +78,11 @@ If you cannot find the answer in the documents, say so clearly.`,
effectiveIds = userSelectedDataroomDocumentIds.filter((id) =>
filteredDataroomDocumentIds.includes(id),
);
+ // Security: If intersection is empty (user sent unauthorized IDs),
+ // fall back to the permission-based filter to prevent searching all documents
+ if (effectiveIds.length === 0) {
+ effectiveIds = filteredDataroomDocumentIds;
+ }
}
if (effectiveIds.length > 0) {
fileSearchOptions.filters = {