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-podsgrants the Role indefaultto userjaneand thedefaultaccount fromkube-system. - After: Removing the account leaves only
janein this binding. Check the account’s other bindings for any remaining access.