hashicorp / vault

A tool for secrets management, encryption as a service, and privileged access management
https://www.vaultproject.io/
Other
30.98k stars 4.19k forks source link

Vault plugin deregister always success & never fails #9534

Closed aphorise closed 2 years ago

aphorise commented 4 years ago

Vault CLI steps for plugin deregister always returns a success and what's more compatibility options provided for older versions of Vault that do not require plugin-type to be passed are also impacting deregister especially since requesting a register without a plugin-type is accepted as valid yet similarly attempting a deregister without a plugin-type passed results in the same behaviour and without any complaints or warnings.

There's presently no way to determine when a plugin has been successfully deregistered (without an additional listing requests and deductive comparisons)

To Reproduce

# // register a plugin - eg:
# vault plugin register -sha256=… venafi-pki-backend ;  # // no type required.

# // --------------------------------------------------------------------------
# // WITHOUT TYPE - no errors or complaints:
vault plugin deregister venafi-pki-backend
  # Success! Deregistered plugin (if it was registered): venafi-pki-backend

curl -X DELETE -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" https://192.168.178.253:8200/v1/sys/plugins/catalog/venafi-pki-backend
  # {"request_id":"a2845804-1356-3e5a-ae07-a563287b3458","lease_id":"","renewable":false,"lease_duration":0,"data":null,"wrap_info":null,"warnings":["Deprecated API endpoint, cannot deregister plugin from catalog for \"venafi-pki-backend\""],"auth":null}

vault plugin deregister does-not-exist
  # Success! Deregistered plugin (if it was registered): does-not-exist

curl -v -X DELETE -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" https://192.168.178.253:8200/v1/sys/plugins/catalog/secret/does-not-exist
  # // ...
  # < HTTP/2 204
  # < cache-control: no-store
  # < content-type: application/json
  # < date: Mon, 20 Jul 2020 18:40:31 GMT
  # <
  # * Connection #0 to host 192.168.178.253 left intact

# // --------------------------------------------------------------------------
# // WITH TYPE:
vault plugin deregister secret venafi-pki-backend
  # Success! Deregistered plugin (if it was registered): venafi-pki-backend

# //^ WORKS as `vault plugin list` can confirm since 'secret' plugin-type is set.

# // BUT then repeating CLI or API you get:
vault plugin deregister secret venafi-pki-backend
  # Success! Deregistered plugin (if it was registered): venafi-pki-backend

Expected behavior Provide contextual responses which express a HTTP-2xx / 0 exit code only when an actually deregister has been successfully performed and also provide any error messages or warnings for plugin-type that must be set for all newer and current Vault versions.

Environment:

Vault server configuration file(s):

cluster_name = "primary"
api_addr = "https://192.168.178.253:8200"
cluster_addr = "https://192.168.178.253:8201"

listener "tcp" {
  address       = "0.0.0.0:8200"
  cluster_address  = "192.168.178.253:8201"
  tls_cert_file = "/home/vagrant/vault1_certificate.crt"
  tls_key_file = "/home/vagrant/vault1_private.key"
}

storage "raft" {
        path            = "/vault/data"
        node_id         = "vault1"
}

disable_mlock = true
log_level = "trace"
ui = true
raw_storage_endpoint = true
plugin_directory = "/etc/vault.d/plugins"
aphorise commented 2 years ago

I realise that a deregister may take longer and require additional checks by way of a restart to properly confirm - making this request not as effective even if it were possible.

There are other areas of Vault (like raft join) where a success if returned wherever an API call is correctly made but the connection can not be left pending till it's confirmed (reload + list catalogue).

Closing - I've change my mind on this issue and I understand it in a different light.