<!-- llms-explorer concept facts · https://llms-explorer.com/tree/client-side-encryption-dek-rewrapping-with-rewrapmanydatakey/ · pack 2026-10-29 · ~1446 tokens -->

# Client-side encryption DEK rewrapping with rewrapManyDataKey

> Source-anchored research for Client-side encryption DEK rewrapping with rewrapManyDataKey. Run status: COMPLETED.

Parent: [MongoDB Security Architecture](https://llms-explorer.com/tree/mongodb-security-architecture/) · 4 facets · 17 facts · page: https://llms-explorer.com/tree/client-side-encryption-dek-rewrapping-with-rewrapmanydatakey/

## Definitions

- The operation is not atomic, and MongoDB warns against running it in parallel with other key-management operations. (low confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)

## How it works

- The historical MONGOCRYPT-464 bug affected rewrapping with libmongocrypt 1.5.0/1.5.1: when Azure- or GCP-backed DEK decryption required fetching an access token, rewrapping could replace original key material with random material. The documented fix was libmongocrypt 1.5.2. (medium confidence) — [source](https://jira.mongodb.org/browse/PHPC-2120)
- The driver API returns RewrapManyDataKeyResult with an optional bulkWriteResult; it can be absent when no keys match or when the bulk write is unacknowledged. (low confidence) — [source](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md)
- The options identify the target KMS provider and provider-specific masterKey. When masterKey is omitted, each DEK uses the CMK referenced in its existing metadata. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)
- AWS KMS key-material rotation preserves the logical KMS key and selects the original key material when decrypting existing ciphertext. It does not rotate data keys or mitigate a compromised data key; MongoDB likewise leaves DEK material unchanged when rewrapping. (medium confidence) — [source](https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html)

## Comparisons and alternatives

- rewrapManyDataKey decrypts existing DEKs and re-encrypts their unchanged plaintext key material under the selected CMK. Rewrapping changes key protection rather than replacing the DEKs that encrypt application fields. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults.md)

## Facts and statements

- The key vault stores CMK-encrypted DEKs. A client needs both key-vault access and access to the protecting KMS key to use a DEK; the key vault can reside on a separate MongoDB cluster. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults.md)
- Rotating the KMS key does not itself rewrap existing stored DEKs. AWS additionally documents that key rotation does not replace data keys, re-encrypt protected data, or mitigate a compromised data key. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults.md)
- The filter selects key-vault documents to rewrap. If no key matches, the driver performs no bulk write; without a new masterKey, DEKs are rewrapped using their current master keys. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)
- Back up the key-vault collection before rewrapping: losing DEK material can make the corresponding encrypted data unrecoverable. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)
- The client-side encryption specification requires applicable drivers to reject rewrapManyDataKey with libmongocrypt 1.5.0 or 1.5.1 and document dependency upgrades for MONGOCRYPT-464. (low confidence) — [source](https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.md)
- Fortanix documents a concrete KMIP integration sequence: rotate the CMK in DSM, then call ClientEncryption.rewrapManyDataKey with the returned CMK identifier as masterKey.keyId and the chosen provider. (low confidence) — [source](https://support.fortanix.com/v1/docs/fortanix-dsm-for-mongodb-client-side-field-level-encryption)
- rewrapManyDataKey decrypts matching wrapped DEKs, re-encrypts them under a specified CMK, and updates their documents in the Key Vault collection. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)
- Rotating a CMK at the KMS does not automatically rewrap existing MongoDB DEKs; an explicit rewrapManyDataKey operation performs that separate step. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/keys-key-vaults.md)
- The query filter selects Key Vault documents to rewrap; an empty filter selects all keys. If no keys match, the driver specification requires no bulk write and leaves bulkWriteResult unset. (medium confidence) — [source](https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/manage-keys.md)
- Back up the Key Vault before rewrapping and confirm that keys no longer protect any required data or keys before deleting them. Losing a required DEK or CMK can make encrypted fields permanently unreadable. (medium confidence) — [source](https://www.mongodb.com/docs/manual/reference/method/KeyVault.rewrapManyDataKey.md)
- MongoDB's mongosh v1.5.4 release notes, dated July 31, 2022, describe a destructive historical bug: rewrapping an Azure- or GCP-backed DEK that required fetching an access token for decryption could replace all rewrapped DEKs with random material. The release notes identify v1.5.4 as the shell fix. (low confidence) — [source](https://www.mongodb.com/docs/mongodb-shell/changelog.md)
