RBACLens is a powerful CLI tool for auditing and analyzing Kubernetes RBAC (Role-Based Access Control) resources. It helps cluster administrators and security teams identify risky RBAC configurations, visualize permissions, and ensure best practices are followed.
It is also intended to be used by people trying to learn more about RBAC rules on K8s
- Fetch RBAC resources: Retrieve Roles, ClusterRoles, RoleBindings, and ClusterRoleBindings from a Kubernetes cluster and save them to a JSON file for offline analysis.
- Audit for risky configurations: Analyze RBAC resources using built-in rules to detect overly permissive or dangerous settings.
- Flexible input: Audit live from a cluster or from previously saved JSON files.
Comprehensive documentation for each command, including usage, flags, and examples, is available here.
- Go 1.16 or higher
Pre-built binaries for Linux, macOS, and Windows are available on the GitHub Releases page.
- Go to the releases page.
- Download the appropriate binary for your OS and architecture.
- Move the binary to a directory in your
PATH(e.g.,~/bin,~/.local/bin, or/usr/local/bin). - (Optional) Rename the binary to
rbaclensfor convenience. This makes it easier to run the tool from the terminal.
Linux:
mv RBACLens-linux-amd64 ~/bin/rbaclens
chmod +x ~/bin/rbaclensmacOS:
mv RBACLens-darwin-amd64 /usr/local/bin/rbaclens
chmod +x /usr/local/bin/rbaclensYou can install RBACLens directly using Go (requires Go 1.16+):
go install github.com/flushthemoney/RBACLens@latestThis will place the binary (named RBACLens by default) in your $GOPATH/bin, $GOBIN, or $HOME/go/bin directory.
Add Go bin directory to your PATH:
-
Bash / Zsh:
export PATH="$PATH:$HOME/go/bin"
Add the above line to your
~/.bashrcor~/.zshrc. -
Fish shell:
set -U fish_user_paths $fish_user_paths $HOME/go/bin
Symlink for Convenience:
If the binary is named RBACLens, you may want to symlink it to rbaclens:
ln -sf "$HOME/go/bin/RBACLens" "$HOME/go/bin/rbaclens"After this, you can use the rbaclens command as described below.
- Clone the repository:
git clone https://github.com/flushthemoney/RBACLens.git
- Navigate to the project directory:
cd RBACLens - Build the binary:
go build -o rbaclens main.go
- Fetch RBAC Resources: Use the
fetchcommand to collect RBAC resources from your cluster. See the fetch documentation for details. - Audit RBAC Resources: Use the
ruleauditcommand to analyze RBAC resources for risky configurations. See the ruleaudit documentation for details.
For more information on all commands and advanced usage, refer to the complete documentation.