Skip to content

External Secrets SecretSyncedError: permission denied with dataFrom.find

Securitytested on OpenBao 2.7 und External Secrets Operator 2.x auf kind

An ExternalSecret with dataFrom.find stays in SecretSyncedError while another one using extract on the same path is green. find has to list first – and listing in KV v2 goes through secret/metadata/, not secret/data/.

Symptom

kubectl apply -f es-extract.yaml -f es-find.yaml
kubectl -n shop get es shop-api-all shop-find
externalsecret.external-secrets.io/shop-api-all created
externalsecret.external-secrets.io/shop-find created
NAME           STORETYPE     STORE     REFRESH INTERVAL   STATUS              READY ...
shop-api-all   SecretStore   openbao   1m                 SecretSynced        True  ...
shop-find      SecretStore   openbao   1m                 SecretSyncedError   False ...

Both ExternalSecrets use the same SecretStore; only the one with find fails.

Diagnosis

The ExternalSecret's event names the exact URL OpenBao rejected.

kubectl -n shop get events --field-selector involvedObject.name=shop-find \
  -o jsonpath='{.items[0].message}'
error processing spec.dataFrom[0].find, err: error getting all secrets: cannot read
secret data from Vault: Error making API request.

URL: GET http://openbao.openbao.svc:8200/v1/secret/metadata/shop?list=true
Code: 403. Errors:

* 1 error occurred:
	* permission denied

Causes

findfind needs list on secret/metadata/

extract reads a known path under secret/data/. find first has to list the paths – which needs list on secret/metadata/.

Least privilegeThe policy only allows read

The policy shop-api-read allows read on secret/data/shop/*. That is right – find needs a targeted extra policy.

path "secret/metadata/shop/*" {
  capabilities = ["list", "read"]
}
path "secret/metadata/shop" {
  capabilities = ["list"]
}

Fix

Write the extra policy, attach it to the Kubernetes role and trigger a sync.
bao policy write shop-api-list shop-api-list.hcl
bao write auth/kubernetes/role/shop-api token_policies=shop-api-read,shop-api-list
bao read -format=json auth/kubernetes/role/shop-api \
  | jq -c '.data | {audience, token_policies}'
kubectl -n shop annotate es shop-find force-sync="$(date +%s)" --overwrite
Success! Uploaded policy: shop-api-list
Success! Data written to: auth/kubernetes/role/shop-api
{"audience":"openbao","token_policies":["shop-api-read","shop-api-list"]}
externalsecret.external-secrets.io/shop-find annotated

Don't: Do not just put path "secret/*" with all capabilities into the policy – find only gets list on exactly the metadata path.

▶
Break it yourself and find it – free
OpenBao secrets in Kubernetes and CI/CD, Day 3: External Secrets Operator – SecretStore, ExternalSecret, extract and find.
Go to day 3 →

FAQ

Is extract or find better?

For environment variables usually extract. find returns one key per path with the whole secret as JSON.

Does bao write on the role change the audience?

No, bao write on an existing role only changes the fields you pass.

Related error patterns

More