More Info:
Wildcards in Roles and ClusterRoles grant unpredictable and often excessive permissions. Replace wildcards with explicit resources and verbs to enforce least privilege.Risk Level
CriticalAddress
SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all Roles and ClusterRoles that use wildcards
- Run on: any machine with kubectl access
-
Inspect each wildcarded Role/ClusterRole in detail
- For each name from step 1, view the full spec:
- Record for each rule:
- Which fields use
*(verbs,resources,apiGroups,resourceNames,nonResourceURLs) - Which subjects are bound (via RoleBindings/ClusterRoleBindings).
- Which fields use
-
Determine intended access and justify or reject each wildcard
For each Role/ClusterRole:- Identify business/operational purpose (who/what uses it, for what tasks).
- With application owners / operators, decide for each wildcard:
- Is the role truly generic/admin (e.g.
cluster-admin) and intentionally broad? If yes, document the justification and leave as-is. - Otherwise, enumerate the specific resources and verbs actually needed.
- Is the role truly generic/admin (e.g.
- Identify business/operational purpose (who/what uses it, for what tasks).
-
Design least-privilege replacement rules (on paper or in a draft file)
For each wildcarded rule you plan to tighten:- Replace
verbs: ["*"]with an explicit list (e.g.["get","list","watch"]for read-only, or addcreate,update, etc. only if required). - Replace
resources: ["*"]with only required resources per API group (e.g.["pods","deployments","configmaps"]). - Replace
apiGroups: ["*"]with specific groups (e.g.["","apps","batch"]). - Save the revised spec to a file for review, e.g.:
- Replace
-
Apply tightened Roles/ClusterRoles carefully and validate workloads
- After peer review/change control, apply the edited objects:
- Coordinate with owners to run smoke tests for affected users/service accounts to confirm required operations still succeed and no critical functionality broke.
- After peer review/change control, apply the edited objects:
-
Re-verify that wildcards are minimized
- Re-run the discovery from step 1 to confirm only justified wildcarded Roles/ClusterRoles remain:
- For any remaining wildcard use, ensure there is a written justification (e.g. break-glass admin, temporary migration) and a plan/date to revisit if appropriate.
Using kubectl
Using kubectl
- Any name listed here is a ClusterRole that uses at least one wildcard and must be reviewed.
- In
.rules:verbs: ["*"]orverbs: - "*".resources: ["*"]orresources: - "*".apiGroups: ["*"]orapiGroups: - "*".resourceNames: ["*"]orresourceNames: - "*".
- Especially risky when combined, e.g.:
apiGroups: ["*"]andresources: ["*"]andverbs: ["*"](effectively full admin).- Wildcards on sensitive resources like
secrets,configmaps,roles,clusterroles,rolebindings,clusterrolebindings, orpods/exec.
- Which resources it actually needs.
- Which verbs are really required (e.g.
get,list,watchvscreate,update,patch,delete). - Whether wildcards can be replaced with explicit lists.
- Which subjects (users, groups, service accounts) are granted the wildcarded ClusterRole.
- Broader or more sensitive subjects (e.g.
system:serviceaccounts,system:authenticated, production namespaces) indicate higher risk and increase the urgency to reduce wildcard use.
- Any
namespace/namelisted is a Role with wildcard usage; examine them with: - The same indicators of problematic wildcards apply as for ClusterRoles.
Automation
Automation
- Any block printed by this script (separated by
---) represents a Role or ClusterRole that uses at least one wildcard in:rules[].verbs(e.g.,"*"),rules[].resources(e.g.,"*"),rules[].apiGroups(e.g.,"*"),- or
rules[].resourceNames(e.g.,"*").

