Fields you marked with #[Encrypt] can end up stored as plain text in MongoDB, with no error or warning. Anyone who can read the database, its backups or its replicas without the encryption keys can read those fields. That undoes the point of MongoDB's Queryable Encryption, where the server should never see the plain text.
Who is affected
Apps on doctrine/mongodb-odm from 2.12.0 up to (not including) 2.17.3 that created encrypted collections with odm:schema:create or SchemaManager::createDocumentCollection(). The Doctrine advisory says a class is exposed when its encrypted fields come from more than one place: its own #[Encrypt] fields plus an embedded document with encrypted fields, or two or more embedded documents with encrypted fields. The list of fields to encrypt then silently lost some of them.
If all of a class's encrypted fields are declared in one place, such as only on the root document or only in one embedded document, you aren't affected.
What to do
Update to 2.17.3. The fix builds the complete field list. Updating alone isn't enough, because a collection's encryption settings can't be changed after it's created:
- Compare each encrypted collection's
encryptedFieldsoption with what the fixed version generates. - Drop and recreate any collection that's missing fields, then move the data into it.
- Treat values already stored as plain text as exposed, including copies in backups, snapshots and replicas.