RoleBinding targets a default ServiceAccount

Binding roles to a default ServiceAccount can grant the same permissions to unintended workloads.

Description

An RBAC grant to a default ServiceAccount can reach any Pod in that account’s namespace that omits its own account name. A RoleBinding grants access in the binding’s namespace. A ClusterRoleBinding grants access cluster-wide.

Potential impact

New Pods can inherit the grant. Requests by workloads using the same account can be hard to distinguish in audit logs.

Remediation

Check the name and namespace of each kind: ServiceAccount subject. Move workloads that need API access to dedicated accounts, remove unnecessary grants from the default account, and verify both identities’ effective permissions.

Examples

The pod-reader Role must exist in the default namespace.

Before

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: default
subjects:
  - kind: User
    name: jane
    apiGroup: rbac.authorization.k8s.io
  - kind: ServiceAccount
    name: default
    namespace: kube-system
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

After

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: default
subjects:
  - kind: User
    name: jane
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: pod-reader
  apiGroup: rbac.authorization.k8s.io

Explanation:

  • Before: read-pods grants the Role in default to user jane and the default account from kube-system.
  • After: Removing the account leaves only jane in this binding. Check the account’s other bindings for any remaining access.

References