Skip to main content
Applies to:
DuoKey Cockpit v2MongoDB Queryable Encryption (QE)Client-side field-level encryption, queryable

Overview​

MongoDB Queryable Encryption (QE) keeps fields encrypted client-side, the same way CSFLE does, but with one key difference: specific fields can still be queried — for equality, or for a numeric/date range — without the server ever seeing plaintext or a value it can otherwise correlate the way a deterministic CSFLE field can. Each queryable field carries its own Data Encryption Key (DEK), and those DEKs are wrapped by a Customer Master Key (CMK) — a DuoKey vault key.

This app's role mirrors CSFLE: it provisions and manages the CMK, and it emits the two artifacts the MongoDB driver needs — the encryptedFieldsMap (which fields are QE-encrypted, and with which query type) and the CMK reference (KMS provider plus key ID) the driver passes as the masterKey when creating a DEK.

Architecture

MongoDB Queryable Encryption: where encryption happens

MongoDB Queryable Encryption with DuoKeyThe driver encrypts fields and query predicates; MongoDB receives ciphertext and encrypted query tokens only, and the driver asks DuoKey to unwrap the per-field data encryption keys.APPLICATION HOSTMONGODBDUOKEYPLAINTEXTCIPHERTEXTQUERY TOKENSUNWRAP DEKAPPApplicationwrites · queries fieldsDRIVERMongoDB driverautomatic encryptionMONGODBMongoDB serverencryptedFieldsMap collectionkey vault collectionCMKDuoKey vaultCMK wraps per-field DEKsLEGENDYour applicationDriverMongoDBDuoKeyKey request

The server still never sees plaintext, but for declared fields it can match encrypted structures without decrypting.

PropertyValue
Encryption modelClient-side field-level encryption — queryable (equality / range) or non-queryable per field
Key custodyDuoKey vault key acts as the CMK wrapping per-field DEKs
OnboardingApp detail page — no wizard entry
Proof statusThe emitted `encryptedFieldsMap` and CMK reference are real and usable as-is; the self-test is currently simulated — see below

CSFLE vs. Queryable Encryption​

CSFLEQueryable Encryption
What the server seesOpaque ciphertext, never queryableCiphertext, but structured so equality/range queries still work
Query supportNone on encrypted fields (unless deterministic, and then only exact equality with a correlation trade-off)Equality and range predicates on declared fields, without deterministic ciphertext repetition
Per-field configurationA single encryption schema (deterministic or random) per fieldEach field declares a query_type: equality, range (with optional min/max bounds), or none
Key custody modelCMK wraps per-field DEKsSame — CMK wraps per-field DEKs
Choosing between them

Use CSFLE when a field never needs to be queried, or only ever needs exact-match lookups and you accept the correlation trade-off of deterministic encryption. Use Queryable Encryption when you need equality or range queries on an encrypted field without that trade-off — for example, filtering patient records by an encrypted date-of-birth range. See MongoDB CSFLE for the simpler model.

How an equality or range query stays server-side​

This is the step CSFLE's model cannot do. A CSFLE field is opaque ciphertext end to end — the server can store and return it, but never compare it. A Queryable Encryption field uses a structured, searchable encryption scheme: the driver turns a query predicate into an encrypted token, and MongoDB compares that token against encrypted index structures for the field — matching without ever decrypting.

Sequence

Querying an encrypted field without decrypting it

Querying an encrypted fieldThe driver turns the predicate into an encrypted token, MongoDB matches it against encrypted index structures without decrypting, and the driver decrypts the results after DuoKey unwraps the DEK.1 QUERY2 ENCRYPT PREDICATEQUERY TOKEN3 MATCH · NO DECRYPTCIPHERTEXT DOCS4 UNWRAP DEKDEKDECRYPT RESULTS5 PLAINTEXTAPPApplicationequality or range queryDRIVERMongoDB driverautomatic encryptionMONGODBMongoDB serverencrypted indexDUOKEYDuoKey vaultCMKLEGENDCallReturnLocal stepServer-side matchDuoKey

Step 3 is what CSFLE cannot do: the server matches encrypted structures for a declared field instead of only storing opaque ciphertext.

Equality or range, not both

A field is declared for one query type at a time — equality or range — matching the query_type in its field declaration (see below). This mirrors MongoDB's own constraint: a queryable-encrypted field supports the query type it was configured for, not arbitrary predicates.

Configuration​

FieldPurpose
mongodb_uridatabasecollectionConnection URI and target collection whose fields are QE-encrypted.
key_vault_namespaceNamespace (`database.collection`) MongoDB uses to store encrypted data keys. Defaults to `encryption.__keyVault`.
kms_providerKMS provider type wrapping the DEKs — `kmip` (DuoKey), `aws`, `azure`, `gcp`, or `local`.
cmk_key_idThe DuoKey vault key acting as the Customer Master Key.
fieldsThe declared queryable-encrypted fields (see below).

Field declarations​

Each entry in fields declares one document field to bring under Queryable Encryption:

PropertyPurpose
pathDotted field path within the document, e.g. `ssn` or `patient.dob`.
bson_typeBSON type of the field (`string`, `int`, `long`, `date`, `decimal`, …). Defaults to `string`.
query_type`equality`, `range`, or `none` (encrypted but not queryable). Defaults to `equality`.
minmaxOptional inclusive bounds for a `range` field.

What gets emitted​

Deploying the app returns the CMK reference and the encryptedFieldsMap, ready to pass into the MongoDB driver's AutoEncryptionOpts or db.createCollection(..., { encryptedFields }).

CMK reference (masterKey for DEK creation)JSON
{
"provider": "kmip",
"key_id": "<cmk-vault-key-id>",
"key_vault_namespace": "encryption.__keyVault",
"endpoint_guid": "<app-endpoint-guid>"
}
encryptedFieldsMap — equality and range fieldsJSON
{
"medical.patients": {
  "fields": [
    {
      "path": "ssn",
      "bsonType": "string",
      "keyId": null,
      "queries": [{ "queryType": "equality" }]
    },
    {
      "path": "age",
      "bsonType": "int",
      "keyId": null,
      "queries": [{ "queryType": "range", "min": 0, "max": 150 }]
    },
    {
      "path": "notes",
      "bsonType": "string",
      "keyId": null
    }
  ]
}
}
keyId: null is intentional

A null keyId instructs the MongoDB driver to auto-create a per-field DEK on first use, wrapped by the CMK above. The notes field above has no queries array — it is encrypted but deliberately not queryable, matching a query_type of none.

Health and self-test​

CheckWhat it reportsLive probe today
HealthMongoDB reachability, key vault access, CMK reachabilityNo — returns a fixed healthy status envelope
Self-testMongoDB connection, key vault access, CMK wrap/unwrap, equality/range query round-tripNo — all four checks return a hardcoded pass
What is real vs. simulated, precisely

The handler behavior for enable/disable/health/self-test is simulated — there is no live MongoDB round-trip yet. But the encryptedFieldsMap and CMK reference shown above are not placeholders: they are generated from your actual field declarations and vault key, and can be used as-is in a driver's AutoEncryptionOpts.

Encrypted fields require createCollection, not a later ALTER

Queryable Encryption's encryptedFields must be supplied when the collection is created — you cannot retroactively enable it on an existing collection's existing documents.