Bug 1983931 - [RFE] VAULT_BACKEND parameter should be added to the csi-kms-connection-details
Summary: [RFE] VAULT_BACKEND parameter should be added to the csi-kms-connection-details
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenShift Container Storage
Classification: Red Hat Storage
Component: csi-driver
Version: 4.7
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: OCS 4.7.3
Assignee: Niels de Vos
QA Contact: Rachael
URL:
Whiteboard:
Depends On: 1984334
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-07-20 08:26 UTC by Eran Tamir
Modified: 2022-06-24 08:46 UTC (History)
11 users (show)

Fixed In Version: v4.7.3-243.ci
Doc Type: Enhancement
Doc Text:
.Improved backend Vault parameter configuration This feature allows configuring of the `VAULT_BACKEND` parameter for selecting the type of backend used by Hashicorp Vault. The autodetection of the backend used by Hashicorp Vault is not always working as expected. In case, if a non-common configuration is used, the automatically detected configuration parameter might be set incorrectly. By allowing users to configure the `VAULT_BACKEND` (or `vaultBackend`) parameter, non-common configurations can now be forced to use a particular type of backend.
Clone Of:
: 1984333 1984334 (view as bug list)
Environment:
Last Closed: 2021-08-11 13:59:14 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github ceph ceph-csi pull 2307 0 None closed util: allow configuring VAULT_BACKEND for Vault connection 2021-07-29 05:04:40 UTC
Github openshift ceph-csi pull 65 0 None open BUG 1983931: util: allow configuring VAULT_BACKEND for Vault connection 2021-07-29 09:38:29 UTC
Red Hat Product Errata RHBA-2021:3135 0 None None None 2021-08-11 13:59:26 UTC

Description Eran Tamir 2021-07-20 08:26:50 UTC
Description of problem:

Currently, VAULT_BACKEND parameter can't be specified in csi-kms-connection-details and it's needed for a v2 configuration

Version-Release number of selected component (if applicable):

4.7.2

Comment 3 Mudit Agarwal 2021-07-21 06:02:42 UTC
Eran/Niels, are we tagetting this for 4.7.4 or 4.7.3?

Comment 4 Niels de Vos 2021-07-21 06:33:42 UTC
From an engineering point of view, we can include this in 4.7.3. Currently a PR is available and waiting for the opening of the 4.7.4 merge window.

The customer that reported the problem, can apply a temporary workaround if needed.

If other stakeholders are supporting to include this in 4.7.3, we can include the change in the next build for testing.

Comment 5 Mudit Agarwal 2021-07-21 08:47:01 UTC
Eran clarified that this is needed in 4.8.1 also, so we need to target this to 4.7.4
Will create a 4.8.1 clone too

Comment 12 Niels de Vos 2021-08-06 11:55:20 UTC
The only valid values for `VAULT_BACKEND` are `kv` and `kv-v2`. If the option is not set, or has an other value, libopenstorage/secrets will try to do auto-detection. Only when auto-detection fails (no access to `sys/mounts`), connecting to the Vault service will fail.

`kv-v2` formatting of the URLs is different than the format for `kv` (version 1)`:

- kv: no support for metadata, no need to separate data
- kv-v2: supports metadata, different URLs for data and metadata

When using a `kv` (version 1) storage, the secret store does not get a `data/` part in the name of the key. When using `kv-v2`, the name of the key will get an additional `data/` section in the path.

The following configuration has now been tested, and it should show that the setting of `VAULT_BACKEND` is used:

- configure a `vaulttokens` KMS
- create a `secret/` store, with `kv -version=1`
- create a policy for a tenant, with only access to the `secret/` path, not `sys/mounts`
- create a new token (with -orphan and -policy=...)
- configure the token in the Secret ceph-csi-kms-token in the Tenants namespace

When not setting `VAULT_BACKEND` in the KMS configuration, the provisioning fails with errors like:

--- %< ---
E0806 11:45:20.005724       1 utils.go:136] ID: 138 Req-ID: pvc-f6c890dc-dce3-47cb-8c24-8b6d79c2373b GRPC error: rpc error: code = InvalidArgument desc = invalid encryption kms configuration: failed creating new Vault Secrets: Error making API request.

URL: GET http://vault.infra.svc.cluster.local:8200/v1/sys/mounts
Code: 403. Errors:

* 1 error occurred:
	* permission denied

--- %< ---


Setting `VAULT_BACKEND` to "invalid" causes the same error (auto-detection fails to access "sys/mounts"):

--- %< ---
E0806 11:47:24.817460       1 utils.go:136] ID: 148 Req-ID: pvc-9e70ce37-6b00-4032-a8e4-835d833a372b GRPC error: rpc error: code = InvalidArgument desc = invalid encryption kms configuration: failed creating new Vault Secrets: Error making API request.

URL: GET http://vault.infra.svc.cluster.local:8200/v1/sys/mounts
Code: 403. Errors:

* 1 error occurred:
	* permission denied

--- %< ---


Setting `VAULT_BACKEND` to "kv" (version 1) and creating a PVC and Pod results in a key created in Vault:

--- %< ---
/ $ vault kv list secret/
Keys
----
0001-0011-openshift-storage-0000000000000001-48698aff-f6ac-11eb-9b5d-0a580a81025a
/ $ vault kv get secret/0001-0011-openshift-storage-0000000000000001-48698aff-f6ac-11eb-9b5d-0a580a81025a
==== Data ====
Key     Value
---     -----
data    map[passphrase:QD9Tph39Hl1LYTUJg9Yoc-SwcoY=]
--- %< ---


Setting `VAULT_BACKEND` to "kv-v2" (version 2) and creating a PVC and Pod results in a key created in Vault, but added "data/" path (required for version 2):

--- %< ---
/ $ vault kv list secret/
Keys
----
data/
/ $ vault kv list secret/data
Keys
----
0001-0011-openshift-storage-0000000000000001-cf18f1a7-f6ac-11eb-9b5d-0a580a81025a
/ $ vault kv get secret/data/0001-0011-openshift-storage-0000000000000001-cf18f1a7-f6ac-11eb-9b5d-0a580a81025a
==== Data ====
Key     Value
---     -----
data    map[data:map[passphrase:fqHbBr7LRQVYIXvO9L0mtO8eb9M=]]
--- %< ---


According to my understanding, this confirms that the `VAULT_BACKEND` configuration option in the csi-kms-connection-details ConfigMap has an effect on how the encryption passphrase is stored in Vault.

Comment 13 Niels de Vos 2021-08-06 12:36:14 UTC
Also note that validating `kv` (version 1) and `kv-v2` (version 2) can be done by using policies that are restrictive:

For `kv`:
 - allow writing to `secret/*`, this will also work when configuring with `kv-v2` as it uses sub-paths which are allowed automatically
 - maybe it is possible to deny access to `secret/data/*`, in which case using `kv-v2` should fail

For `kv-v2`:
 - allow writing to only `secret/data/*` and secret/metadata/*`, this will prevent using `kv` as it tries to use `secret/*`

Comment 14 Mudit Agarwal 2021-08-06 12:49:35 UTC
Moving it back to ON_QA based on the above comments.

Comment 32 errata-xmlrpc 2021-08-11 13:59:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Red Hat OpenShift Container Storage 4.7.3 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:3135


Note You need to log in before you can comment on or make changes to this bug.