Consult server-side encryptedFields when dropping QE collections - #3099
Merged
comandeo-mongo merged 1 commit intoJul 30, 2026
Merged
Conversation
Dropping a queryable encryption collection through a client that has auto encryption configured without an encryptedFieldsMap left the enxcol_.<name>.esc/.ecoc metadata collections behind: the listCollections fallback ran only when the map was present. Per the client-side-encryption spec (GetEncryptedFields with askDb=true) and the reference implementation, the server lookup must happen whenever auto encryption is configured. Also add the spec-mandated documentation note that supplying an encrypted_fields_map protects against a malicious server advertising false encryptedFields.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes queryable encryption (QE) collection drops when a client has auto encryption enabled but does not supply an encrypted_fields_map, ensuring the driver still consults server-advertised encryptedFields so the QE metadata collections are properly removed.
Changes:
- Update QE drop logic to consult server-side
encryptedFieldswhenever auto encryption is configured (not only whenencrypted_fields_mapis present). - Add an integration spec covering both the map-absent case and the present-but-empty map case.
- Document the security implication of relying on server-provided
encryptedFieldsvs providing anencrypted_fields_map.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/mongo/collection/queryable_encryption.rb |
Adjusts QE metadata-drop behavior to fall back to server encryptedFields whenever auto encryption is enabled. |
spec/integration/client_side_encryption/qe_drop_collection_spec.rb |
Adds an integration regression spec to verify QE metadata collections are removed on drop for both configuration variants. |
lib/mongo/client.rb |
Adds a documentation note about the security benefit of providing encrypted_fields_map. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+516
to
521
| # - Note: Supplying an encrypted_fields_map provides more security | ||
| # than relying on an encryptedFields obtained from the server. It | ||
| # protects against a malicious server advertising a false | ||
| # encryptedFields. | ||
| # - Note: If a collection is present on both the encryptedFieldsMap | ||
| # and schemaMap, an error will be raised. |
jamis
approved these changes
Jul 30, 2026
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.
What changed
Dropping a queryable encryption collection through a client that has auto encryption configured but no
encryptedFieldsMapleft theenxcol_.<name>.esc/.ecocmetadata collections behind. ThelistCollectionsfallback inmaybe_drop_emm_collectionsonly ran when the map itself was present, while the client-side-encryption spec (GetEncryptedFieldswithaskDb=true) and PyMongo perform the server lookup whenever auto encryption is configured.The spec test suite does not catch this: the
fle2v2-CreateCollection.yml"DropCollection from remote encryptedFields" test configures the client withencryptedFieldsMap: {}, which is present (and truthy), so only the map-absent case was broken.Also adds the documentation note required by the spec: supplying an
encrypted_fields_mapprotects against a malicious server advertising falseencryptedFields.Testing
New integration spec covers both the map-absent case (previously failing) and the present-but-empty map case, asserting the metadata collections exist after create and are gone after drop. Ran against a local 9.0.0-rc0 replica set together with
explicit_queryable_encryption_spec.rbandqueryable_encryption_examples_spec.rb: 8 examples, 0 failures. RuboCop clean on the changed files.