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
HighAddress
Compliance, SecurityCompliance Standards
- CIS OKE
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
In OKE this is a Kubernetes RBAC issue, so you fix it inside the cluster (via Or list them and inspect one by one:Check namespace-scoped Roles:Look for rules like:or any use of To least-privilege:If nothing returns (or only comments), the wildcard usage is removed.
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
- Sign in to OCI Console.
- Click the Cloud Shell icon (top-right of the console).
- A terminal opens at the bottom of the browser.
2. Get kubeconfig for the OKE cluster
- In the left menu: Developer Services → Kubernetes Clusters (OKE).
- Select the correct Compartment.
- Click your Cluster.
- Click Access Cluster.
-
Under “Cloud Shell access”, click Copy next to the
oci ce cluster create-kubeconfigcommand. -
Paste it into Cloud Shell and run it, for example:
-
Verify access:
3. Identify Roles and ClusterRoles using wildcards
Check ClusterRoles:"*" 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"]).
5. Edit the Roles/ClusterRoles
Usekubectl edit in Cloud Shell:-
ClusterRole:
-
Role:
vi); modify the rules section to remove * and save.Or apply updated YAML manifests:-
Dump existing definition:
-
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.
- Under
-
Apply:
6. Verify remediation
Recheck for wildcards: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.
Using CLI
Using CLI
In OKE you can only reach the cluster via OCI CLI; the RBAC objects themselves are standard Kubernetes and must be changed with
If you share a sample Role/ClusterRole manifest that currently uses
kubectl. So the remediation flow is:- use OCI CLI to fetch kubeconfig
- use
kubectlto find Roles/ClusterRoles that use* - replace wildcards with explicit verbs/resources and apply
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:-
Export it to a file:
-
Edit the file and remove wildcards:
Example BEFORE:
Example AFTER (replace with explicit groups/resources/verbs you actually need):Key principles:
- Do not use
*inverbs,resources, orapiGroups. - List only the verbs required (
get,list,watch,create,update,patch,delete,deletecollection). - List only the resources needed.
- Do not use
-
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.Using Python
Using Python
Below is a practical, Python-based approach to identify and remediate OCI OKE
Ensure your kubeconfig points to the OKE cluster (e.g. from OCI Console, “Access Cluster” >
Example: convert some typical wildcards to explicit sets.
Best practice: print a diff or backup yaml before applying.
Additionally test workloads and CI/CD pipelines that depend on these RBAC objects to ensure nothing breaks.
If you share an example of an actual
Role and ClusterRole objects that use wildcard ("*") verbs or resources.Assumptions:- You have
kubectlaccess 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
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 APIreplace_* 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
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/Roleis 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.Using Terraform
Using Terraform
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.
