<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Rbac | FirewallSync</title><link>https://firewallsync.com/tags/rbac/</link><description>Practical cybersecurity writing for engineering teams that ship fast.</description><language>en-us</language><image><url>https://firewallsync.com/icon-512.png</url><title>FirewallSync</title><link>https://firewallsync.com/</link></image><lastBuildDate>Thu, 22 Oct 2026 18:43:00 +0000</lastBuildDate><atom:link href="https://firewallsync.com/tags/rbac/index.xml" rel="self" type="application/rss+xml"/><item><title>Kubernetes RBAC Audit: 11 Permissions That Escalate Access</title><link>https://firewallsync.com/posts/kubernetes-rbac-audit-11-permissions-that-escalate-access/</link><guid>https://firewallsync.com/posts/kubernetes-rbac-audit-11-permissions-that-escalate-access/</guid><pubDate>Thu, 22 Oct 2026 18:43:00 +0000</pubDate><dc:creator>Craig Leslie</dc:creator><category>Identity &amp; Access</category><description>Some Kubernetes RBAC permissions look harmless but let the holder become someone more powerful: list on Secrets, create on Pods, get on nodes/proxy, and the escalate, bind and impersonate verbs among them. This guide lists the 11 the Kubernetes project flags and gives a tested script that finds them in your bindings.</description><enclosure url="https://firewallsync.com/posts/kubernetes-rbac-audit-11-permissions-that-escalate-access/cover_hu683712424518613144.jpg" type="image/jpeg" length="0"/><media:content url="https://firewallsync.com/posts/kubernetes-rbac-audit-11-permissions-that-escalate-access/cover_hu683712424518613144.jpg" medium="image" type="image/jpeg" width="1200" height="630"/><content:encoded><![CDATA[<p><img src="https://firewallsync.com/posts/kubernetes-rbac-audit-11-permissions-that-escalate-access/cover_hu683712424518613144.jpg" alt="A heap of old rusty iron and steel keys of many shapes and sizes in bright sunlight" width="1200" height="630"></p><p>Kubernetes RBAC is usually audited by looking for <code>cluster-admin</code> bindings. That misses the permissions that don&rsquo;t look like admin but lead there: a service account that can list Secrets, a CI identity that can create Pods, a monitoring agent with <code>get</code> on <code>nodes/proxy</code>. The Kubernetes project documents these escalation paths on its RBAC Good Practices page. This guide turns that list into an audit you can run.</p>
<p><strong>Scope.</strong> Based on the Kubernetes v1.37 documentation pages &ldquo;Role Based Access Control Good Practices&rdquo;, &ldquo;Using RBAC Authorization&rdquo; and &ldquo;Authorization&rdquo;, read from the kubernetes/website repository on October 22, 2026. The audit script was tested with Python 3.13 on a sample JSON file we wrote; we did not run it against a live cluster.</p>
<h2 id="the-11-escalation-risks">The 11 escalation risks</h2>
<p>The RBAC Good Practices page lists these under &ldquo;privilege escalation risks&rdquo;. The &ldquo;why&rdquo; column paraphrases the documentation.</p>
<table>
  <thead>
      <tr>
          <th>#</th>
          <th>Permission</th>
          <th>Why it escalates</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>1</td>
          <td><code>get</code>, <code>list</code> or <code>watch</code> on <code>secrets</code></td>
          <td>All three reveal Secret contents; a list response includes every Secret&rsquo;s data</td>
      </tr>
      <tr>
          <td>2</td>
          <td>Creating Pods or workload resources (Deployments, Jobs and so on)</td>
          <td>Pods can mount the namespace&rsquo;s Secrets, ConfigMaps and volumes and run as any service account in the namespace; privileged Pods can reach the node</td>
      </tr>
      <tr>
          <td>3</td>
          <td><code>create</code> on <code>persistentvolumes</code></td>
          <td>Allows <code>hostPath</code> volumes, which expose the node&rsquo;s file system</td>
      </tr>
      <tr>
          <td>4</td>
          <td>Any access to <code>nodes/proxy</code></td>
          <td>Reaches the kubelet API, which can execute commands in every pod on the node, bypassing audit logging and admission control. <code>get</code> alone is enough</td>
      </tr>
      <tr>
          <td>5</td>
          <td><code>escalate</code> on <code>roles</code> or <code>clusterroles</code></td>
          <td>Lets the holder write roles with permissions it does not have</td>
      </tr>
      <tr>
          <td>6</td>
          <td><code>bind</code> on roles</td>
          <td>Lets the holder bind roles with permissions it does not have</td>
      </tr>
      <tr>
          <td>7</td>
          <td><code>impersonate</code></td>
          <td>Lets the holder act as other users, groups or service accounts</td>
      </tr>
      <tr>
          <td>8</td>
          <td><code>create</code> on <code>certificatesigningrequests</code> plus <code>update</code> on <code>certificatesigningrequests/approval</code></td>
          <td>With the <code>kubernetes.io/kube-apiserver-client</code> signer, can mint client certificates with arbitrary names, including system component names</td>
      </tr>
      <tr>
          <td>9</td>
          <td><code>create</code> on <code>serviceaccounts/token</code></td>
          <td>Issues tokens for existing service accounts</td>
      </tr>
      <tr>
          <td>10</td>
          <td>Control of <code>validatingwebhookconfigurations</code> or <code>mutatingwebhookconfigurations</code></td>
          <td>Webhooks can read every admitted object; mutating webhooks can change them</td>
      </tr>
      <tr>
          <td>11</td>
          <td><code>patch</code> on <code>namespaces</code></td>
          <td>Can relabel a namespace, which can loosen Pod Security Admission or widen NetworkPolicy access</td>
      </tr>
  </tbody>
</table>
<p>Two points deserve emphasis.</p>
<p><strong>Read is not always read-only.</strong> The documentation states plainly that <code>get</code> on <code>nodes/proxy</code> &ldquo;is not a read-only permission&rdquo;, because the kubelet APIs can be reached with websocket <code>GET</code> requests. Monitoring tools sometimes request it. If one of yours does, find out exactly why. There is often a narrower option. The kubelet maps <code>/metrics</code>, <code>/stats</code> and <code>/logs</code> to their own subresources (<code>nodes/metrics</code>, <code>nodes/stats</code>, <code>nodes/log</code>), so a collector that only reads those needs no <code>nodes/proxy</code>. On recent versions, kubelet fine-grained authorization (the <code>KubeletFineGrainedAuthz</code> feature, beta and on by default from v1.33, stable in v1.36) adds the same for <code>/pods</code>, <code>/runningPods</code>, <code>/healthz</code> and <code>/configz</code>, checking <code>nodes/pods</code>, <code>nodes/healthz</code> or <code>nodes/configz</code> before falling back to <code>nodes/proxy</code>.</p>
<p><strong>Pod creation is a namespace-wide grant.</strong> Anyone who can create a Pod can choose which service account it runs as and which Secrets it mounts. The documentation concludes that &ldquo;boundaries within a namespace should be considered weak&rdquo; and recommends enforcing the Baseline or Restricted Pod Security Standard where you don&rsquo;t fully trust the creator. See <a href="/posts/kubernetes-pod-security-admission-namespace-labels-modes-and-a-safe-rollout-from-warn-to-enforce/">our Pod Security Admission rollout guide</a>.</p>
<h2 id="two-problems-a-rolebinding-review-wont-catch">Two problems a RoleBinding review won&rsquo;t catch</h2>
<ul>
<li><strong><code>system:masters</code>.</strong> Members of this group bypass all RBAC checks, and that cannot be revoked by removing RoleBindings or ClusterRoleBindings. If an authorization webhook is in use, they bypass that too. Membership comes from the credential itself (for example a client certificate&rsquo;s organization field), so look at how credentials are issued, not at bindings.</li>
<li><strong>Wildcards.</strong> <code>*</code> in resources or verbs grants rights not only to every resource type that exists now but to every type created in the future, for example by a new CRD (CustomResourceDefinition).</li>
</ul>
<p>The documentation also warns about deleted users: if an attacker can create an account with the same name as a deleted user, they inherit any bindings that still name it. Remove bindings when you remove people.</p>
<h2 id="how-the-built-in-guardrails-work">How the built-in guardrails work</h2>
<p>RBAC does have an anti-escalation check. Per the RBAC reference, you can only create or update a role if you already hold all of its permissions at the same scope, or have <code>escalate</code> on roles. You can only create or update a role binding if you already hold all of the referenced role&rsquo;s permissions, or have <code>bind</code> on that role. That is why <code>escalate</code> and <code>bind</code> are on the list: they are the switches that turn the guardrail off.</p>
<p>The documentation shows a legitimate, narrow use of <code>bind</code>: letting a team lead grant only the built-in <code>admin</code>, <code>edit</code> and <code>view</code> ClusterRoles, by listing them in <code>resourceNames</code>. Without <code>resourceNames</code>, <code>bind</code> covers every role.</p>
<h2 id="a-script-to-find-risky-grants">A script to find risky grants</h2>
<p>The script below reads the JSON that kubectl produces for roles and bindings, and prints one line per subject per risky finding. It reports wildcards once instead of listing every risk they imply, and it skips cluster-scoped resources (such as <code>nodes/proxy</code> or <code>persistentvolumes</code>) when the grant comes through a RoleBinding, because the RBAC reference says those permissions only take effect through a ClusterRoleBinding.</p>
<p>Export the data first:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>kubectl get clusterroles,clusterrolebindings,roles,rolebindings -A -o json &gt; rbac.json
</span></span><span style="display:flex;"><span>python3 rbac_audit.py rbac.json
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> json<span style="color:#f92672">,</span> sys
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># (resource, verbs, why) - from the Kubernetes &#34;RBAC Good Practices&#34; page</span>
</span></span><span style="display:flex;"><span>RISKY <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;secrets&#34;</span>, {<span style="color:#e6db74">&#34;get&#34;</span>, <span style="color:#e6db74">&#34;list&#34;</span>, <span style="color:#e6db74">&#34;watch&#34;</span>}, <span style="color:#e6db74">&#34;reads Secret contents&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;pods&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;workload creation: mounts Secrets, runs as any ServiceAccount in the namespace&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;deployments&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>, <span style="color:#e6db74">&#34;patch&#34;</span>}, <span style="color:#e6db74">&#34;workload creation&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;daemonsets&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>, <span style="color:#e6db74">&#34;patch&#34;</span>}, <span style="color:#e6db74">&#34;workload creation&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;statefulsets&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>, <span style="color:#e6db74">&#34;patch&#34;</span>}, <span style="color:#e6db74">&#34;workload creation&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;jobs&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;workload creation&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;cronjobs&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;workload creation&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;persistentvolumes&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;hostPath volumes give node filesystem access&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;nodes/proxy&#34;</span>, {<span style="color:#e6db74">&#34;get&#34;</span>, <span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;kubelet API: exec into pods, bypasses audit and admission&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;roles&#34;</span>, {<span style="color:#e6db74">&#34;escalate&#34;</span>}, <span style="color:#e6db74">&#34;can write roles with rights it does not hold&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;clusterroles&#34;</span>, {<span style="color:#e6db74">&#34;escalate&#34;</span>}, <span style="color:#e6db74">&#34;can write roles with rights it does not hold&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;roles&#34;</span>, {<span style="color:#e6db74">&#34;bind&#34;</span>}, <span style="color:#e6db74">&#34;can bind roles with rights it does not hold&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;clusterroles&#34;</span>, {<span style="color:#e6db74">&#34;bind&#34;</span>}, <span style="color:#e6db74">&#34;can bind roles with rights it does not hold&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;users&#34;</span>, {<span style="color:#e6db74">&#34;impersonate&#34;</span>}, <span style="color:#e6db74">&#34;acts as other users&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;groups&#34;</span>, {<span style="color:#e6db74">&#34;impersonate&#34;</span>}, <span style="color:#e6db74">&#34;acts as other groups&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;serviceaccounts&#34;</span>, {<span style="color:#e6db74">&#34;impersonate&#34;</span>}, <span style="color:#e6db74">&#34;acts as service accounts&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;certificatesigningrequests/approval&#34;</span>, {<span style="color:#e6db74">&#34;update&#34;</span>}, <span style="color:#e6db74">&#34;with CSR create, can mint client certificates&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;serviceaccounts/token&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>}, <span style="color:#e6db74">&#34;issues tokens for existing service accounts&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;validatingwebhookconfigurations&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>, <span style="color:#e6db74">&#34;patch&#34;</span>}, <span style="color:#e6db74">&#34;sees every admitted object&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;mutatingwebhookconfigurations&#34;</span>, {<span style="color:#e6db74">&#34;create&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>, <span style="color:#e6db74">&#34;patch&#34;</span>}, <span style="color:#e6db74">&#34;sees and changes every admitted object&#34;</span>),
</span></span><span style="display:flex;"><span>    (<span style="color:#e6db74">&#34;namespaces&#34;</span>, {<span style="color:#e6db74">&#34;patch&#34;</span>, <span style="color:#e6db74">&#34;update&#34;</span>}, <span style="color:#e6db74">&#34;can relabel namespaces (Pod Security, NetworkPolicy selectors)&#34;</span>),
</span></span><span style="display:flex;"><span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># A RoleBinding cannot grant access to cluster-scoped resources.</span>
</span></span><span style="display:flex;"><span>CLUSTER_SCOPED <span style="color:#f92672">=</span> {<span style="color:#e6db74">&#34;persistentvolumes&#34;</span>, <span style="color:#e6db74">&#34;nodes/proxy&#34;</span>, <span style="color:#e6db74">&#34;clusterroles&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#e6db74">&#34;certificatesigningrequests/approval&#34;</span>, <span style="color:#e6db74">&#34;users&#34;</span>, <span style="color:#e6db74">&#34;groups&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#e6db74">&#34;validatingwebhookconfigurations&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#e6db74">&#34;mutatingwebhookconfigurations&#34;</span>, <span style="color:#e6db74">&#34;namespaces&#34;</span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">findings</span>(rule, namespaced_binding):
</span></span><span style="display:flex;"><span>    res, verbs <span style="color:#f92672">=</span> set(rule<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;resources&#34;</span>, [])), set(rule<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;verbs&#34;</span>, []))
</span></span><span style="display:flex;"><span>    out <span style="color:#f92672">=</span> []
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;*&#34;</span> <span style="color:#f92672">in</span> res <span style="color:#f92672">or</span> <span style="color:#e6db74">&#34;*&#34;</span> <span style="color:#f92672">in</span> verbs:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> [<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;wildcard resources=</span><span style="color:#e6db74">{</span>sorted(res)<span style="color:#e6db74">}</span><span style="color:#e6db74"> verbs=</span><span style="color:#e6db74">{</span>sorted(verbs)<span style="color:#e6db74">}</span><span style="color:#e6db74">: &#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;covers current and future resource types&#34;</span>]
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r, risky_verbs, why <span style="color:#f92672">in</span> RISKY:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> namespaced_binding <span style="color:#f92672">and</span> r <span style="color:#f92672">in</span> CLUSTER_SCOPED:
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> r <span style="color:#f92672">in</span> res <span style="color:#f92672">and</span> verbs <span style="color:#f92672">&amp;</span> risky_verbs:
</span></span><span style="display:flex;"><span>            out<span style="color:#f92672">.</span>append(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>r<span style="color:#e6db74">}</span><span style="color:#e6db74"> </span><span style="color:#e6db74">{</span>sorted(verbs <span style="color:#f92672">&amp;</span> risky_verbs)<span style="color:#e6db74">}</span><span style="color:#e6db74">: </span><span style="color:#e6db74">{</span>why<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> out
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">main</span>(path):
</span></span><span style="display:flex;"><span>    items <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>load(open(path))[<span style="color:#e6db74">&#34;items&#34;</span>]
</span></span><span style="display:flex;"><span>    roles <span style="color:#f92672">=</span> {}
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> o <span style="color:#f92672">in</span> items:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> o[<span style="color:#e6db74">&#34;kind&#34;</span>] <span style="color:#f92672">in</span> (<span style="color:#e6db74">&#34;Role&#34;</span>, <span style="color:#e6db74">&#34;ClusterRole&#34;</span>):
</span></span><span style="display:flex;"><span>            ns <span style="color:#f92672">=</span> o[<span style="color:#e6db74">&#34;metadata&#34;</span>]<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;namespace&#34;</span>, <span style="color:#e6db74">&#34;&#34;</span>)
</span></span><span style="display:flex;"><span>            roles[(o[<span style="color:#e6db74">&#34;kind&#34;</span>], ns, o[<span style="color:#e6db74">&#34;metadata&#34;</span>][<span style="color:#e6db74">&#34;name&#34;</span>])] <span style="color:#f92672">=</span> o<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;rules&#34;</span>) <span style="color:#f92672">or</span> []
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> b <span style="color:#f92672">in</span> items:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> b[<span style="color:#e6db74">&#34;kind&#34;</span>] <span style="color:#f92672">not</span> <span style="color:#f92672">in</span> (<span style="color:#e6db74">&#34;RoleBinding&#34;</span>, <span style="color:#e6db74">&#34;ClusterRoleBinding&#34;</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>        ref <span style="color:#f92672">=</span> b[<span style="color:#e6db74">&#34;roleRef&#34;</span>]
</span></span><span style="display:flex;"><span>        bns <span style="color:#f92672">=</span> b[<span style="color:#e6db74">&#34;metadata&#34;</span>]<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;namespace&#34;</span>, <span style="color:#e6db74">&#34;&#34;</span>)
</span></span><span style="display:flex;"><span>        key <span style="color:#f92672">=</span> (ref[<span style="color:#e6db74">&#34;kind&#34;</span>], bns <span style="color:#66d9ef">if</span> ref[<span style="color:#e6db74">&#34;kind&#34;</span>] <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;Role&#34;</span> <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#34;&#34;</span>, ref[<span style="color:#e6db74">&#34;name&#34;</span>])
</span></span><span style="display:flex;"><span>        nsb <span style="color:#f92672">=</span> b[<span style="color:#e6db74">&#34;kind&#34;</span>] <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;RoleBinding&#34;</span>
</span></span><span style="display:flex;"><span>        hits <span style="color:#f92672">=</span> sorted({f <span style="color:#66d9ef">for</span> rule <span style="color:#f92672">in</span> roles<span style="color:#f92672">.</span>get(key, []) <span style="color:#66d9ef">for</span> f <span style="color:#f92672">in</span> findings(rule, nsb)})
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> hits:
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>        scope <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;cluster-wide&#34;</span> <span style="color:#66d9ef">if</span> b[<span style="color:#e6db74">&#34;kind&#34;</span>] <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;ClusterRoleBinding&#34;</span> <span style="color:#66d9ef">else</span> <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;namespace </span><span style="color:#e6db74">{</span>bns<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> s <span style="color:#f92672">in</span> b<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;subjects&#34;</span>) <span style="color:#f92672">or</span> []:
</span></span><span style="display:flex;"><span>            who <span style="color:#f92672">=</span> <span style="color:#e6db74">f</span><span style="color:#e6db74">&#39;</span><span style="color:#e6db74">{</span>s[<span style="color:#e6db74">&#34;kind&#34;</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74"> </span><span style="color:#e6db74">{</span>s<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;namespace&#34;</span>, <span style="color:#e6db74">&#34;&#34;</span>) <span style="color:#f92672">+</span> <span style="color:#e6db74">&#34;/&#34;</span> <span style="color:#66d9ef">if</span> s<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#34;namespace&#34;</span>) <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#34;&#34;</span><span style="color:#e6db74">}{</span>s[<span style="color:#e6db74">&#34;name&#34;</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74">&#39;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> h <span style="color:#f92672">in</span> hits:
</span></span><span style="display:flex;"><span>                print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>who<span style="color:#e6db74">}</span><span style="color:#e6db74"> | </span><span style="color:#e6db74">{</span>ref[<span style="color:#e6db74">&#39;kind&#39;</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74"> </span><span style="color:#e6db74">{</span>ref[<span style="color:#e6db74">&#39;name&#39;</span>]<span style="color:#e6db74">}</span><span style="color:#e6db74"> | </span><span style="color:#e6db74">{</span>scope<span style="color:#e6db74">}</span><span style="color:#e6db74"> | </span><span style="color:#e6db74">{</span>h<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> __name__ <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;__main__&#34;</span>:
</span></span><span style="display:flex;"><span>    main(sys<span style="color:#f92672">.</span>argv[<span style="color:#ae81ff">1</span>])
</span></span></code></pre></div><p>We ran it on a sample file with five bindings: a CI service account with a ClusterRole that can patch Deployments and list Secrets cluster-wide; a namespaced &ldquo;release&rdquo; Role with Pod creation and <code>bind</code>; a read-only debug Role; a monitoring agent bound through a RoleBinding to a ClusterRole with <code>get</code> on <code>nodes/proxy</code>; and a user with a full wildcard ClusterRole. Output:</p>
<pre tabindex="0"><code>ServiceAccount build/ci | ClusterRole ci-deployer | cluster-wide | deployments [&#39;patch&#39;]: workload creation
ServiceAccount build/ci | ClusterRole ci-deployer | cluster-wide | secrets [&#39;list&#39;]: reads Secret contents
ServiceAccount payments/release-bot | Role release | namespace payments | pods [&#39;create&#39;]: workload creation: mounts Secrets, runs as any ServiceAccount in the namespace
ServiceAccount payments/release-bot | Role release | namespace payments | roles [&#39;bind&#39;]: can bind roles with rights it does not hold
User alice@example.com | ClusterRole platform-admin | cluster-wide | wildcard resources=[&#39;*&#39;] verbs=[&#39;*&#39;]: covers current and future resource types
</code></pre><p>The read-only debug Role produced nothing, as intended, and the <code>nodes/proxy</code> grant was correctly skipped because a RoleBinding cannot grant a cluster-scoped resource. Had it been a ClusterRoleBinding, it would have been reported.</p>
<p><strong>Known limits of the script.</strong> It ignores <code>apiGroups</code> (a CRD that reuses a name like <code>jobs</code> would be flagged), does not evaluate <code>resourceNames</code> restrictions, flags <code>update</code> and <code>patch</code> on workloads as well as <code>create</code>, does not cover every workload type (for example ReplicaSets), and does not see <code>system:masters</code> membership or permissions granted by authorizers other than RBAC. Treat its output as a review list, not a verdict.</p>
<h2 id="confirming-a-finding">Confirming a finding</h2>
<p>For any subject the script flags, check what it can actually do. The Kubernetes authorization documentation shows <code>kubectl auth can-i</code> combined with impersonation:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>kubectl auth can-i list secrets --namespace payments <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  --as system:serviceaccount:build:ci
</span></span></code></pre></div><p>You need impersonation rights to run that, which is itself item 7 on the list. Keep those rights with a small group of administrators.</p>
<h2 id="fixing-what-you-find">Fixing what you find</h2>
<p>From the Good Practices page, plus our notes:</p>
<ul>
<li><strong>Prefer RoleBindings to ClusterRoleBindings,</strong> so rights stay inside one namespace.</li>
<li><strong>Replace wildcards</strong> with explicit resources and verbs.</li>
<li><strong>Give powerful service accounts to as few Pods as possible,</strong> and keep those Pods off nodes that run untrusted or internet-facing workloads, using taints and tolerations or affinity rules.</li>
<li><strong>Turn off token automounting</strong> where a workload doesn&rsquo;t call the API, with <code>automountServiceAccountToken: false</code> on the ServiceAccount or Pod; the Pod setting takes precedence.</li>
<li><strong>Review bindings for <code>system:unauthenticated</code>,</strong> which give access to anyone who can reach the API server.</li>
<li><strong>Use <code>resourceNames</code></strong> to limit <code>bind</code> and <code>impersonate</code> to specific roles or identities.</li>
<li><strong>Review periodically,</strong> and remove bindings for departed users and retired service accounts.</li>
</ul>
<p>The same least-privilege thinking applies to cloud IAM; <a href="/posts/how-to-find-overprivileged-aws-iam-users-and-roles/">our guide to finding overprivileged AWS IAM users and roles</a> covers that side. Namespace labels also drive network isolation, which is why item 11 matters for <a href="/posts/kubernetes-networkpolicy-default-deny-safe-rollout/">NetworkPolicy default deny</a>.</p>
<h2 id="limits-of-this-article">Limits of this article</h2>
<p>The list of risks is the Kubernetes project&rsquo;s; it is not exhaustive for every add-on or CRD in your cluster, many of which define their own sensitive resources. The script was tested on sample data only. Managed Kubernetes services add their own identity layers (for example cloud IAM mappings) that are outside this article.</p>
<h2 id="sources-and-verification">Sources and verification</h2>
<p>Checked on October 22, 2026.</p>
<table>
  <thead>
      <tr>
          <th>Important claim</th>
          <th>Source</th>
          <th>Verification</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>The 11 privilege-escalation risks and their explanations; nodes/proxy get is not read-only; namespace boundaries are weak; system:masters bypasses RBAC; wildcard and deleted-user warnings; hardening advice</td>
          <td><a href="https://kubernetes.io/docs/concepts/security/rbac-good-practices/">Kubernetes: RBAC Good Practices</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Role creation and binding restrictions; escalate and bind; resourceNames example; cluster-scoped resources need a ClusterRoleBinding</td>
          <td><a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">Kubernetes: Using RBAC Authorization</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Kubelet path-to-subresource mapping; fine-grained authorization endpoints; feature stages (beta default-on from v1.33, stable v1.36)</td>
          <td><a href="https://kubernetes.io/docs/reference/access-authn-authz/kubelet-authn-authz/">Kubernetes: Kubelet authentication/authorization</a> and the KubeletFineGrainedAuthz feature-gate page</td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Client certificates can carry group memberships in their organization fields</td>
          <td><a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/">Kubernetes: Authenticating</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td><code>kubectl auth can-i</code> with <code>--as</code> for service accounts</td>
          <td><a href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/">Kubernetes: Authorization</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td><code>automountServiceAccountToken: false</code>; Pod setting takes precedence</td>
          <td><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/">Kubernetes: Configure Service Accounts for Pods</a></td>
          <td>Verified</td>
      </tr>
      <tr>
          <td>Script output</td>
          <td>Run by us on October 22, 2026 with Python 3.13 on a five-binding sample file</td>
          <td>Verified on sample data; not run on a live cluster</td>
      </tr>
  </tbody>
</table>
]]></content:encoded></item></channel></rss>