[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E2F6YFV22S0SFDQ1J8ECGP":3,"skill-same:01M7E2F6YFV22S0SFDQ1J8ECGP":107},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":69,"commitSha":70,"skillDirectory":71,"forksCount":72,"repositoryHtmlUrl":73,"repositoryHomepageUrl":6,"ownerHtmlUrl":74,"ownerBlogUrl":6,"ownerDescription":75,"updatedAt":76,"install":77,"resources":90},"01M7E2F6YFV22S0SFDQ1J8ECGP","auditing-kubernetes-cluster-rbac",null,"Auditing Kubernetes cluster RBAC configurations to identify overly permissive roles, wildcard permissions, dangerous ClusterRoleBindings, service account abuse, and privilege escalation paths using kubectl, rbac-tool, KubiScan, and Kubeaudit.","sanjeevafk\u002Fagent-skills","sanjeevafk","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F230678117?v=4","01M7C540EFY46ETG1NNWKS5X3Q","Sanjeev","01M7C540F366J5C1D587BMKH9Q",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: auditing-kubernetes-cluster-rbac\ndescription: 'Auditing Kubernetes cluster RBAC configurations to identify overly permissive\n  roles, wildcard permissions, dangerous ClusterRoleBindings, service account abuse,\n  and privilege escalation paths using kubectl, rbac-tool, KubiScan, and Kubeaudit.\n\n  '\ndomain: cybersecurity\nsubdomain: cloud-security\ntags:\n- cloud-security\n- kubernetes\n- rbac\n- access-control\n- eks\n- gke\n- aks\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.IR-01\n- ID.AM-08\n- GV.SC-06\n- DE.CM-01\nmitre_attack:\n- T1098.006\n- T1552.007\n- T1611\n- T1613\n- T1078.004\nmitre_f3:\n  version: '1.1'\n  tactics:\n  - initial-access\n  - positioning\n  - defense-impairment\n  techniques:\n  - id: F1033\n    name: Insider Access Abuse\n    tactic: initial-access\n    source: f3\n  - id: F1005\n    name: Account Manipulation\n    tactic: positioning\n    source: f3\n  - id: F1005.002\n    name: 'Account Manipulation: Add Authorized User'\n    tactic: positioning\n    source: f3\n  - id: T1531\n    name: Account Access Removal\n    tactic: positioning\n    source: attack\n---\n\n# Auditing Kubernetes Cluster RBAC\n\n## When to Use\n\n- When performing security assessments of Kubernetes clusters (EKS, GKE, AKS, or self-managed)\n- When validating that RBAC policies enforce least privilege for users and service accounts\n- When investigating potential lateral movement or privilege escalation within a Kubernetes cluster\n- When compliance audits require documentation of access controls and permissions\n- When onboarding new teams to a shared cluster and defining appropriate RBAC policies\n\n**Do not use** for network policy auditing (use Cilium or Calico network policy tools), for container image scanning (use Trivy or Grype), or for runtime security monitoring (use Falco or Sysdig Secure).\n\n## Prerequisites\n\n- kubectl configured with cluster-admin or equivalent read permissions to the target cluster\n- rbac-tool installed (`kubectl krew install rbac-tool` or binary from GitHub)\n- KubiScan installed (`pip install kubiscan`)\n- Kubeaudit installed (`brew install kubeaudit` or from GitHub releases)\n- Access to the cluster's audit logs for correlating RBAC findings with actual API access\n\n## Workflow\n\n### Step 1: Enumerate ClusterRoles and Roles with Dangerous Permissions\n\nIdentify roles with wildcard permissions, secret access, pod exec, or escalation capabilities.\n\n```bash\n# List all ClusterRoles with wildcard verb access\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        verbs = rule.get('verbs', [])\n        resources = rule.get('resources', [])\n        if '*' in verbs or '*' in resources:\n            print(f'ClusterRole: {name}')\n            print(f'  Verbs: {verbs}')\n            print(f'  Resources: {resources}')\n            print(f'  API Groups: {rule.get(\\\"apiGroups\\\", [])}')\n            print()\n\"\n\n# Find roles that can read secrets\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        resources = rule.get('resources', [])\n        verbs = rule.get('verbs', [])\n        if ('secrets' in resources or '*' in resources) and ('get' in verbs or 'list' in verbs or '*' in verbs):\n            if not name.startswith('system:'):\n                print(f'ClusterRole: {name} -> can access secrets (verbs: {verbs})')\n\"\n\n# Find roles with pod\u002Fexec permissions (container escape risk)\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        resources = rule.get('resources', [])\n        if 'pods\u002Fexec' in resources or 'pods\u002F*' in resources:\n            print(f'ClusterRole: {name} -> has pods\u002Fexec access')\n\"\n```\n\n### Step 2: Audit ClusterRoleBindings and RoleBindings\n\nReview bindings to identify who has elevated access and detect overly broad group assignments.\n\n```bash\n# List all ClusterRoleBindings with the subjects\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    name = binding['metadata']['name']\n    role = binding['roleRef']['name']\n    subjects = binding.get('subjects', [])\n    for subject in subjects:\n        kind = subject.get('kind', '')\n        subj_name = subject.get('name', '')\n        ns = subject.get('namespace', 'cluster-wide')\n        print(f'{name} -> Role: {role} | {kind}: {subj_name} ({ns})')\n\" | sort\n\n# Find bindings to cluster-admin\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    if binding['roleRef']['name'] == 'cluster-admin':\n        print(f\\\"Binding: {binding['metadata']['name']}\\\")\n        for subject in binding.get('subjects', []):\n            print(f\\\"  {subject.get('kind')}: {subject.get('name')} (ns: {subject.get('namespace', 'N\u002FA')})\\\")\n\"\n\n# Find bindings granting access to all authenticated users\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    for subject in binding.get('subjects', []):\n        if subject.get('name') in ['system:authenticated', 'system:unauthenticated']:\n            print(f\\\"WARNING: {binding['metadata']['name']} grants {binding['roleRef']['name']} to {subject['name']}\\\")\n\"\n```\n\n### Step 3: Scan with rbac-tool for Comprehensive Analysis\n\nUse rbac-tool for automated RBAC analysis including who-can queries and policy generation.\n\n```bash\n# Who can get secrets across all namespaces\nkubectl rbac-tool who-can get secrets\n\n# Who can create pods (potential for container escape)\nkubectl rbac-tool who-can create pods\n\n# Who can exec into pods\nkubectl rbac-tool who-can create pods\u002Fexec\n\n# Who can escalate privileges (bind\u002Fescalate verbs)\nkubectl rbac-tool who-can bind clusterroles\nkubectl rbac-tool who-can escalate clusterroles\n\n# Generate RBAC policy report\nkubectl rbac-tool analysis\n\n# Visualize RBAC relationships\nkubectl rbac-tool viz --outformat dot > rbac-graph.dot\ndot -Tpng rbac-graph.dot -o rbac-graph.png\n```\n\n### Step 4: Run KubiScan for Risky Permissions Detection\n\nUse KubiScan to automatically identify risky service accounts, pods, and RBAC configurations.\n\n```bash\n# Run KubiScan to find risky roles\npython3 -m kubiscan -rroles   # List risky Roles\npython3 -m kubiscan -rcr      # List risky ClusterRoles\npython3 -m kubiscan -rrb      # List risky RoleBindings\npython3 -m kubiscan -rcrb     # List risky ClusterRoleBindings\n\n# Find risky service accounts\npython3 -m kubiscan -rs       # Risky service accounts\n\n# Find pods running with risky service accounts\npython3 -m kubiscan -rp       # Risky pods\n\n# Check for privilege escalation paths\npython3 -m kubiscan -pe       # Privilege escalation vectors\n\n# Generate full report\npython3 -m kubiscan -a        # All checks\n```\n\n### Step 5: Audit Service Account Token Mounting and Usage\n\nCheck for unnecessary service account token mounts that could enable lateral movement from compromised pods.\n\n```bash\n# Find pods with automounted service account tokens\nkubectl get pods --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor pod in data['items']:\n    name = pod['metadata']['name']\n    ns = pod['metadata']['namespace']\n    sa = pod['spec'].get('serviceAccountName', 'default')\n    automount = pod['spec'].get('automountServiceAccountToken', True)\n    if automount and sa != 'default':\n        print(f'{ns}\u002F{name} -> SA: {sa} (token auto-mounted)')\n\"\n\n# Find service accounts with non-default token secrets\nkubectl get serviceaccounts --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor sa in data['items']:\n    name = sa['metadata']['name']\n    ns = sa['metadata']['namespace']\n    secrets = sa.get('secrets', [])\n    if name != 'default' and len(secrets) > 0:\n        print(f'{ns}\u002F{name}: {len(secrets)} secret(s) bound')\n\"\n\n# Check for pods running as privileged or with host access\nkubectl get pods --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor pod in data['items']:\n    name = pod['metadata']['name']\n    ns = pod['metadata']['namespace']\n    for container in pod['spec'].get('containers', []):\n        sc = container.get('securityContext', {})\n        if sc.get('privileged', False) or sc.get('runAsUser', 1) == 0:\n            print(f'RISK: {ns}\u002F{name}\u002F{container[\\\"name\\\"]} - privileged={sc.get(\\\"privileged\\\",False)} runAsRoot={sc.get(\\\"runAsUser\\\",\\\"not set\\\")==0}')\n\"\n```\n\n### Step 6: Run Kubeaudit for RBAC and Security Policy Validation\n\nExecute Kubeaudit for comprehensive security checks including RBAC-related findings.\n\n```bash\n# Run all kubeaudit checks\nkubeaudit all --kubeconfig ~\u002F.kube\u002Fconfig\n\n# Run specific RBAC-related checks\nkubeaudit privesc    # Check for allowPrivilegeEscalation\nkubeaudit rootfs     # Check for readOnlyRootFilesystem\nkubeaudit nonroot    # Check for runAsNonRoot\nkubeaudit capabilities  # Check for dangerous capabilities\n\n# Output as JSON for processing\nkubeaudit all --kubeconfig ~\u002F.kube\u002Fconfig -f json > kubeaudit-results.json\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| RBAC | Role-Based Access Control in Kubernetes, a method for regulating access to cluster resources based on the roles of individual users or service accounts |\n| ClusterRole | Cluster-wide role definition that specifies permissions (verbs on resources) applicable across all namespaces |\n| ClusterRoleBinding | Associates a ClusterRole with subjects (users, groups, service accounts) at the cluster scope |\n| Service Account | Identity associated with pods for authenticating to the Kubernetes API server, automatically mounted unless disabled |\n| automountServiceAccountToken | Pod spec field controlling whether the service account token is automatically mounted into the pod filesystem |\n| Privilege Escalation | RBAC verbs (bind, escalate, impersonate) that allow a user to grant themselves or others elevated permissions |\n\n## Tools & Systems\n\n- **kubectl**: Primary CLI for querying Kubernetes RBAC resources (roles, bindings, service accounts)\n- **rbac-tool**: kubectl plugin for RBAC analysis including who-can queries, visualization, and policy generation\n- **KubiScan**: Python tool for scanning Kubernetes RBAC for risky permissions and privilege escalation paths\n- **Kubeaudit**: Security auditing tool that checks pods and workloads for security anti-patterns including RBAC issues\n- **rakkess**: kubectl plugin showing access matrix for the current user across all resource types\n\n## Common Scenarios\n\n### Scenario: Auditing an EKS Cluster Shared by Multiple Development Teams\n\n**Context**: A shared EKS cluster serves four development teams. RBAC was configured during initial setup but has not been reviewed in 12 months. Teams report being able to access other teams' namespaces.\n\n**Approach**:\n1. List all ClusterRoleBindings to identify bindings granting broad access to authenticated users\n2. Run `kubectl rbac-tool who-can get secrets` to find subjects that can read secrets across namespaces\n3. Discover that a ClusterRoleBinding grants `edit` to `system:authenticated`, giving all users write access cluster-wide\n4. Run KubiScan to identify service accounts with risky permissions and pods running with elevated service accounts\n5. Replace the ClusterRoleBinding with namespace-scoped RoleBindings for each team\n6. Disable automountServiceAccountToken for workloads that do not need API access\n7. Create a NetworkPolicy to isolate namespace traffic between teams\n\n**Pitfalls**: Removing ClusterRoleBindings can break CI\u002FCD pipelines and operators that rely on cluster-wide access. Always audit which workloads use the bindings before removing them. EKS maps IAM roles to Kubernetes groups via aws-auth ConfigMap, so RBAC changes must be coordinated with IAM role mappings.\n\n## Output Format\n\n```\nKubernetes RBAC Audit Report\n===============================\nCluster: production-eks (EKS 1.28)\nAudit Date: 2026-02-23\nNamespaces: 12\n\nRBAC INVENTORY:\n  ClusterRoles: 48 (18 custom, 30 system)\n  ClusterRoleBindings: 32 (12 custom, 20 system)\n  Roles (namespaced): 24\n  RoleBindings (namespaced): 36\n  Service Accounts: 67\n\nCRITICAL FINDINGS:\n[RBAC-001] ClusterRoleBinding Grants edit to system:authenticated\n  Binding: authenticated-edit\n  Effect: ALL authenticated users have edit access across ALL namespaces\n  Risk: Any user can modify resources in any namespace\n  Remediation: Replace with namespace-scoped RoleBindings per team\n\n[RBAC-002] Custom ClusterRole with Wildcard Permissions\n  ClusterRole: developer-admin\n  Rules: verbs=[\"*\"], resources=[\"*\"], apiGroups=[\"*\"]\n  Bindings: 4 users via developer-admin-binding\n  Risk: Equivalent to cluster-admin without the name\n  Remediation: Scope to specific resources and verbs needed\n\nSUMMARY:\n  Principals with cluster-admin: 6 (recommended: \u003C= 3)\n  Roles with wildcard permissions: 4\n  Service accounts with secret access: 12\n  Pods with auto-mounted tokens: 45 \u002F 67\n  Privileged containers: 8\n```\n","# Auditing Kubernetes Cluster RBAC\n\n## When to Use\n\n- When performing security assessments of Kubernetes clusters (EKS, GKE, AKS, or self-managed)\n- When validating that RBAC policies enforce least privilege for users and service accounts\n- When investigating potential lateral movement or privilege escalation within a Kubernetes cluster\n- When compliance audits require documentation of access controls and permissions\n- When onboarding new teams to a shared cluster and defining appropriate RBAC policies\n\n**Do not use** for network policy auditing (use Cilium or Calico network policy tools), for container image scanning (use Trivy or Grype), or for runtime security monitoring (use Falco or Sysdig Secure).\n\n## Prerequisites\n\n- kubectl configured with cluster-admin or equivalent read permissions to the target cluster\n- rbac-tool installed (`kubectl krew install rbac-tool` or binary from GitHub)\n- KubiScan installed (`pip install kubiscan`)\n- Kubeaudit installed (`brew install kubeaudit` or from GitHub releases)\n- Access to the cluster's audit logs for correlating RBAC findings with actual API access\n\n## Workflow\n\n### Step 1: Enumerate ClusterRoles and Roles with Dangerous Permissions\n\nIdentify roles with wildcard permissions, secret access, pod exec, or escalation capabilities.\n\n```bash\n# List all ClusterRoles with wildcard verb access\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        verbs = rule.get('verbs', [])\n        resources = rule.get('resources', [])\n        if '*' in verbs or '*' in resources:\n            print(f'ClusterRole: {name}')\n            print(f'  Verbs: {verbs}')\n            print(f'  Resources: {resources}')\n            print(f'  API Groups: {rule.get(\\\"apiGroups\\\", [])}')\n            print()\n\"\n\n# Find roles that can read secrets\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        resources = rule.get('resources', [])\n        verbs = rule.get('verbs', [])\n        if ('secrets' in resources or '*' in resources) and ('get' in verbs or 'list' in verbs or '*' in verbs):\n            if not name.startswith('system:'):\n                print(f'ClusterRole: {name} -> can access secrets (verbs: {verbs})')\n\"\n\n# Find roles with pod\u002Fexec permissions (container escape risk)\nkubectl get clusterroles -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor role in data['items']:\n    name = role['metadata']['name']\n    for rule in role.get('rules', []):\n        resources = rule.get('resources', [])\n        if 'pods\u002Fexec' in resources or 'pods\u002F*' in resources:\n            print(f'ClusterRole: {name} -> has pods\u002Fexec access')\n\"\n```\n\n### Step 2: Audit ClusterRoleBindings and RoleBindings\n\nReview bindings to identify who has elevated access and detect overly broad group assignments.\n\n```bash\n# List all ClusterRoleBindings with the subjects\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    name = binding['metadata']['name']\n    role = binding['roleRef']['name']\n    subjects = binding.get('subjects', [])\n    for subject in subjects:\n        kind = subject.get('kind', '')\n        subj_name = subject.get('name', '')\n        ns = subject.get('namespace', 'cluster-wide')\n        print(f'{name} -> Role: {role} | {kind}: {subj_name} ({ns})')\n\" | sort\n\n# Find bindings to cluster-admin\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    if binding['roleRef']['name'] == 'cluster-admin':\n        print(f\\\"Binding: {binding['metadata']['name']}\\\")\n        for subject in binding.get('subjects', []):\n            print(f\\\"  {subject.get('kind')}: {subject.get('name')} (ns: {subject.get('namespace', 'N\u002FA')})\\\")\n\"\n\n# Find bindings granting access to all authenticated users\nkubectl get clusterrolebindings -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor binding in data['items']:\n    for subject in binding.get('subjects', []):\n        if subject.get('name') in ['system:authenticated', 'system:unauthenticated']:\n            print(f\\\"WARNING: {binding['metadata']['name']} grants {binding['roleRef']['name']} to {subject['name']}\\\")\n\"\n```\n\n### Step 3: Scan with rbac-tool for Comprehensive Analysis\n\nUse rbac-tool for automated RBAC analysis including who-can queries and policy generation.\n\n```bash\n# Who can get secrets across all namespaces\nkubectl rbac-tool who-can get secrets\n\n# Who can create pods (potential for container escape)\nkubectl rbac-tool who-can create pods\n\n# Who can exec into pods\nkubectl rbac-tool who-can create pods\u002Fexec\n\n# Who can escalate privileges (bind\u002Fescalate verbs)\nkubectl rbac-tool who-can bind clusterroles\nkubectl rbac-tool who-can escalate clusterroles\n\n# Generate RBAC policy report\nkubectl rbac-tool analysis\n\n# Visualize RBAC relationships\nkubectl rbac-tool viz --outformat dot > rbac-graph.dot\ndot -Tpng rbac-graph.dot -o rbac-graph.png\n```\n\n### Step 4: Run KubiScan for Risky Permissions Detection\n\nUse KubiScan to automatically identify risky service accounts, pods, and RBAC configurations.\n\n```bash\n# Run KubiScan to find risky roles\npython3 -m kubiscan -rroles   # List risky Roles\npython3 -m kubiscan -rcr      # List risky ClusterRoles\npython3 -m kubiscan -rrb      # List risky RoleBindings\npython3 -m kubiscan -rcrb     # List risky ClusterRoleBindings\n\n# Find risky service accounts\npython3 -m kubiscan -rs       # Risky service accounts\n\n# Find pods running with risky service accounts\npython3 -m kubiscan -rp       # Risky pods\n\n# Check for privilege escalation paths\npython3 -m kubiscan -pe       # Privilege escalation vectors\n\n# Generate full report\npython3 -m kubiscan -a        # All checks\n```\n\n### Step 5: Audit Service Account Token Mounting and Usage\n\nCheck for unnecessary service account token mounts that could enable lateral movement from compromised pods.\n\n```bash\n# Find pods with automounted service account tokens\nkubectl get pods --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor pod in data['items']:\n    name = pod['metadata']['name']\n    ns = pod['metadata']['namespace']\n    sa = pod['spec'].get('serviceAccountName', 'default')\n    automount = pod['spec'].get('automountServiceAccountToken', True)\n    if automount and sa != 'default':\n        print(f'{ns}\u002F{name} -> SA: {sa} (token auto-mounted)')\n\"\n\n# Find service accounts with non-default token secrets\nkubectl get serviceaccounts --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor sa in data['items']:\n    name = sa['metadata']['name']\n    ns = sa['metadata']['namespace']\n    secrets = sa.get('secrets', [])\n    if name != 'default' and len(secrets) > 0:\n        print(f'{ns}\u002F{name}: {len(secrets)} secret(s) bound')\n\"\n\n# Check for pods running as privileged or with host access\nkubectl get pods --all-namespaces -o json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor pod in data['items']:\n    name = pod['metadata']['name']\n    ns = pod['metadata']['namespace']\n    for container in pod['spec'].get('containers', []):\n        sc = container.get('securityContext', {})\n        if sc.get('privileged', False) or sc.get('runAsUser', 1) == 0:\n            print(f'RISK: {ns}\u002F{name}\u002F{container[\\\"name\\\"]} - privileged={sc.get(\\\"privileged\\\",False)} runAsRoot={sc.get(\\\"runAsUser\\\",\\\"not set\\\")==0}')\n\"\n```\n\n### Step 6: Run Kubeaudit for RBAC and Security Policy Validation\n\nExecute Kubeaudit for comprehensive security checks including RBAC-related findings.\n\n```bash\n# Run all kubeaudit checks\nkubeaudit all --kubeconfig ~\u002F.kube\u002Fconfig\n\n# Run specific RBAC-related checks\nkubeaudit privesc    # Check for allowPrivilegeEscalation\nkubeaudit rootfs     # Check for readOnlyRootFilesystem\nkubeaudit nonroot    # Check for runAsNonRoot\nkubeaudit capabilities  # Check for dangerous capabilities\n\n# Output as JSON for processing\nkubeaudit all --kubeconfig ~\u002F.kube\u002Fconfig -f json > kubeaudit-results.json\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| RBAC | Role-Based Access Control in Kubernetes, a method for regulating access to cluster resources based on the roles of individual users or service accounts |\n| ClusterRole | Cluster-wide role definition that specifies permissions (verbs on resources) applicable across all namespaces |\n| ClusterRoleBinding | Associates a ClusterRole with subjects (users, groups, service accounts) at the cluster scope |\n| Service Account | Identity associated with pods for authenticating to the Kubernetes API server, automatically mounted unless disabled |\n| automountServiceAccountToken | Pod spec field controlling whether the service account token is automatically mounted into the pod filesystem |\n| Privilege Escalation | RBAC verbs (bind, escalate, impersonate) that allow a user to grant themselves or others elevated permissions |\n\n## Tools & Systems\n\n- **kubectl**: Primary CLI for querying Kubernetes RBAC resources (roles, bindings, service accounts)\n- **rbac-tool**: kubectl plugin for RBAC analysis including who-can queries, visualization, and policy generation\n- **KubiScan**: Python tool for scanning Kubernetes RBAC for risky permissions and privilege escalation paths\n- **Kubeaudit**: Security auditing tool that checks pods and workloads for security anti-patterns including RBAC issues\n- **rakkess**: kubectl plugin showing access matrix for the current user across all resource types\n\n## Common Scenarios\n\n### Scenario: Auditing an EKS Cluster Shared by Multiple Development Teams\n\n**Context**: A shared EKS cluster serves four development teams. RBAC was configured during initial setup but has not been reviewed in 12 months. Teams report being able to access other teams' namespaces.\n\n**Approach**:\n1. List all ClusterRoleBindings to identify bindings granting broad access to authenticated users\n2. Run `kubectl rbac-tool who-can get secrets` to find subjects that can read secrets across namespaces\n3. Discover that a ClusterRoleBinding grants `edit` to `system:authenticated`, giving all users write access cluster-wide\n4. Run KubiScan to identify service accounts with risky permissions and pods running with elevated service accounts\n5. Replace the ClusterRoleBinding with namespace-scoped RoleBindings for each team\n6. Disable automountServiceAccountToken for workloads that do not need API access\n7. Create a NetworkPolicy to isolate namespace traffic between teams\n\n**Pitfalls**: Removing ClusterRoleBindings can break CI\u002FCD pipelines and operators that rely on cluster-wide access. Always audit which workloads use the bindings before removing them. EKS maps IAM roles to Kubernetes groups via aws-auth ConfigMap, so RBAC changes must be coordinated with IAM role mappings.\n\n## Output Format\n\n```\nKubernetes RBAC Audit Report\n===============================\nCluster: production-eks (EKS 1.28)\nAudit Date: 2026-02-23\nNamespaces: 12\n\nRBAC INVENTORY:\n  ClusterRoles: 48 (18 custom, 30 system)\n  ClusterRoleBindings: 32 (12 custom, 20 system)\n  Roles (namespaced): 24\n  RoleBindings (namespaced): 36\n  Service Accounts: 67\n\nCRITICAL FINDINGS:\n[RBAC-001] ClusterRoleBinding Grants edit to system:authenticated\n  Binding: authenticated-edit\n  Effect: ALL authenticated users have edit access across ALL namespaces\n  Risk: Any user can modify resources in any namespace\n  Remediation: Replace with namespace-scoped RoleBindings per team\n\n[RBAC-002] Custom ClusterRole with Wildcard Permissions\n  ClusterRole: developer-admin\n  Rules: verbs=[\"*\"], resources=[\"*\"], apiGroups=[\"*\"]\n  Bindings: 4 users via developer-admin-binding\n  Risk: Equivalent to cluster-admin without the name\n  Remediation: Scope to specific resources and verbs needed\n\nSUMMARY:\n  Principals with cluster-admin: 6 (recommended: \u003C= 3)\n  Roles with wildcard permissions: 4\n  Service accounts with secret access: 12\n  Pods with auto-mounted tokens: 45 \u002F 67\n  Privileged containers: 8\n```\n",{"name":5,"tags":25,"author":33,"domain":34,"license":15,"version":35,"mitre_f3":36,"nist_csf":57,"subdomain":26,"description":62,"mitre_attack":63},[26,27,28,29,30,31,32],"cloud-security","kubernetes","rbac","access-control","eks","gke","aks","mahipal","cybersecurity","1.0",{"tactics":37,"version":41,"techniques":42},[38,39,40],"initial-access","positioning","defense-impairment","1.1",[43,47,50,53],{"id":44,"name":45,"source":46,"tactic":38},"F1033","Insider Access Abuse","f3",{"id":48,"name":49,"source":46,"tactic":39},"F1005","Account Manipulation",{"id":51,"name":52,"source":46,"tactic":39},"F1005.002","Account Manipulation: Add Authorized User",{"id":54,"name":55,"source":56,"tactic":39},"T1531","Account Access Removal","attack",[58,59,60,61],"PR.IR-01","ID.AM-08","GV.SC-06","DE.CM-01","Auditing Kubernetes cluster RBAC configurations to identify overly permissive roles, wildcard permissions, dangerous ClusterRoleBindings, service account abuse, and privilege escalation paths using kubectl, rbac-tool, KubiScan, and Kubeaudit.\n",[64,65,66,67,68],"T1098.006","T1552.007","T1611","T1613","T1078.004","main","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","collections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac",1,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fsanjeevafk","First make it work. Then make it right. Then make it fast.","2026-11-14 13:36:16",{"source":8,"skillName":5,"commands":78,"prompt":88,"zipAvailable":89},[79,82,85],{"tool":80,"command":81},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-cluster-rbac",{"tool":83,"command":84},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-cluster-rbac",{"tool":86,"command":87},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-cluster-rbac","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac\u002FSKILL.md",true,[91,95,101],{"path":92,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":96,"resourceType":97,"resourceTypeDesc":98,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Fapi-reference.md","REFERENCE","参考文档",2193,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac\u002Freferences\u002Fapi-reference.md",{"path":102,"resourceType":103,"resourceTypeDesc":104,"sizeBytes":105,"sourceHtmlUrl":106},"scripts\u002Fagent.py","SCRIPT","脚本",7019,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-cluster-rbac\u002Fscripts\u002Fagent.py",[108,116,124,132,140,147],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":112,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":20},"01M7EFHX67M3KKXT1BXVPA5ADT","zarr-python","Chunked N-D arrays for cloud storage (Zarr-Python 3). Compressed arrays, parallel I\u002FO, S3\u002FGCS via fsspec, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","MIT","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":112,"licenseFileUrl":120,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":20},"01M7EFFQGM51TZBGRENXY50ZYM","whiteboard-diagrams","Create accurate, simple, hand-drawn whiteboard diagrams from a user's process, system, architecture, learning workflow, comparison, or causal explanation. Use when the user asks for a scribbly whiteboard visual, educational workflow graphic, hand-drawn explainer, or diagram like the bundled reference; ask one focused clarification question when the subject or relationships are missing, then generate and visually verify the final image.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwhiteboard-diagrams\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":128,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":20},"01M7EFF1CSQNTDMHFK4ZGY6NYK","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":136,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":20},"01M7EFE8106X6C28FT8PA74427","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":112,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":20},"01M7EFCSNZM9G7ZHS6F127Q71X","verification-loop","A comprehensive verification system for Claude Code sessions.","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":112,"licenseFileUrl":151,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":20},"01M7EFCE7EZMKPRYDDNKBQ9EEH","vercel-deploy","Deploy applications and websites to Vercel. Use when the user requests deployment actions like \"deploy my app\", \"deploy and give me the link\", \"push this live\", or \"create a preview deployment\".","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-deploy\u002FSKILL.md",[],[]]