Introducing kube-hunter: an Open Source Tool for Discovering Security Issues in Kubernetes Clusters
Take a look at this tool that can be used to determine if there are any concerning security flaws in your Kubernetes cluster.
Join the DZone community and get the full member experience.
Join For FreeAqua Security has been actively participating in the open source community around Kubernetes security, including contributing significantly to the kube-bench project. We have followed that up with the release of the kube-hunter project, named for its ability to hunt for security weaknesses in Kubernetes clusters. Kube-hunter enables Kubernetes administrators, operators and security teams to identify weaknesses in their deployments and address those issues before attackers can exploit them.
Kube-hunter augments the CIS validation for K8s deployments provided by kube-bench with discovery and penetration testing capabilities. In that respect it works much like an automated penetration testing tool — you give it the IP or DNS name of your Kubernetes cluster, and it will probe for security issues and alert you, for example, if your dashboard is open or your kubelets are accessible. Use kube-hunter to find Kubernetes installations in your environments, assess them for potential security risks, and receive suggestions on remediation for a wide range of vulnerabilities.
Running kube-hunter
The kube-hunter code is open source and Aqua also provides a containerized version to make it easy to run. The containerized version works in conjunction with Aqua’s kube-hunter website where it’s easy to view and share the results. The container includes this source code, plus an additional (closed source) reporting plugin for uploading results into a report that can be viewed at kube-hunter.aquasec.com. Note that running the aquasec/kube-hunter container and uploading reports data are subject to additional terms and conditions.
After navigating to the Aqua kube-hunter site, enter your email address to receive a Docker command to run that includes a token. Copy that command and run it anywhere you have Docker installed, and you’ll be prompted for the address of the cluster to test against. After the tests run you’ll see a unique URL (associated with that token) for viewing the results, which you can send to anyone else who needs to see the results.
By default kube-hunter will run “passive hunters” only. This is a series of tests that probe for potential access points (like open ports) within your cluster. “Active hunting” can potentially do state-changing operations on the cluster, which could be harmful, so use this with care.
To turn on “active hunting” simply, add the --active
parameter when starting kube-hunter. This enables some additional tests that will attempt to leverage any weaknesses found with the passive hunter. Active hunters are intended to give an indication of what an attacker might be able to do. While we don’t intend for any of these tests to do anything destructive, you should exercise caution as they could potentially change the state of the cluster or the code running within it. As an example, here is an active hunter which attempts to exec into a container and run uname
within it.
Be Responsible!
Never use kube-hunter on other people’s clusters. It is possible to use this code to probe other sites, however, this is explicitly forbidden by the terms & conditions.
You will find a list of the tests that have been implemented so far on the kube-hunter site or by running kube-hunter with the --list
parameter. It is not yet comprehensive, but it does have a good range of hunters that have the potential to uncover many common issues.
The underlying test code (which you can also run without using the web site) is open source, and Aqua welcomes feedback, ideas and contributions, especially new hunter modules that perform additional tests.
Published at DZone with permission of Liz Rice. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments