Minimizing Cross-Tenant Leakage in Azure Cosmos DB Vector Search
Short answer
D Partition by tenant (customerId) and always scope vector queries to that partition key, with retrieval logging
Question
Key Takeaways
Partitioning by tenant and scoping vector queries to the partition key in Azure Cosmos DB for NoSQL minimizes cross-tenant leakage risk. This approach ensures physical data isolation and efficient single-partition queries, unlike shared containers or client-side filtering which expose data to broader scanning.
Expert Analysis
Partitioning by tenant and constraining every vector query to that partition key both isolates data and makes queries efficient and single-partition, while retrieval logging satisfies auditing. Relying only on a query filter without tenant partitioning, post-retrieval client-side filtering, or lumping tenants together all raise the risk of returning another customer's data.
In Azure Cosmos DB for NoSQL, particularly when integrating vector search capabilities for AI solutions like Retrieval-Augmented Generation (RAG), data isolation is not merely a logical concern but a physical one enforced by the storage engine. The critical mechanism here is the partition key. When a container is configured with a specific property—such as customerId—as the partition key, Cosmos DB physically separates the data items into distinct partitions based on the hash of that value. This physical separation ensures that any query scoped to a specific partition key reads from a single, isolated data slice. If the query does not specify the partition key, it becomes a cross-partition query, which scans multiple physical partitions. In a multi-tenant SaaS environment, this scanning behavior is the primary vector for cross-tenant data leakage, especially when combined with approximate nearest neighbor (ANN) vector searches that may return results based on semantic similarity rather than exact matches.
Option D correctly implements this security boundary by enforcing two constraints: first, the data is explicitly partitioned by customerId, ensuring physical isolation; second, every vector query is required to include the customerId in its scope. This forces the query engine to target only the relevant physical partition, eliminating the possibility of retrieving vectors belonging to other customers. Additionally, the inclusion of retrieval logging addresses the auditing requirement mentioned in the scenario, providing a trail of access without compromising data integrity.
Let’s examine why the other options fail under these constraints:
Option A suggests using a single global index with client-side filtering. While a global index allows flexible querying, it indexes all data across all partitions. A client-side filter applies logic after the database has returned results. However, vector search queries often return a top-K list of similar items. If the query itself is not scoped to a partition, the database returns the most semantically similar vectors from the entire dataset. Filtering them out client-side is inefficient and risky because the initial retrieval step already exposed the potential for mixing data at the infrastructure level. Furthermore, if the client application crashes or logs errors during filtering, partial leakage might occur. More importantly, relying on client-side logic shifts the security burden away from the database’s inherent isolation guarantees.
Option B proposes storing all tenants in one item. This is architecturally unsound for several reasons. First, it violates the NoSQL principle of scalable, independent scaling units. Second, it creates a massive bottleneck where every read/write operation affects all tenants. Third, it offers no isolation whatsoever; any query accessing that single item inherently accesses all tenant data simultaneously. This design maximizes cross-tenant leakage risk to the extreme.
Option C recommends a shared container with customerId used only as a query filter and no partitioning by tenant. Without a partition key defined in the container schema, Cosmos DB treats the entire dataset as a single logical unit with potentially many physical partitions based on internal hashing, but without explicit control over tenant boundaries. Using customerId as a filter in the SQL-like query language is a logical constraint, not a physical one. The query engine will still scan multiple partitions to find matches. In vector search scenarios, this can lead to inconsistent performance and increased latency, but more critically, if the query planner optimizes for speed over strict isolation, there is a higher risk of non-deterministic behavior in multi-tenant environments. Unlike Option D, where the partition key is part of the query’s identity, here it is just a predicate. This distinction is vital: predicates can be optimized away or handled differently by the query optimizer, whereas partition keys are fundamental to the execution plan’s structure.
Therefore, the combination of physical partitioning and query scoping in Option D provides the strongest guarantee against cross-tenant leakage, aligning with the zero-trust principles required for financial applications.
Exam Strategy
When designing secure multi-tenant solutions in Azure Cosmos DB, always prioritize physical partitioning over logical filtering. Define the tenant identifier as the partition key and enforce its presence in every query, especially for vector searches. Avoid global scans or client-side filtering for security boundaries, as they do not provide the same isolation guarantees and can introduce performance and compliance risks.
Related Analysis
Practice All AI-200 Questions
Access 69 questions with complete answers and detailed explanations.
View Full AI-200 Practice Test →