Skip to main content

More Info:

Verifies no ServiceAccount is bound to the cluster-admin ClusterRole. Such a binding hands full cluster control to any workload using that account.

Risk Level

Critical

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. List all ClusterRoleBindings that bind cluster-admin to any ServiceAccount (run on any machine with kubectl access):
  2. For each violating ServiceAccount identified in step 1, review what permissions it actually needs by inspecting the workloads that use it (run on any machine with kubectl access). Replace VIOLATING_NAMESPACE and VIOLATING_SA with actual names:
  3. Define a narrowly-scoped Role or ClusterRole that grants only the minimal verbs/resources required by those workloads (run on any machine with kubectl access). Example template to save as minimal-role.yaml and edit for correct namespace, apiGroups, resources, and verbs:
    Apply it:
  4. Bind the violating ServiceAccount to the new narrowly-scoped Role or ClusterRole (run on any machine with kubectl access). Example for a namespaced Role:
  5. After confirming that workloads still function with the new, reduced privileges, remove the ClusterRoleBinding that granted cluster-admin to that ServiceAccount (run on any machine with kubectl access). Replace CLUSTERROLEBINDING_NAME with the name from step 1:
  6. Verification (run on any machine with kubectl access): confirm that no ServiceAccount is bound to cluster-admin and that the check now reports compliance:
On any machine with kubectl access:
  1. Identify violating ClusterRoleBindings
Note the name= of each violating ClusterRoleBinding.
  1. (Optional but recommended) Create a narrowly-scoped Role/ClusterRole and binding
    Adapt the following to the actual verbs and resources the workload requires.
Example namespaced Role and RoleBinding for a ServiceAccount my-sa in namespace my-namespace:
Apply it:
For cluster-scoped access, use ClusterRole and ClusterRoleBinding instead of Role/RoleBinding.
  1. Delete ClusterRoleBindings that bind ServiceAccounts to cluster-admin
For each violating binding name (replace BINDING_NAME with the actual name):
You can delete multiple at once:
  1. Verification
Run the audit command again and confirm it returns only is_compliant=true: