Skip to main content

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

Critical

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. List all Roles and ClusterRoles that use wildcards
    • Run on: any machine with kubectl access
  2. 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).
  3. 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.
  4. 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 add create, 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.:
  5. 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.
  6. 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.
Output to review:
  • Any name listed here is a ClusterRole that uses at least one wildcard and must be reviewed.

What indicates a problem:
  • In .rules:
    • verbs: ["*"] or verbs: - "*".
    • resources: ["*"] or resources: - "*".
    • apiGroups: ["*"] or apiGroups: - "*".
    • resourceNames: ["*"] or resourceNames: - "*".
  • Especially risky when combined, e.g.:
    • apiGroups: ["*"] and resources: ["*"] and verbs: ["*"] (effectively full admin).
    • Wildcards on sensitive resources like secrets, configmaps, roles, clusterroles, rolebindings, clusterrolebindings, or pods/exec.
You must decide, per ClusterRole:
  • Which resources it actually needs.
  • Which verbs are really required (e.g. get,list,watch vs create,update,patch,delete).
  • Whether wildcards can be replaced with explicit lists.

Output to review:
  • 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.

Output to review:
  • Any namespace/name listed is a Role with wildcard usage; examine them with:
  • The same indicators of problematic wildcards apply as for ClusterRoles.
Explanation of output indicating a problem:
  • 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., "*").
Each such occurrence should be manually reviewed to determine whether you can replace the wildcard with a specific list of verbs, resources, API groups, or resource names to better enforce least privilege.