ReynardSec<p>A grumpy ItSec guy walks through the office #2</p><p>devops0: dude, we've got so many roles in this cluster my terminal buffer runs out when I try to list them all.<br>devops1: bro, if it works, don't touch.<br>devops0: sure, but neither I nor anyone else on the project knows who can access what...</p><p>ItSec (walking by): just use rbac-tool and review this... </p><p>devops1: r... rba... what?<br>devops0: rbac-tool probably or smth</p><p>--</p><p>It's always a good moment to verify who can do what in your Kubernetes cluster.</p><p>For basic checks, use native kubectl:</p><p>1) Can "I" read secrets?</p><p>kubectl auth can-i get secrets</p><p>2) To check another identity's permissions (e.g., a ServiceAccount) run:</p><p>kubectl auth can-i get secrets --as=system:serviceaccount:somenamespace:someserviceaccount</p><p>However, this approach will not work for complex environments. There's a more effective way to do this with rbac-tool [2]. It gives you cluster-wide visibility with simple commands. Check this:</p><p>1) Who can do a specific thing? For example: who in the entire cluster can read Secrets?</p><p>rbac-tool who-can get secrets</p><p>2) Run an RBAC health check - global analysis with risk hints (wildcards in RBAC, overly broad permissions, cross-namespace binds, etc)</p><p>rbac-tool analysis</p><p>3) Visualize the mess - produce an interactive map of roles, bindings, etc:</p><p>rbac-tool visualize</p><p>This command writes a report to rbac.html in the current directory.</p><p>Alternatives to rbac-tool like rakkess [3] can offer similar "who can" insights, though it may not be actively maintained.</p><p>Stay (more) safe!</p><p>[1] <a href="https://kubernetes.io/docs/reference/kubectl/generated/kubectl_auth/kubectl_auth_can-i/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">kubernetes.io/docs/reference/k</span><span class="invisible">ubectl/generated/kubectl_auth/kubectl_auth_can-i/</span></a><br>[2] <a href="https://github.com/alcideio/rbac-tool" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="">github.com/alcideio/rbac-tool</span><span class="invisible"></span></a><br>[3] <a href="https://github.com/corneliusweig/rakkess" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/corneliusweig/rakke</span><span class="invisible">ss</span></a></p><p><a href="https://infosec.exchange/tags/devops" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>devops</span></a> <a href="https://infosec.exchange/tags/programming" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>programming</span></a> <a href="https://infosec.exchange/tags/webdev" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>webdev</span></a> <a href="https://infosec.exchange/tags/cybersecurity" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>cybersecurity</span></a> <a href="https://infosec.exchange/tags/infosec" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>infosec</span></a> <a href="https://infosec.exchange/tags/sysadmin" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>sysadmin</span></a> <a href="https://infosec.exchange/tags/kubernetes" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>kubernetes</span></a> <a href="https://infosec.exchange/tags/containers" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>containers</span></a></p>