Skip to main content

More Info:

Wildcards (*) in verbs, resources, or apiGroups grant broad, unintended permissions. Replacing them with explicit values enforces least privilege.

Risk Level

Critical

Address

Security

Compliance Standards

  • CIS AKS

Triage and Remediation

Remediation

Manual Steps

  1. List all ClusterRoles that use wildcards
    • Run on: any machine with kubectl access
    Save this list; these are the ClusterRoles to review.
  2. Inspect each flagged ClusterRole’s rules and usage
    • Run on: any machine with kubectl access
      For each <clusterrole> from step 1:
    Use this to understand who/what is using the ClusterRole and in what context.
  3. Determine the minimal required verbs, resources, and apiGroups
    • Review the consuming subjects (users, groups, service accounts) and their applications’ actual needs:
      • Check application docs/helm charts/manifest comments for required permissions.
      • If necessary, enable/consult audit logs (if available) to see which API calls are made by these identities.
  4. Edit the ClusterRole to replace wildcards with explicit values
    • Run on: any machine with kubectl access
      For each ClusterRole confirmed as overly broad:
    In the editor, for each rules entry:
    • Replace verbs: ["*"] with only the required verbs (e.g. ["get","list","watch"]).
    • Replace resources: ["*"] with only the needed resources (e.g. ["pods","configmaps"]).
    • Replace apiGroups: ["*"] with only the necessary groups (e.g. ["","apps"]).
      Save and exit to apply.
  5. If a wildcard is truly required, document and isolate it
    • For any ClusterRole where * cannot be safely removed (e.g., break-glass admin):
      • Keep the wildcard but ensure it is bound only to tightly controlled identities (e.g., specific admin group).
      • Optionally, create a new, narrower ClusterRole for regular use and update bindings to use that instead:
  6. Verify no unintended wildcards remain
    • Run on: any machine with kubectl access
    Confirm that:
    • Only ClusterRoles with a conscious, documented justification still appear.
    • All others have been corrected to use explicit verbs, resources, and apiGroups.
Run these commands from any machine with kubectl access.

1. List all ClusterRoles that contain any wildcard

Problem indication: Any name in the output is a ClusterRole that uses at least one * in verbs, resources, or apiGroups and needs manual review.If you don’t have jq, use:
Problem indication: Lines under rules: where verbs:, resources:, or apiGroups: include - "*" are suspect and must be reviewed.

2. Inspect a specific ClusterRole in detail

For any ClusterRole name identified above, review it:
Problem indication inside rules::
  • verbs:
  • resources:
  • apiGroups:
Any of these (or combinations) mean broad, non–least-privilege permissions that must be assessed manually for necessity and risk.

3. Focus on ClusterRoles actually bound to users/service accounts

List all ClusterRoleBindings and the ClusterRoles they reference:
Then intersect with the wildcarded ClusterRoles:
Problem indication: Any ClusterRole name in the final comm output both uses wildcards and is bound, meaning it actively grants broad permissions and should be prioritized for review.

4. Verify after manual edits

After you edit ClusterRoles with kubectl edit clusterrole <name> to replace * with explicit values, rerun:
If a previously flagged ClusterRole no longer appears, it no longer contains wildcards and passes this manual check (subject to your least-privilege judgment).
How to interpret the output:
  • Any block printed under === Scanning ClusterRoles for wildcard usage === or === Scanning Roles for wildcard usage (all namespaces) === indicates a potential problem.
  • In each block:
    • KIND / NAME / NAMESPACE identify the Role or ClusterRole.
    • OFFENDING RULES lists the specific rules entries where at least one of:
      • verbs contains "*",
      • resources contains "*",
      • apiGroups contains "*".
  • Each such rule should be manually reviewed and, where feasible, wildcards replaced with explicit verbs, resources, and apiGroups using:
    • kubectl edit clusterrole <name>
    • kubectl edit role -n <namespace> <name>