Skip to content

OpenBao Kubernetes auth: “service account name not authorized”

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

Kubernetes auth in OpenBao checks at login whether the token's service account and namespace match the role. A SecretStore in a foreign namespace using another team's role is rejected here – and that is intended.

Symptom

kubectl -n fremd get ss openbao
NAME      AGE   STATUS                  CAPABILITIES   READY
openbao   3s    InvalidProviderConfig                  False

A SecretStore in the namespace fremd (“foreign”) uses the role shop-api.

Diagnosis

The SecretStore's event contains OpenBao's answer.

kubectl -n fremd get events --field-selector involvedObject.kind=SecretStore \
  -o jsonpath='{.items[0].message}'
unable to log in to auth method: unable to log in with Kubernetes auth: Error making
API request.

URL: PUT http://openbao.openbao.svc:8200/v1/auth/kubernetes/login
Code: 403. Errors:

* service account name not authorized

Causes

BindingThe role binds a different SA or namespace

The role shop-api binds only the service account shop-api in the namespace shop. Every other token is rejected.

SecretStoreA SecretStore can only use SAs from its namespace

A namespaced SecretStore may only use service accounts from its own namespace; serviceAccountRef.namespace is ignored.

Fix

Create one OpenBao role per namespace with a matching binding (bound_service_account_names, bound_service_account_namespaces) and policy, and use that role with the namespace's own service account in the SecretStore.

Don't: Do not widen the role's binding to * – then every service account in the cluster can read the team's secrets.

▶
Break it yourself and find it – free
OpenBao secrets in Kubernetes and CI/CD, Day 4: advanced ESO – templates, multi-tenancy with one SecretStore per namespace, PushSecret.
Go to day 4 →

FAQ

Why doesn't OpenBao give a more precise message?

So an attacker does not learn which combination of service account and namespace would be allowed.

What about ClusterSecretStore?

A ClusterSecretStore may reference service accounts from other namespaces – which is exactly why it belongs under the platform team's control.

Related error patterns

More