More Info:
Wildcards (*) in verbs, resources, or apiGroups grant broad, unintended permissions. Replacing them with explicit values enforces least privilege.Risk Level
CriticalAddress
SecurityCompliance Standards
- CIS AKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all ClusterRoles that use wildcards
- Run on: any machine with kubectl access
Save this list; these are the ClusterRoles to review. -
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. - Run on: any machine with kubectl access
-
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.
- Review the consuming subjects (users, groups, service accounts) and their applications’ actual needs:
-
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 eachrulesentry:- 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.
- Run on: any machine with kubectl access
-
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:
- For any ClusterRole where
-
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.
Using kubectl
Using kubectl
Run these commands from any machine with kubectl access.Problem indication: Any name in the output is a ClusterRole that uses at least one Problem indication: Lines under Problem indication inside Then intersect with the wildcarded ClusterRoles:Problem indication: Any ClusterRole name in the final If a previously flagged ClusterRole no longer appears, it no longer contains wildcards and passes this manual check (subject to your least-privilege judgment).
1. List all ClusterRoles that contain any wildcard
* in verbs, resources, or apiGroups and needs manual review.If you don’t have jq, use: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:rules::verbs:resources:apiGroups:
3. Focus on ClusterRoles actually bound to users/service accounts
List all ClusterRoleBindings and the ClusterRoles they reference: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 withkubectl edit clusterrole <name> to replace * with explicit values, rerun:Automation
Automation
- 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/NAMESPACEidentify the Role or ClusterRole.OFFENDING RULESlists the specificrulesentries where at least one of:verbscontains"*",resourcescontains"*",apiGroupscontains"*".
- Each such rule should be manually reviewed and, where feasible, wildcards replaced with explicit
verbs,resources, andapiGroupsusing:kubectl edit clusterrole <name>kubectl edit role -n <namespace> <name>

