rbac-review
Skill0 starsChanged 8 months agoMITView on GitHub
Audit Kubernetes RBAC for overly broad permissions. Use when the user asks to review roles, service accounts, or role bindings for least privilege, or wants to know what a specific principal can do in the cluster.
In this repository6 other files it gives its agents.
- composeSkill
- docker-debugSkill
- dockerfileSkill
- helm-reviewSkill
- k8s-debugSkill
- manifestSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 110
Create a dedicated ServiceAccount instead of using the namespace default.
- Distinctive: line 114
Do not modify RBAC resources without asking the user.
- Distinctive: line 115
Do not produce findings based only on role names.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Audit Kubernetes RBAC
Review RBAC definitions and flag overly broad permissions.
Inputs
$ARGUMENTS is an optional namespace. If empty, audit cluster-wide RBAC (ClusterRole, ClusterRoleBinding) and ask whether the user also wants to audit a specific namespace. Only run namespace-scoped Role, RoleBinding, and ServiceAccount commands when a namespace is provided or confirmed.
Workflow
Step 1: inventory
kubectl get clusterrole -o wide
kubectl get clusterrolebinding -o wide
kubectl get role -n <ns>
kubectl get rolebinding -n <ns>
kubectl get serviceaccount -n <ns>Step 2: look for broad permissions
For each ClusterRole and Role, check rules for any of these red flags:
verbs: ["*"]on any resource.resources: ["*"]on any API group.apiGroups: ["*"].resources: ["secrets"]withverbsincludinggetorlist, outside a controller that genuinely needs it.resources: ["pods/exec"]or["pods/attach"]outside of explicit admin roles.nonResourceURLs: ["*"].
Step 3: trace bindings
For each risky role, find who uses it:
kubectl get clusterrolebinding -o wide
kubectl describe clusterrolebinding <binding-name>Focus on:
- Service accounts bound to
cluster-adminor other broad roles. - Groups such as
system:authenticatedorsystem:unauthenticatedbound to anything non-trivial. - Human users bound directly to ClusterRoles when a group would be more appropriate.
Step 4: test specific permissions
For any principal that looks risky, confirm with:
kubectl auth can-i --list --as=system:serviceaccount:<ns>:<sa>Output
Report findings grouped by severity:
## Critical
- <principal> has <verb> on <resource> cluster-wide via <role>. <why this is bad>. <fix>.
## High
- <...>
## Medium
- <...>
## Info
- <N> service accounts use the default service account in namespace <ns>. Consider creating dedicated accounts.For each finding, include:
- The exact role or binding, with namespace.
- The problematic rule.
- A concrete replacement rule that follows least privilege.
Example finding
Critical: ServiceAccount ci-runner in namespace build is bound to ClusterRole cluster-admin via ClusterRoleBinding ci-runner-admin. This gives CI full control of the cluster, including reading every Secret.
Replace with a minimal Role in the build namespace:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: ci-runner
namespace: build
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "patch", "update"]
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]Common fixes
- Replace
verbs: ["*"]with the actual verbs the workload uses. - Replace
resources: ["*"]with the specific resource kinds. - Split a ClusterRole into a Role when access is only needed in one namespace.
- Create a dedicated ServiceAccount instead of using the namespace default.
Do not
- Do not modify RBAC resources without asking the user.
- Do not produce findings based only on role names. Always read the actual rules.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

