fix: verify tenant/database ownership in data-plane collection auth - #7480
Open
PiedPiper911 wants to merge 1 commit into
Open
fix: verify tenant/database ownership in data-plane collection auth#7480PiedPiper911 wants to merge 1 commit into
PiedPiper911 wants to merge 1 commit into
Conversation
…ross-tenant access The data-plane endpoints (add, get, query, count, update, etc.) resolve collections purely by UUID without verifying that the collection belongs to the tenant/database in the URL path. This allows any caller who knows a collection UUID to bypass tenant isolation. Add an ownership check in authenticate_and_authorize_collection that verifies the resolved collection's tenant and database match the request path, returning 404 for cross-tenant references — matching the behavior of the correctly-scoped sibling endpoints (GET by-id, DELETE). Fixes chroma-core#7462
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Author
|
Friendly ping - this PR adds tenant/database ownership verification in data-plane collection operations to prevent cross-tenant access. Happy to add tests or adjust the implementation if needed. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Chroma's REST API scopes every collection operation under
/api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/..., but the data-plane endpoints (add,get,query,count,updaterecords,update_collection,fork_count,indexing_status) resolve the target collection purely by UUID viaget_cached_collection— never verifying that the UUID actually belongs to the{tenant}/{database}in the URL path.Any caller who knows another tenant's collection UUID can read, write, and modify that collection's data by issuing the request under their own tenant/database prefix. This defeats Chroma's tenant/database isolation model.
The sibling endpoints (
GET .../collections/by-id/{id},DELETE .../collections/{id}) correctly 404 for cross-tenant references, proving this is an omission rather than intentional design.Solution
Add a tenant/database ownership verification in
authenticate_and_authorize_collection(the shared auth helper used by all data-plane endpoints). After resolving the collection viaget_cached_collection, verify thatcollection.tenantandcollection.databasematch the values from the request path (available inAuthzResource). Return 404 for mismatches — matching the behavior of the correctly-scoped sibling endpoints.Changes
rust/frontend/src/server.rs: Added tenant and database ownership checks inauthenticate_and_authorize_collectionafter collection resolution.Testing
The fix ensures that for any collection C owned by
(T1, D1), a data-plane request authenticated as(T2, D2)where(T1,D1) != (T2,D2)returns 404 instead of silently succeeding. This matches the existing behavior ofGET by-idandDELETE.Notes for Reviewer
resource.tenantandresource.databasefromAuthzResource, which are populated from the URL path parameters at every call site.get_cached_collection(which populates the cache) but before the auth delegation, so it protects all 13+ data-plane endpoints that go through this helper.collection_idalone) is a separate optimization; this fix ensures correctness regardless of cache state since the ownership check runs on every request.Fixes #7462