Skip to content

OpenBao “Code: 403 permission denied”: policy, path or token

Securitytested on OpenBao v2.7.1

Code 403 with “permission denied” means: the token is valid, but none of its policies allows this operation on this path. OpenBao never tells you which rule is missing – bao token capabilities does.

Symptom

bao kv get -mount=secret -field=db_user webshop/config; echo
bao kv list -mount=secret webshop
bao kv get -mount=secret webshop/admin
bao kv get -mount=secret billing/config
bao kv put -mount=secret webshop/config x=1
webshop
Keys
----
admin
config
Error reading secret/data/webshop/admin: Error making API request.
Code: 403. Errors:
	* permission denied
Error reading secret/data/billing/config: Error making API request.
Code: 403. Errors:
	* permission denied
Error writing data to secret/data/webshop/config: Error making API request.
Code: 403. Errors:
	* permission denied

A token with the policy webshop-read reads webshop/config but fails on webshop/admin, billing/config and on writing.

Diagnosis

Ask OpenBao what the current token may do on the real API paths instead of trying it out.

bao token capabilities secret/data/webshop/config
bao token capabilities secret/data/webshop/admin
bao token capabilities secret/metadata/webshop/

Causes

PolicyThe policy does not cover the path or operation

Read access is not write access. And a rule on secret/data/webshop/config does not apply to webshop/admin or billing/config.

KV v2Wrong path in the policy

With KV v2, values live under secret/data/…, lists and metadata under secret/metadata/…. A policy on secret/webshop/* matches neither.

use-limitThe token is used up

A token with a use limit is revoked after its last use; after that every call returns 403.

U=$(bao token create -field=token -policy=default -use-limit=2)
BAO_TOKEN=$U bao token lookup -format=json | jq .data.num_uses
BAO_TOKEN=$U bao token lookup -format=json | jq .data.num_uses
BAO_TOKEN=$U bao token lookup
1
-1
Code: 403. Errors:

* permission denied

bad tokenParent token revoked

When the parent token is revoked, all children die with it – the message is then bad token. Orphan tokens survive.

bao token revoke $PARENT
bao token lookup $CHILD
Success! Revoked token (if it existed)
Code: 403. Errors:

* bad token

Fix

Add exactly the missing path and operation to the policy (with data/ or metadata/ for KV v2), then check again with bao token capabilities. For used-up or revoked tokens, get a new token.

Don't: Do not widen the policy to path "secret/*" or use root just to make the error go away – least privilege is the point of policies.

▶
Break it yourself and find it – free
OpenBao hands-on, Day 2: tokens, TTLs and policies – with least privilege, use limits and the token hierarchy.
Go to day 2 →

FAQ

Why can I read webshop/config but not list it?

With KV v2, listing goes through secret/metadata/…; the policy needs capabilities = ["list"] on the metadata path.

How do I see which policies my token has?

bao token lookup shows policies; bao token capabilities <path> shows the effective rights on a path.

Related error patterns

More