Skip to main content

A comprehensive Kubernetes security auditing tool

Project description

Kubenumerate

Enumerate your target Kubernetes cluster with just 1 command! :eyes:

Motivation

  • Concerned about your Kubernetes cluster's security?
  • Are you going to use tools like kubeaudit, kube-bench, and trivy anyway?
  • Do you want all done for you with one lazy command and exported to excel?

Enter kubenumerate!

With just 1 command it will locate or install (with permission) all the necessary tools, enumerate the whole current context, spit out a spreadsheet containing any juicy info and raise some found issues to the CLI. A handy containerised version is released in case you don't want to pollute the system with access to the target cluster's Kubernetes API with these tools, more info below in the containerised version section.

Currently included tools:

Usage

┌──(subtle㉿SubtleLabs)-[~]
└─# kubenumerate -h

             +-----+  1. -----
            /     /|  2. -----
           +-----+ |  3. -----
           |     | +  4. -----
           |     |/  5. -----
           +-----+  6. -----
             Kubenumerate
          By 0x5ubt13 v2.0.3

usage: kubenumerate.py [-h] [--cheatsheet] [--dry-run] [--excel-out EXCEL_OUT] [--files FILES] [--kubeconfig KUBECONFIG]
                   [--namespace NAMESPACE] [--output OUTPUT] [--trivy-file TRIVY_FILE] [--verbosity VERBOSITY]
                   [--skip-summary] [--summary-output SUMMARY_OUTPUT]

Uses local kubeconfig file to launch kubectl, trivy and KubiScan and parses all useful output to excel.

options:
-h, --help              show this help message and exit
--cheatsheet, -c        Print commands to extract info from the cluster and work offline
--dry-run, -d           Don't contact the Kubernetes API - do all work locally
--excel-out EXCEL_OUT, -e EXCEL_OUT
                        Select a different name for your excel file. Default: kubenumerate_results_v1_0.xlsx
--files FILES, -f FILES
                        Instruct Kubenumerate to use an already generated kubectl_output directory with all the necessary files to work
                        offline (pods.json, deployments.json, etc). Forces --dry-run mode.
--kubeconfig KUBECONFIG, -k KUBECONFIG
                        Select a specific Kubeconfig file you want to use
--namespace NAMESPACE, -n NAMESPACE
                        Select a specific namespace to test, if your scope is restricted. Default: -A
--output OUTPUT, -o OUTPUT
                        Select a different directory for all the output. Default: '/tmp/kubenumerate_out/'
--trivy-file TRIVY_FILE, -t TRIVY_FILE
                        Run trivy from a pods dump in json instead of running kubectl using your kubeconfig file
--verbosity VERBOSITY, -v VERBOSITY
                        Select a verbosity level. (0 = quiet | 1 = default | 2 = verbose/debug)
--skip-summary, -s      Skip generating the summary table in Microsoft Word format (generated by default)
--summary-output SUMMARY_OUTPUT
                        Specify the path for the summary Word document. Default: {output_dir}/kubenumerate_summary.docx

Installation (pipx ✨)

pipx install kubenumerate

Installation (from source)

git clone https://github.com/0x5ubt13/kubenumerate.git && \ 
cd kubenumerate && \ 
python3 -m venv venv && \ 
source venv/bin/activate && \ 
python -m pip install . && \ 
kubenumerate -h

Note: kubenumerate orchestrates external tools such as kubectl, kubeaudit, kube-bench, trivy, kubiscan, jq, and wget. When you run it, it can prompt to install missing tools, but you can also install them manually beforehand.

Examples

Run using your kubeconfig file (simply call the script!)

kubenumerate

Run locally using extracted pods.json (no kubeconfig file needed)

kubenumerate -o ./kubenumerate_out/dev_cluster -t pods-dev.json --dry-run

Skip the summary table generation (only generate Excel)

kubenumerate --skip-summary

Specify custom path for summary document

kubenumerate --summary-output /path/to/my_report.docx

Output

Kubenumerate generates two types of output:

1. Detailed Excel Workbook (Default: kubenumerate_results_v1_0.xlsx)

Contains detailed findings across multiple sheets:

  • AppArmor - AppArmor profile issues
  • Automount SA - Service account token automounting issues
  • Capabilities - Linux capabilities configurations
  • Deprecated API - Deprecated Kubernetes API usage
  • Host Namespace - Host PID/Network namespace usage
  • Limits - Resource limits configuration
  • Mounts - Sensitive path mounts
  • Network Policies - Network policy configurations
  • Non Root - RunAsNonRoot configurations
  • Privilege Escalation - allowPrivilegeEscalation settings
  • Privileged - Privileged containers
  • Root Filesystem - Read-only root filesystem settings
  • Seccomp - Seccomp profile configurations
  • Vulnerable Images - Container images with CVEs (from Trivy)

2. Word Summary Table (Default: kubenumerate_summary.docx) - Generated Automatically

A concise, executive-friendly summary showing:

  • Namespace - Where the workload is deployed
  • Workload - Name of the resource
  • Type - Resource kind (Deployment, DaemonSet, StatefulSet, Job, CronJob)
  • Issues - List of security/config issues affecting the workload

Features:

  • Excludes ephemeral Pods (shows parent controllers only)
  • Intelligent ReplicaSet deduplication (avoids showing Deployment-managed ReplicaSets)
  • Professional formatting with colored headers and alternating row colors
  • Summary statistics at the bottom

To skip summary generation: Use --skip-summary or -s flag

Containerised version

If you don't want to install everything in your system, a containerised version is available at Docker Hub: gagarter/kubenumerate.

You will need to mount your kubeconfig file inside the container, along with any cloud file or env variable needed for the container to authenticate to a CSP, then mount the desired output directory inside the container, and after running, it will dump all the output in the mounted directory.

A basic example of how can this be done:

# Create directory and prepare kubeconfig file and out directory
mkdir /tmp/kubenumerate_out
cp ~/.kube/config /tmp/config
chmod a+r /tmp/config
chmod a+w /tmp/kubenumerate_out

# Run the program
docker run \
    --network host \
    --name kubenumerate \
    -v /tmp/config:/home/subtle/.kube/config \
    --mount type=bind,source=/tmp/kubenumerate_out,target=/tmp/kubenumerate_out \
    gagarter/kubenumerate

# Clean up
printf "Removing container -> "; docker rm kubenumerate
rm /tmp/config

or, if you're using PowerShell on Windows:

# Create directory and prepare kubeconfig file and out directory
New-Item -Path "C:\tmp\kubenumerate_out" -ItemType Directory
Copy-Item -Path "$env:USERPROFILE\.kube\config" -Destination "C:\tmp\config"
icacls "C:\tmp\config" /grant Everyone:R
icacls "C:\tmp\kubenumerate_out" /grant Everyone:W

# Run the program
docker run `
    --network host `
    --name kubenumerate `
    -v C:\tmp\config:/home/subtle/.kube/config `
    --mount type=bind,source=C:\tmp\kubenumerate_out,target=/tmp/kubenumerate_out `
    gagarter/kubenumerate

# Clean up
Write-Output "Removing container -> "; docker rm kubenumerate
Remove-Item -Path "C:\tmp\config"

If you want to build the image yourself, simply clone the repo, cd into it, make any changes you want to the source code and use docker build:

git clone https://github.com/0x5ubt13/kubenumerate.git
cd kubenumerate
# Edit the repo as you like, then:
docker build -t gagarter/kubenumerate:your_custom_tag .

Other enumeration tools you might be interested in

I developed a fully automated enumeration tool that performs infrastructure scans, which gained some traction but needs feedback, so feel free to try GitHub - 0x5ubt13/Enumeraga if you're going to play a CTF (single target scan) or do an infra job (subnet range scan).

To Do

  • Add verbose flag
  • Containerise
  • Offer the user to install all reqs for them
  • Clear all TODOs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubenumerate-2.1.5.tar.gz (79.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubenumerate-2.1.5-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

Details for the file kubenumerate-2.1.5.tar.gz.

File metadata

  • Download URL: kubenumerate-2.1.5.tar.gz
  • Upload date:
  • Size: 79.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kubenumerate-2.1.5.tar.gz
Algorithm Hash digest
SHA256 bc7f904406f255a470545ae07143f8168a2e6b9a3b9911183574e0ea808ffad2
MD5 262a427794de904d745f730246e5986a
BLAKE2b-256 cbdd3feae3983770700565a281069a84e4bea44af4d24935fc7a1147f77bff5b

See more details on using hashes here.

File details

Details for the file kubenumerate-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: kubenumerate-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 62.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kubenumerate-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe6cca6c3e3795ea2ae78c8167acf75ea5416051b8c0f5c2215ebd30313a3ff
MD5 57b11248c62e44dead2f626370b4c26c
BLAKE2b-256 4e4feaec3a2047a04c2feac30486d4d844cdf42c999af4879495ec61b3b96b1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page