MEK (Master Encryption Key) Rotation
MEK (Master Encryption Key) Rotation
Overview
The Master Encryption Key (MEK) is an AES-256-GCM key stored in OpenBAO that wraps all Namespace Encryption Keys (NEKs). The MEK is shared across NVCF services in the control plane — ESS is its primary consumer.
Rotate the MEK on a regular schedule (for example, every 90 days) or when required by your security policy.
Prerequisites
kubectlconfigured for your NVCF control plane cluster- Access to OpenBAO pods in the
vault-systemnamespace - The OpenBAO root token (stored in the
openbao-server-root-tokensecret invault-system) - A tool to generate UUIDs (
uuidgenor equivalent) base64,python3, orjqfor JSON manipulation- A maintenance window; MEK rotation can briefly affect availability
Where the MEK is Stored
The MEK is stored in the services/all/kv/ KV v2 secret engine in OpenBAO, at the path:
encryption/keys/stored_data
This path contains four fields:
Inspecting Current State
Retrieve the OpenBAO root token:
Read the current MEK data:
Decode the keys array to see the current MEK(s):
You should see output like:
MEK Rotation Procedure
Do not remove the old MEK from the keys array. ESS needs the old MEK to decrypt existing NEKs during the transition.
-
Read the current stored_data and save it as a backup:
-
Generate a new MEK key ID and key material:
-
Build the updated keys JSON with the new key as the first element:
-
Write the updated values back to OpenBAO:
-
Verify the update:
The output should show your new key ID (
$NEW_KID).
Verification
After completing MEK rotation:
-
OpenBAO shows the updated
current_kid: -
ESS pods are
RunningandReadywith no MEK/decryption errors: -
Secrets can still be read and written through the NVCF API.
MEK Propagation Grace Period
After writing the new MEK to OpenBAO, ESS does not start using it immediately. Each ESS pod refreshes its secrets from OpenBAO via the vault-agent sidecar container roughly every 24 hours. Because different pods refresh at different times, there is a default grace period of 48 hours before the new MEK is actively used for encryption.
This grace period prevents a race condition: if pod A picks up the new MEK and uses it to write encrypted data to the database before pod B has refreshed, pod B would be unable to decrypt that data because it still only has the old MEK loaded.
- Do not remove the old MEK from the
keysarray as ESS needs the old MEK to decrypt existing NEKs during the transition. - During the grace period the old MEK remains the active encryption key; the new MEK is present in the key set but not yet used for writes.
- After the grace period, ESS switches to the new MEK for all new encryption operations while retaining the old MEK for decrypting previously encrypted data.
Rollback
If the rotation causes issues:
-
Restore the previous
keys,current_kid,jwe_mapping, andprivate_jwksfrom the backup (mek_backup.json) taken in Step 1: -
Restart ESS to pick up the restored MEK:
-
Do not remove the old key from the keys array until the new key has been verified and ESS is healthy.