implementing-rbac-hardening-for-kubernetes

Harden Kubernetes RBAC with least-privilege roles, binding audits, and OIDC integration.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill implementing-rbac-hardening-for-kubernetes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implementing-rbac-hardening-for-kubernetes
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/container-security/implementing-rbac-hardening-for-kubernetes
Command: npx skills add https://github.com/xalgord/xalgorix --skill implementing-rbac-hardening-for-kubernetes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kubernetes clusters often ship with overly permissive RBAC defaults—wildcard verbs, cluster-admin sprawl, and auto-mounted service account tokens—that enable privilege escalation and lateral movement. This Skill provides a structured methodology to audit, detect, and remediate dangerous RBAC configurations before attackers exploit them.

Core Features & Use Cases

  • Misconfiguration Detection: Identify wildcard permissions, escalation verbs (escalate, bind, impersonate), token/exec paths, and aggregated ClusterRoles using kubectl and jq queries.
  • Least-Privilege Implementation: Apply namespace-scoped Roles, dedicated service accounts per workload, and restricted permission sets with ready-to-use YAML manifests.
  • RBAC Audit Workflow: Run a four-step audit covering binding enumeration, overprivileged service accounts, default service account usage, and token auto-mount verification.
  • Use Case: A platform engineer preparing for a CIS Kubernetes Benchmark assessment uses this Skill to enumerate all cluster-admin bindings, replace them with namespace-scoped roles, integrate OIDC authentication, and verify effective access with kubectl auth can-i.

Quick Start

Audit my Kubernetes cluster for overprivileged RBAC bindings and generate least-privilege role manifests to replace cluster-admin grants.

Frequently Asked Questions about implementing-rbac-hardening-for-kubernetes

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find overprivileged RBAC roles in Kubernetes?

Use kubectl with jq to list all ClusterRoleBindings referencing cluster-admin, and scan roles for wildcard verbs or resources. Verify effective permissions with kubectl auth can-i rather than reading YAML, since RBAC is additive.

How to implement least-privilege RBAC in Kubernetes?

Replace ClusterRoles with namespace-scoped Roles granting only required verbs, create dedicated service accounts per workload with automountServiceAccountToken disabled, and block dangerous permissions like secrets get, pods/exec create, and clusterrole modification.

What RBAC permissions allow privilege escalation in Kubernetes?

The escalate and bind verbs let subjects grant themselves any permission, while impersonate bypasses RBAC entirely. Create access on pods/exec, serviceaccounts/token, and secrets get/list also enables lateral movement without admin rights.

Does Kubernetes RBAC work with external identity providers?

Yes, the API server supports OIDC integration via flags like --oidc-issuer-url, --oidc-client-id, and --oidc-groups-claim. This maps external users and groups to RBAC RoleBindings for centralized authentication.

Why is my RBAC binding not taking effect?

A binding referencing a non-existent role is inert and grants nothing. Also check that subjects are correctly namespaced and remember RBAC never subtracts permissions—verify actual access with kubectl auth can-i --as for the specific subject.