Encryption at rest
Encryption at rest → across different products
Data at rest in a YugabyteDB universe should be protected from unauthorized users by encrypting it. You do this by enabling encryption at rest. When enabled, the data in your universe is secured using envelope encryption, whereby multiple encryption keys are used to encrypt data, and those keys are in turn encrypted by other keys in a key hierarchy.
YugabyteDB Anywhere uses the following types of keys for envelope encryption:
| Key | Description |
|---|---|
| Data encryption keys (DEK) | Symmetric keys used to directly encrypt the data. Each file flushed from memory has a unique DEK. This key is generated in the database layer of YugabyteDB. |
| Universe key | Symmetric key used to encrypt and decrypt DEKs. The latest universe key encrypts new DEKs; DEKs for older files remain encrypted with the universe key that was current when they were written. This key is generated by YugabyteDB Anywhere. |
| Master key | The key at the highest level in the key hierarchy. The master key is used to encrypt (wrap) universe keys. This key is a customer managed key (CMK) stored and managed in a Key Management Service (KMS). |
Master key details are stored in YugabyteDB Anywhere in KMS configurations, and YugabyteDB Anywhere supports CMKs in AWS KMS, GCP KMS, Azure Key Vault, OCI Vault, and Hashicorp Vault.
You enable encryption at rest for a universe by assigning the universe a KMS configuration. For instructions on creating a KMS configuration, see Create a KMS configuration.
For more information on the features, assumptions, design, data key management, universe keys, key rotations, master failures, and adding a node, see Encryption at rest in YugabyteDB.
Manage universe encryption at rest
You can enable encryption at rest when creating a universe, and enable and disable encryption at rest on existing universes.
For information on creating universes, see Create universes.
Enable encryption at rest on an existing universe
To enable encryption at rest on an existing universe, navigate to the universe and do the following:
-
New UI Click Settings > Security, and under Encryption at Rest click Edit.
Classic UI Click Actions > More > Edit Security > Encryption at Rest.
-
In the Manage Encryption at Rest dialog, toggle Enable Encryption at Rest for this Universe.
When the encryption is enabled, the Key Management Service Config option appears.
-
Select your KMS configuration from the Key Management Service Config list. The list displays only preconfigured KMS configurations. If you need to create one, see Create a KMS configuration.
-
Click Apply.
Verify encryption at rest on a universe
You can verify that encryption at rest has been successfully configured as follows:
-
Navigate to the universe and select Nodes.
-
On one of the nodes, click Master under the PROCESSES column to open the overview.
-
To the right of Replication Factor, click See full config to open the Current Cluster Config page.
-
Verify that the configuration includes the following
encryption_infosection with the correct values:encryption_info { encryption_enabled: true universe_key_registry_encoded: ".*" key_in_memory: true latest_version_id: ".*" }
If your configuration includes AWS KMS, the following occurs: after the universe has been created with encryption at rest enabled, YugabyteDB Anywhere persists the universe key (because AWS does not persist any CMK-generated data keys themselves) and requests the plaintext of the master key from AWS KMS using the KMS configuration whenever it needs to provide the universe key to the master nodes. For more information, see Create a KMS configuration using AWS KMS.
Disable encryption at rest
Disabling encryption at rest in YugabyteDB Anywhere stops encryption of new data. It does not decrypt data already on disk; data on disk stays encrypted until compaction rewrites it. In addition, a backup taken after that rewrite still requires the KMS configuration to restore, even though the backup data is not encrypted.
To disable encryption at rest for a universe, navigate to the universe and do the following:
-
New UI Click Settings > Security, and under Encryption at Rest click Edit.
Classic UI Click Actions > More > Edit Security > Encryption at Rest.
-
In the Manage Encryption at Rest dialog, toggle Enable Encryption at Rest for this Universe and click Apply.
To verify that encryption at rest is disabled for new data, check the current cluster configuration for each node to see that it contains encryption_enabled: false.
KMS configuration still required
Keep the KMS configuration after compaction has rewritten the universe data in plaintext. Later backups still record the earlier universe keys, so restore still requires that KMS configuration even though the backup data is not encrypted.Back up and restore data from an encrypted at rest universe
When you back up and restore universe data with encryption at rest enabled, YugabyteDB Anywhere requires a KMS configuration to manage backing up and restoring encrypted universe data. Because you might restore data to a different universe that uses a different master key, every encrypted backup includes a metadata file. The file contains the universe keys wrapped by the master key, and the master key metadata needed to unwrap them.
When restoring an encrypted backup to a universe, YugabyteDB Anywhere detects the KMS configuration that can unwrap those universe keys. The KMS configuration must be available in the YugabyteDB Anywhere account.
On restore, YugabyteDB Anywhere unwraps each universe key with that KMS configuration and sends the universe keys to the destination universe. The destination universe adds them to its universe key registry.
Rotate keys
You can rotate the master and universe keys.
Changing the KMS configuration does not generate a new universe key. It re-wraps every universe key that YugabyteDB Anywhere stores for the universe under the new master key. YugabyteDB Anywhere keeps those wrapped copies and records them in backup metadata. The re-wrap happens immediately. The universe key registry on the universe stays encrypted with the latest universe key, and the data on disk stays as it is.
Rotating the universe key encrypts new data with that key. Existing files move to the new universe key when compaction rewrites them.
Note that you can choose to rotate the master key/KMS configuration or rotate the universe key, but you can't do both actions at the same time.
Rotate the master keys
As part of envelope encryption, the universe keys are protected by master keys. The master key resides in the KMS of your choosing and is used to encrypt and decrypt the universe keys as needed.
YugabyteDB Anywhere uses a KMS configuration to house the information about the master key to use in envelope encryption, as well as the credentials to use to access this master key.
You can change KMS configurations, and consequently the master keys used to encrypt the universe key, at any time. To accomplish this, do the following:
-
Create a new KMS configuration with the new master key to use.
-
After the KMS configuration is successfully created, go to the encryption at rest-enabled universe, and do the following:
-
New UI Click Settings > Security, and under Encryption at Rest click Edit.
-
Classic UI Click Actions > More > Edit Security > Encryption at Rest.
-
-
In the Manage Encryption at Rest dialog, choose the new KMS configuration from the Key Management Service Config list.
-
Click Apply to use the new KMS configuration and master key for envelope encryption.
Keep KMS configurations after rotation
Without a KMS configuration, you would no longer be able to decrypt universe keys that were encrypted using the master key in the KMS configuration. Even after a key is rotated out of service, it may still be needed to restore backups that were created while it was active.
You can't delete a KMS configuration while any existing universe has used it. If you delete a universe, keep its KMS configuration for as long as you need to restore that universe's backups.
Rotate the universe keys
Enabling encryption and rotating a universe key works in two steps:
- Add the new universe key ID and key data to all the in-memory state of masters.
- Issue a cluster configuration change to enable encryption with the new universe key.
The cluster configuration change does the following:
- Decrypts the universe key registry with the previous universe key, when encryption is already enabled.
- Adds the new universe key to the registry.
- Updates the cluster configuration with the new latest key ID.
- Encrypts the registry with the new universe key.
Once encryption is enabled with a new universe key, new data is encrypted with this key. Existing files stay under the previous universe key, or remain unencrypted, until compaction rewrites them. There is no indicator of how much data is still under an earlier universe key.
To rotate the universe keys, navigate to the universe and do the following:
-
New UI Click Settings > Security, and under Encryption at Rest click Edit.
Classic UI Click Actions > More > Edit Security > Encryption at Rest.
-
Select Rotate Universe key and click Apply.