vault --version: Vault v1.9.2
I have a policy file created, with few capabilities, especially delete:
# cat ~/.my_policy.hcl
path "secret/*" {
capabilities = ["create", "read", "update", "list", "delete"]
}
Created new policy using this file and I can now see the policy in the list operation:
# vault policy write my-policy ~/.my_policy.hcl
Success! Uploaded policy: my-policy
# vault policy list
default
my-policy
root
# vault policy read my-policy
path "secret/*" {
capabilities = ["create", "read", "update", "list", "delete"]
}
Created a new token using the above policy (so I can use it in CURL -X DELETE operation):
# vault token create -policy=my-policy; # using -no-default-policy didn't help with curl output
Key Value
--- -----
token s.27T3cNB4PrHll9byc6tppHw9
token_accessor C6mu2crjudeHVy5jijcFkF4K
token_duration 768h
token_renewable true
token_policies ["default" "my-policy"]
identity_policies []
policies ["default" "my-policy"]
But, when I'm looking at the capabilities of the token at the folder path defined in my policy file, it shows a different policy root and shows deny
# vault token lookup s.27T3cNB4PrHll9byc6tppHw9
Key Value
--- -----
accessor C6mu2crjudeHVy5jijcFkF4K
creation_time 1678469133
creation_ttl 768h
display_name token
entity_id n/a
expire_time 2023-04-11T17:25:33.405537533Z
explicit_max_ttl 0s
id s.27T3cNB4PrHll9byc6tppHw9
issue_time 2023-03-10T17:25:33.405548806Z
meta <nil>
num_uses 0
orphan false
path auth/token/create
policies [default my-policy]
renewable true
ttl 767h48m50s
type service
# These should have shown my-policy than root
# This should have shown all policies having some capability at this path
# ----
# vault token capabilities s.27T3cNB4PrHll9byc6tppHw9
root
# vault token capabilities secrets/*
root
# vault token capabilities secrets
root
# This should not give me deny when this token has the necessary policy 'my-policy' with 'delete' capability
# ----
# vault token capabilities s.27T3cNB4PrHll9byc6tppHw9 secrets/*
deny
# vault token capabilities s.27T3cNB4PrHll9byc6tppHw9 secrets
deny
Error mesg:
# curl -k -s -X GET -H 'X-Vault-Token: s.27T3cNB4PrHll9byc6tppHw9' https://vaultserver:8200/v1/secret/data/testA1/test
{"errors":["permission denied"]}
# curl -k -s -X DELETE -H 'X-Vault-Token: s.27T3cNB4PrHll9byc6tppHw9' https://vaultserver:8200/v1/secret/data/testA1/test
{"errors":["permission denied"]}
When querying vault directly using cmd line, to see secret/testA1/test secret, it spits (PS: vault API call requires/puts /data/ in the secret path):
{
"ttl": "90d",
"username": "test",
"value": "KneelB4Me!YaRight"
}
Setting: the following before any of these commands has no effect.
VAULT_ADDR=https://vaultserver:8200
VAULT_NAMESPACE=admin
When creating token with -no-default-token, token capabilties at secret/* shows valid capabilities (instead of deny), still curl command fails.