Skip to content

Commit

Permalink
PSMDB-1283 Added KMIP key state polling (#896) (#911)
Browse files Browse the repository at this point in the history
PSMDB-1283 Added KMIP key state polling

modified:   docs/kmip.md
  • Loading branch information
nastena1606 authored Sep 23, 2024
1 parent 69e90ff commit d04a4cd
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 14 deletions.
Binary file added docs/_images/kmip-state-polling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 11 additions & 6 deletions docs/data-at-rest-encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@ Data at rest encryption for the WiredTiger storage engine in MongoDB was
introduced in MongoDB Enterprise version 3.2 to ensure that encrypted data
files can be decrypted and read by parties with the decryption key.

!!! important

You can only enable data at rest encryption and provide all encryption settings on an empty database, when you start the `mongod` instance for the first time. You cannot enable or disable encryption while the Percona Server for MongoDB server is already running and / or has some data. Nor can you change the effective encryption mode by simply restarting the server. Every time you restart the server, the encryption settings must be the same.

## Differences from upstream

The data encryption at rest in Percona Server for MongoDB is introduced in version 3.6 to be compatible with data encryption at rest interface in MongoDB. In the current release of Percona Server for MongoDB, the data encryption at rest does not include support for Amazon AWS key management service. Instead, Percona Server for MongoDB is [integrated with HashiCorp Vault](vault.md).

Starting with release 6.0.2-1, Percona Server for MongoDB supports the secure transfer of keys using [Key Management Interoperability Protocol (KMIP)](kmip.md). This allows users to store encryption keys in their favorite KMIP-compatible key manager when they set up encryption at rest.

Two types of keys are used for data at rest encryption:

## Workflow

!!! important

You can only enable data at rest encryption and provide all encryption settings on an empty database, when you start the mongod instance for the first time. You cannot enable or disable encryption while the Percona Server for MongoDB server is already running and / or has some data. Nor can you change the effective encryption mode by simply restarting the server. Every time you restart the server, the encryption settings must be the same.

Each node of Percona Server for MongoDB generates a random, individual key for every database. It encrypts every database with an individual key and puts those keys into the special, so-called key database. Then each node of Percona Server for MongoDB randomly generates a unique master encryption key and encrypts the key database with this key.

Thus, two types of keys are used for data at rest encryption:

* Database keys to encrypt data. They are stored internally, near the data that they encrypt.

* The master key to encrypt database keys. It is kept separately from the data and database keys and requires external management.

To manage the master key, use one of the supported key management options:
To manage the master encryption key, use one of the supported key management options:

* Integration with an external key server (recommended). Percona Server for MongoDB is [integrated with HashiCorp Vault](vault.md) for this purpose and supports the secure transfer of keys using [Key Management Interoperability Protocol (KMIP)](kmip.md).

Expand Down
2 changes: 2 additions & 0 deletions docs/install/minor-upgrade.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Minor upgrade of Percona Server for MongoDB

If you are using data-at-rest-encryption with KMIP server, check the [upgrade considerations](../kmip.md#upgrade-considerations)

To upgrade Percona Server for MongoDB to the latest version, follow these steps:


Expand Down
8 changes: 6 additions & 2 deletions docs/install/upgrade-from-60.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Upgrading from Percona Server for MongoDB 6.0 to 7.0

To upgrade Percona Server for MongoDB to version 7.0, you must be running version
## Considerations

1.To upgrade Percona Server for MongoDB to version 7.0, you must be running version
6.0. Upgrades from earlier versions are not supported.

Before upgrading your production Percona Server for MongoDB deployments, test all your applications
2. Before upgrading your production Percona Server for MongoDB deployments, test all your applications
in a testing environment to make sure they are compatible with the new version.
For more information, see [Compatibility Changes in MongoDB 7.0](https://www.mongodb.com/docs/v7.0/release-notes/7.0-compatibility/)

3. If you are using data-at-rest-encryption with KMIP server, check the [upgrade considerations](../kmip.md#upgrade-considerations)

We recommend to upgrade Percona Server for MongoDB from official Percona repositories using [`percona-release` repository management tool](https://docs.percona.com/percona-software-repositories/index.html) and
the corresponding package manager for your system.

Expand Down
57 changes: 54 additions & 3 deletions docs/kmip.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,46 @@ KMIP enables the communication between key management systems and the database s

* Streamlines encryption key management
* Eliminates redundant key management processes
* Reduces the mean time to resolve (MTTR) compromised encryption key incidents via [key state polling](#key-state-polling)

???+ admonition "Version changes"

The following table lists the changes in the KMIP implementation in Percona Server for MongoDB and the versions that introduced those changes:

|Version | Description |
|----------------|-------------|
| [7.0.14-8](release_notes/7.0.14-8.md)| [Key state polling](#key-state-polling).|


## Support for multiple KMIP servers

You can specify multiple KMIP servers for failover. On startup, Percona Server for MongoDB connects to the servers in the order listed and selects the one with which the connection is successful.

## Optional key identifier

The `kmipKeyIdentifier` option is optional and when left blank, the database server creates a key on the KMIP server and uses that for encryption. When you specify the identifier, the key with such an ID must exist on the key storage.


## Key rotation

Percona Server for MongoDB supports the [master key rotation](https://www.mongodb.com/docs/manual/tutorial/rotate-encryption-key/#kmip-master-key-rotation). This enables users to comply with data security regulations when using KMIP.

## Key state polling

When a Percona Server for MongoDB node generates a new master encryption key, it registers the key on the KMIP server with the `Pre-Active` state. Starting with version 7.0.14-8, Percona Server for MongoDB automatically activates the master encryption key and periodically checks (polls) its state. If a master encryption key for a node is not in the `Active` state, the node reports an error and shuts down. This process helps security engineers identify the nodes that require out-of-schedule master key rotation.

Key state polling is enabled by default and is regulated by these configuration file options: `kmip.activateKeys` and `kmip.keyStatePollingSeconds`.

The following diagram illustrates the master key lifecycle with key state polling:

![image](_images/kmip-state-polling.png)

The master key state polling functionality is particularly useful in cluster deployments with hundreds of nodes. If some master keys are compromised, security engineers change their state from `Active` so that the nodes encrypted with these keys identify themselves. This approach allows the security engineers to rotate master keys only on the affected nodes instead of the entire cluster, thus reducing the mean time to resolve (MTTR) compromised encryption key incidents.

!!! admonition "See also"

Percona Blog: [Improve the Security of a Percona Server for MongoDB Deployment with KMIP Key State Polling](https://www.percona.com/blog/improve-the-security-of-a-percona-server-for-mongodb-deployment-with-kmip-key-state-polling/?utm_source=employee&utm_medium=share&utm_campaign=advocacy) by Konstantin Trushin.

## KMIP parameters

| Configuration file | {{ optionlink('security.kmip.serverName') }}|
Expand Down Expand Up @@ -67,10 +101,18 @@ The `kmipKeyIdentifier` option is optional and when left blank, the database ser
| **Command line** | kmipConnectTimeoutMS |
| **Type** | int |
| **Description** | The time to wait for the response from the KMIP server. Min value: 1000. Default: 5000. <br><br>If the `connectRetries` setting is specified, the `mongod` waits up to the value specified with `connectTimeoutMS` for each retry.|

## Key rotation

Percona Server for MongoDB supports the [master key rotation](https://www.mongodb.com/docs/manual/tutorial/rotate-encryption-key/#kmip-master-key-rotation). This enables users to comply with data security regulations when using KMIP.
| Configuration file | {{optionlink('security.kmip.activateKeys')}}|
|-------------------- | --------------------|
| **Command line** | `kmipActivateKeys`|
| **Type** | boolean|
| **Description** | When enabled, Percona Server for MongoDB activates a newly created master encryption key or verifies that the existing master key is in the Active state at startup. It also initiates the key state polling. Enabled by default. Available starting with version 7.0.14-8.|

| Configuration file | {{optionlink('security.kmip.keyStatePollingSeconds')}}|
|-------------------- | --------------------|
| **Command line** | `kmipKeyStatePollingSeconds`|
| **Type** | int|
| **Description** | The period in seconds to check the state of the master encryption key. Default: 900. If the master encryption key is not in the Active state, the node logs the error and shuts down. Available starting with version 7.0.14-8.|

## Configuration

Expand All @@ -82,6 +124,7 @@ To enable data-at-rest encryption in Percona Server for MongoDB using KMIP, the

=== "Configuration file"


Edit the `/etc/mongod.conf` configuration file as follows:

```yaml
Expand All @@ -108,3 +151,11 @@ To enable data-at-rest encryption in Percona Server for MongoDB using KMIP, the
--kmipKeyIdentifier <kmip_identifier>
```


## Upgrade considerations

### To version 7.0.14-8 and higher

Percona Server for MongoDB 7.0.14-8 and subsequent versions tolerate already existing `Pre-Active` master keys as follows: if at startup Percona Server for MongoDB detects that the data directory is encrypted with an existing master key in the `Pre-Active` state, it logs a warning and continues to operate as usual. In that case, Percona Server for MongoDB does not do periodic key state polling regardless the value specified for the [`kmipKeyStatePollingSeconds`](#security-kmip-keystatepollingseconds) option. [Read more about key state polling](#key-state-polling).

We recommend to either rotate a master encryption key or manually change the existing key to the Active state. You can also explicitly set the [`security.kmip.activateKeys`](#security-kmip-activatekeys) configuration file option to ensure that only the active keys are used. This one-time operation smooths the major upgrade flow.
4 changes: 2 additions & 2 deletions mkdocs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ markdown_extensions:
pymdownx.details: {}
pymdownx.mark: {}
pymdownx.smartsymbols: {}
pymdownx.tabbed:
{alternate_style: true}
pymdownx.tabbed: {}
# {alternate_style: true}
pymdownx.tilde: {}
pymdownx.superfences:
custom_fences:
Expand Down
11 changes: 10 additions & 1 deletion mkdocs-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ copyright: Percona LLC, &#169; 2024
markdown_extensions:
pymdownx.tabbed: {}
admonition: {}
pymdownx.superfences: {}


extra_css:
- https://unicons.iconscout.com/release/v3.0.3/css/line.css
- https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css
- css/percona.css
- css/nocopy.css
- css/extra.css
- css/mongodb.css
- css/landing.css

0 comments on commit d04a4cd

Please sign in to comment.