Skip to main content

More Info:

Wildcards in Kubernetes Roles and ClusterRoles grant unintended permissions and break least-privilege. Replace wildcards with explicit verbs and resources to limit blast radius if a service account or user is compromised.

Risk Level

High

Address

Compliance, Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Using Console

In OKE this is a Kubernetes RBAC issue, so you fix it inside the cluster (via kubectl), not by flipping an OKE setting. You can do all of this from the OCI Console using Cloud Shell.

1. Open Cloud Shell from the OCI Console

  1. Sign in to OCI Console.
  2. Click the Cloud Shell icon (top-right of the console).
  3. A terminal opens at the bottom of the browser.

2. Get kubeconfig for the OKE cluster

  1. In the left menu: Developer Services → Kubernetes Clusters (OKE).
  2. Select the correct Compartment.
  3. Click your Cluster.
  4. Click Access Cluster.
  5. Under “Cloud Shell access”, click Copy next to the oci ce cluster create-kubeconfig command.
  6. Paste it into Cloud Shell and run it, for example:
  7. Verify access:

3. Identify Roles and ClusterRoles using wildcards

Check ClusterRoles:
Or list them and inspect one by one:
Check namespace-scoped Roles:
Look for rules like:
or any use of "*" in apiGroups, resources, resourceNames, or verbs.

4. Plan least-privilege replacements

For each offending Role/ClusterRole:
  • Replace resources: ["*"] with the exact resources needed (e.g. ["pods", "deployments"]).
  • Replace verbs: ["*"] with the minimal verbs (e.g. ["get", "list", "watch"]).
  • Avoid apiGroups: ["*"]; specify actual groups (e.g. ["", "apps"]).
Example: From overly broad:
To least-privilege:

5. Edit the Roles/ClusterRoles

Use kubectl edit in Cloud Shell:
  • ClusterRole:
  • Role:
This opens an editor (usually vi); modify the rules section to remove * and save.Or apply updated YAML manifests:
  1. Dump existing definition:
  2. Edit the file in Cloud Shell:
    • Under rules:, replace any "*" with specific resources/verbs/groups.
    • Ensure you do not modify system roles prefixed with system: unless you know exactly what you’re doing.
  3. Apply:
Repeat similarly for namespace Roles.

6. Verify remediation

Recheck for wildcards:
If nothing returns (or only comments), the wildcard usage is removed.

7. Additional notes

  • Avoid changing Kubernetes built-in system:* roles unless absolutely necessary.
  • If a third-party Helm chart installed broad roles, consider:
    • Overriding its RBAC values to use custom, restricted roles.
    • Reinstalling/upgrading the chart with more restrictive RBAC configuration.
In OKE you can only reach the cluster via OCI CLI; the RBAC objects themselves are standard Kubernetes and must be changed with kubectl. So the remediation flow is:
  1. use OCI CLI to fetch kubeconfig
  2. use kubectl to find Roles/ClusterRoles that use *
  3. replace wildcards with explicit verbs/resources and apply
Below is a minimal, step‑by‑step process.

1. Get kubeconfig for the OKE cluster using OCI CLI


2. Identify Roles and ClusterRoles using wildcards

2.1 ClusterRoles with wildcards

2.2 Namespaced Roles with wildcards


3. Replace wildcard rules with least‑privilege rules

For each identified (Cluster)Role:
  1. Export it to a file:
  2. Edit the file and remove wildcards: Example BEFORE:
    Example AFTER (replace with explicit groups/resources/verbs you actually need):
    Key principles:
    • Do not use * in verbs, resources, or apiGroups.
    • List only the verbs required (get, list, watch, create, update, patch, delete, deletecollection).
    • List only the resources needed.
  3. Apply the updated role:

4. Verify there are no remaining wildcards


If you share a sample Role/ClusterRole manifest that currently uses *, I can suggest an explicit least‑privilege replacement for that exact case.
Below is a practical, Python-based approach to identify and remediate OCI OKE Role and ClusterRole objects that use wildcard ("*") verbs or resources.Assumptions:
  • You have kubectl access to the OKE cluster.
  • You can install Python dependencies on a machine that has network access to the cluster.
  • You understand what the correct least-privilege permissions should be (you must decide the replacement for "*").

1. Set up Python environment

Ensure your kubeconfig points to the OKE cluster (e.g. from OCI Console, “Access Cluster” > kubectl setup).

2. Connect to the OKE cluster from Python


3. Detect Roles and ClusterRoles using wildcards


4. Define a least-privilege replacement policy

You must decide how "*" should be replaced.
Example: convert some typical wildcards to explicit sets.

5. Function to “de-wildcard” a single rule


6. Create updated Role / ClusterRole specs without wildcards


7. Apply the changes back to the cluster

Use the Kubernetes API replace_* methods.
Best practice: print a diff or backup yaml before applying.

7.1 Backup originals to YAML

7.2 Replace Roles and ClusterRoles


8. Validate post-remediation

Additionally test workloads and CI/CD pipelines that depend on these RBAC objects to ensure nothing breaks.

9. OCI/OKE-specific notes

  • These steps work the same in OKE as in any Kubernetes cluster, because RBAC is Kubernetes-native.
  • If any ClusterRole/Role is managed by OCI add-ons or Helm charts (e.g. oci-volume-provisioner, oci-cloud-controller-manager, ingress controller, etc.), update the chart/manifests as well, or your changes may be overwritten on upgrade or redeploy.

If you share an example of an actual Role/ClusterRole from your OKE cluster, I can give a concrete “before/after” Python transformation for that object.
The oci_containerengine_cluster / oci-containers-oke-cluster resource has no arguments for Kubernetes Roles or ClusterRoles; RBAC is entirely managed via the Kubernetes API. Update or replace your existing kubernetes_role / kubernetes_cluster_role resources (or Helm charts) to remove resources = ["*"] and verbs = ["*"], enumerating only the specific verbs and resources each principal needs.Verification: terraform plan should show updates to the affected kubernetes_role and/or kubernetes_cluster_role resources where verbs and resources change from ["*"] to explicit lists, with no changes to the OKE cluster resource itself.