[MDEV-29241] Hashicorp Plugin: Provide Key rotation Created: 2022-08-03 Updated: 2023-11-28 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Encryption, Plugin - Hashicorp Key Management |
| Affects Version/s: | 10.9.1 |
| Fix Version/s: | 10.11 |
| Type: | Bug | Priority: | Major |
| Reporter: | Simon Stier | Assignee: | Julius Goryavsky |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The Hashicorp Plugin seems to recognise new encryption keys in vault - but does not rotate them. Reproduce by:
CURRENT_KEY_VERSION -> 2 there seems to be no possibility to re-encrypt the tables. |
| Comments |
| Comment by Sergei Golubchik [ 2023-01-06 ] |
|
sysprg, why is it not possible to re-encrypt the table? As far as I can see from the plugin code, it caches the latest key version, so it might immediately notice that the key was rotated, but the cache expires in cache_version_timeout milliseconds (which is 0 by default, btw). Why the server doesn't notice that the key was rotated in the vault? |
| Comment by Sergei Golubchik [ 2023-02-22 ] |
|
Ok, so the problem is not that it's "not possible to re-encrypt the table". The issue is that hashicorp_key_management plugin caches replies from Hashicorp Vault and these values never expire. By default the caching is enabled, but cache_version_timeout is zero. The workaround for the user is to set cache_version_timeout. The fix for MariaDB is to set the default to some meaningful value. |
| Comment by Sebastian [ 2023-03-13 ] |
|
I'm also interested in the key rotation mechanism of this plugin. The official documentation is not clear if this plugin supports it or not and I'm trying to find it out manually, but an official statement and an example would be highly appreciated. |
| Comment by Sergei Golubchik [ 2023-03-13 ] |
|
As far as I understand, the plugin supports key rotation just fine. But if you have enabled key caching (so that the plugin wouldn't need to query Hashicorp Vault all the time) and you have disabled key expiration timeout, then the key will stay forever in the cache and the plugin will not notice that the key was rotated in the Hashicorp Vault until you restart the server. Key caching is generally a good idea, an infinite timeout is not. |
| Comment by Sebastian [ 2023-03-14 ] |
|
Indeed I see that when I write a new version of the enc key in Vault, MariaDB sees it if I select data from information_schema.INNODB_TABLESPACES_ENCRYPTION (i.e. Current Key Version corresponds to the latest version in Vault, while Min Key Version is the older one used in encryption). But how do I trigger MariaDB to encrypt the tables using the newer version? |
| Comment by Sergei Golubchik [ 2023-03-14 ] |
|
It's beyond the hashicorp plugin. Generally it should be explained here: https://mariadb.com/kb/en/innodb-background-encryption-threads/ You'll need innodb_encryption_threads (like the original reporter did) and innodb_encryption_rotate_key_age (which is 1 by default, so, likely, ok). We're now trying to repeat this issue |