
Benchmarking Kubernetes with kube-bench
FreeEnsure your Kubernetes cluster meets CIS compliance standards.
Free · Opens the source repo
What Benchmarking Kubernetes with kube-bench does
The Benchmarking Kubernetes with kube-bench skill enables you to run security compliance checks on your Kubernetes clusters using the kube-bench tool developed by Aqua Security. This tool assesses your cluster's configuration against the CIS Kubernetes Benchmark, which is a set of best practices for securing Kubernetes deployments. By running kube-bench, you can evaluate the security posture of your control-plane components, kubelet, and node configurations, receiving detailed reports that categorize each check as PASS, FAIL, WARN, or INFO. Recommendations for remediation are provided based on the CIS guidance, allowing you to address security issues effectively.
Kube-bench operates by executing a series of configuration-driven tests, which are defined in YAML files. This allows it to adapt to new Kubernetes versions and benchmark updates seamlessly. The skill supports various Kubernetes environments, including managed distributions like EKS, GKE, and AKS. The output is versatile, available in formats such as human-readable text, JSON, JUnit, and AWS Security Finding Format (ASFF), making it suitable for integration into CI/CD pipelines or compliance reporting.
This skill is particularly useful for security professionals and DevOps teams who need to establish a security baseline for new clusters, conduct periodic audits, or validate configurations after changes. By leveraging kube-bench, you can significantly reduce the attack surface of your Kubernetes deployments, which is crucial for maintaining a secure containerized environment. Whether you're preparing for compliance audits or simply aiming to enhance your cluster's security, this skill provides the necessary tools to achieve those goals.
When to use it
Use this skill when setting up a new Kubernetes cluster or conducting security audits to ensure compliance with the CIS benchmarks.
When not to use it
This skill may not be suitable for environments where Kubernetes is not used or for users unfamiliar with Kubernetes security practices.
What you can build with it
Establishing Security Baseline
Use kube-bench to set a security baseline for a new Kubernetes cluster, ensuring it meets CIS compliance from the start.
Periodic Compliance Audits
Run kube-bench regularly to audit existing clusters and verify compliance with the CIS Kubernetes Benchmark.
Remediation Validation
After applying security changes, re-run kube-bench to confirm that previous FAIL results have been resolved.
How to install Benchmarking Kubernetes with kube-bench
View source1. Install with the skills CLI
npx skills add mukul975/anthropic-cybersecurity-skills/benchmarking-kubernetes-with-kube-bench --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mukul975Benchmarking Kubernetes with kube-bench
Overview
kube-bench (by Aqua Security) is an open-source tool that checks whether a Kubernetes cluster is deployed securely by running the checks documented in the CIS Kubernetes Benchmark. It inspects the control-plane components (API server, controller manager, scheduler, etcd), the kubelet and worker-node configuration, and cluster-wide policy settings, then reports each check as PASS, FAIL, WARN, or INFO with a remediation recommendation drawn directly from the CIS guidance. Tests are configuration-driven YAML files, so kube-bench tracks new Kubernetes versions and benchmark revisions and supports managed distributions (EKS, GKE, AKS, ACK, OpenShift, RKE, k3s).
Hardening a cluster against the CIS Benchmark directly reduces the attack surface for T1610 (Deploy Container), where an adversary deploys a container to execute code or evade defenses — for example by abusing privileged containers, host namespaces, anonymous API access, or insecure kubelet settings that an unhardened cluster leaves exposed.
kube-bench can run as a standalone binary on a node, inside a container, or — most commonly — as a Kubernetes Job whose pod has the host filesystem mounted so it can read the relevant config files. Output is available as human-readable text, JSON, JUnit, or AWS Security Finding Format (ASFF) and can be pushed to a PostgreSQL database for trend tracking.
When to Use
- When establishing a security baseline for a new Kubernetes cluster against the CIS Kubernetes Benchmark.
- When performing periodic compliance audits of control-plane and node hardening.
- When validating remediation after applying hardening changes (re-run to confirm checks now PASS).
- When integrating cluster compliance scanning into CI/CD or a continuous monitoring pipeline.
- When preparing evidence for SOC 2, PCI DSS, or internal hardening compliance.
Prerequisites
- Access to the cluster: either SSH access to a control-plane/worker node (binary mode) or
kubectlwith permission to create Jobs (in-cluster mode). - Knowledge of the cluster's Kubernetes version (kube-bench auto-detects, or specify with
--version/--benchmark). - Install kube-bench (Aqua Security official methods):
# Binary release (Linux)
KB_VERSION=0.10.7
curl -L -o kube-bench.tgz \
"https://github.com/aquasecurity/kube-bench/releases/download/v${KB_VERSION}/kube-bench_${KB_VERSION}_linux_amd64.tar.gz"
tar -xzf kube-bench.tgz
sudo mv kube-bench /usr/local/bin/
sudo cp -R cfg /etc/kube-bench/cfg
# Via Go install
go install github.com/aquasecurity/kube-bench@latest
# Run as a one-off container directly on a node (mounts host config)
docker run --rm --pid=host \
-v /etc:/etc:ro -v /var:/var:ro \
-t docker.io/aquasec/kube-bench:latest run --targets node
# Verify
kube-bench version
Objectives
- Run kube-bench against the appropriate benchmark for the cluster's Kubernetes version.
- Scan control-plane (master), node, etcd, control-plane policies, and managed-service targets.
- Produce machine-readable JSON/JUnit output for pipelines and dashboards.
- Triage FAIL and WARN results and apply CIS remediation guidance.
- Re-run to validate that remediations now PASS.
MITRE ATT&CK Mapping
| Technique ID | Name | Tactic | Relevance |
|---|---|---|---|
| T1610 | Deploy Container | Execution / Defense Evasion | CIS Benchmark hardening enforced by kube-bench restricts privileged/host-namespace deployments, anonymous API access, and insecure kubelet settings that adversaries abuse when deploying malicious containers. |
Workflow
1. Run the default scan (auto-detect)
Run all applicable targets, letting kube-bench detect the Kubernetes version and benchmark:
sudo kube-bench
2. Run as a Kubernetes Job (in-cluster)
Apply the provided Job manifest from the kube-bench repo and read the results from the pod logs:
# General-purpose job
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml
# Wait, then retrieve results
kubectl get pods -l app=kube-bench
kubectl logs -l app=kube-bench
# Platform-specific jobs are available, e.g. EKS:
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job-eks.yaml
3. Target specific components
Use run --targets to scope the scan to particular component groups:
# Control-plane (API server, scheduler, controller manager)
sudo kube-bench run --targets master
# Worker node (kubelet, proxy)
sudo kube-bench run --targets node
# etcd datastore
sudo kube-bench run --targets etcd
# Cluster-wide policies (RBAC, pod security, network policy)
sudo kube-bench run --targets policies
# Combine multiple targets
sudo kube-bench run --targets master,node,etcd,policies
4. Pin a specific benchmark or Kubernetes version
When auto-detection is wrong or you must audit against a specific revision, pin the benchmark explicitly:
# Pin to a specific CIS benchmark revision
sudo kube-bench run --benchmark cis-1.8
# Or map by Kubernetes version
sudo kube-bench --version 1.27
# Managed/distribution-specific benchmarks
sudo kube-bench run --benchmark eks-1.5.0
sudo kube-bench run --benchmark gke-1.6.0
sudo kube-bench run --benchmark rke2-cis-1.7
5. Run or skip individual checks
Focus on or exclude specific check IDs during remediation cycles:
# Run only specific checks
sudo kube-bench run --targets master --check 1.2.1,1.2.2
# Skip noisy/known-accepted checks
sudo kube-bench run --targets node --skip 4.2.6
6. Produce machine-readable output
Emit JSON or JUnit for ingestion into pipelines, SIEM, or dashboards, and write to a file:
# JSON to a file
sudo kube-bench run --targets master,node --json --outputfile kube-bench-report.json
# JUnit (for CI test reporting)
sudo kube-bench --junit --outputfile kube-bench-junit.xml
# AWS Security Finding Format (for Security Hub)
sudo kube-bench run --targets node --asff
7. Triage and remediate FAIL/WARN findings
Each failing check prints a remediation. Apply the CIS-recommended fix on the node/manifest, for example tightening API server flags in the static pod manifest:
# Example remediation for a common control-plane FAIL:
# CIS 1.2.x — ensure anonymous-auth is disabled on the API server.
# Edit the static pod manifest and set the flag:
sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml
# - --anonymous-auth=false
# The kubelet restarts the static pod automatically.
# Example node remediation — kubelet config file permissions (CIS 4.1.x):
sudo chmod 600 /etc/kubernetes/kubelet/kubelet-config.json
sudo chown root:root /etc/kubernetes/kubelet/kubelet-config.json
8. Re-validate after remediation
Re-run the relevant target and confirm the previously failing checks now PASS, then track the score over time:
sudo kube-bench run --targets master --check 1.2.1 --json --outputfile recheck.json
# Optional: persist results to PostgreSQL for trend tracking
sudo kube-bench run --targets master,node --pgsql
Tools and Resources
| Tool / Resource | Purpose | Link |
|---|---|---|
| kube-bench | CIS Kubernetes Benchmark checker | https://github.com/aquasecurity/kube-bench |
| kube-bench docs | Running / platforms / flags | https://aquasecurity.github.io/kube-bench/ |
| CIS Kubernetes Benchmark | Source hardening standard | https://www.cisecurity.org/benchmark/kubernetes |
| Trivy Operator | Continuous in-cluster compliance + vuln scanning | https://github.com/aquasecurity/trivy-operator |
| kube-hunter | Complementary penetration-testing tool | https://github.com/aquasecurity/kube-hunter |
Validation Criteria
- kube-bench installed (
kube-bench version) or running as a Job. - Scan run against the correct benchmark for the cluster's Kubernetes version.
- master, node, etcd, and policies targets each scanned.
- JSON/JUnit output produced for pipeline/dashboard ingestion.
- FAIL and WARN findings triaged and prioritized.
- CIS remediation applied to control-plane manifests and node configs.
- Re-run confirms previously failing checks now PASS.
- Results tracked over time (file archive or PostgreSQL).
Frequently asked questions about Benchmarking Kubernetes with kube-bench
Similar skills
Data Breach Blast Radius Analyzer
Assess potential breach impacts before they occur.
Verify Agent Action
Ensure safe execution of AI agent actions with thorough reviews.
Agent Supply Chain Integrity
Ensure the integrity of AI agent plugins and tools.
Agent OWASP ASI Compliance Check
Ensure your AI agents meet OWASP ASI security standards.
Securing S3 Buckets
Enhance your S3 bucket security with AWS best practices.
AWS Account Enumeration with ScoutSuite
Assess AWS security posture with comprehensive audits.
