加固分析
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 运维部署
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- Linux
- 运行环境要求
- Node.js
- 检测到的文件与系统行为
-
- 只读
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Show only failures
kube-bench run --targets master | grep "\[FAIL\]"
# Run specific check
kube-bench run --check 1.2.1
# Run check group
kube-bench run --group 1.2
# Performing Kubernetes CIS Benchmark with kube-bench
## Overview
kube-bench is an open-source Go tool by Aqua Security that runs the CIS Kubernetes Benchmark checks. It verifies control plane, etcd, worker node, and policy configurations against security best practices, producing actionable pass/fail/warn reports.
## When to Use
- When conducting security assessments that involve performing kubernetes cis benchmark with kube bench
- When following incident response procedures for related security events
- When performing scheduled security testing or auditing activities
- When validating security controls through hands-on testing
## Prerequisites
- Kubernetes cluster (v1.24+)
- kubectl with cluster-admin access
- Node access for direct runs or privileged pod access
## Installation
```bash
# Binary installation
curl -L https://github.com/aquasecurity/kube-bench/releases/download/v0.7.3/kube-bench_0.7.3_linux_amd64.tar.gz | tar xz
sudo mv kube-bench /usr/local/bin/
# Run as Kubernetes Job
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml
kubectl logs job/kube-bench
# Run as a pod with host access
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job-master.yaml
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job-node.yaml
```
## Running Benchmarks
### Full Benchmark
```bash
# Run all checks (auto-detects node type)
kube-bench run
# Run with JSON output
kube-bench run --json > kube-bench-results.json
# Run with JUnit output for CI
kube-bench run --junit > kube-bench-results.xml
```
### Component-Specific Checks
```bash
# Control plane (master) checks
kube-bench run --targets master
# Worker node checks
kube-bench run --targets node
# etcd checks
kube-bench run --targets etcd
# Policies checks
kube-bench run --targets policies
# Control plane + etcd
kube-bench run --targets master,etcd
```
### Managed Kubernetes
```bash
# Amazon EKS
kube-bench run --benchmark eks-1.2.0
# Google GKE
kube-bench run --benchmark gke-1.4.0
# Azure AKS
kube-bench run --benchmark aks-1.0
# Red Hat OpenShift
kube-bench run --benchmark rh-1.0
```
### Filtering Results
```bash
# Show only failures
kube-bench run --targets master | grep "\[FAIL\]"
# Run specific check
kube-bench run --check 1.2.1
# Run check group
kube-bench run --group 1.2
```
## CIS Benchmark Sections
| Section | Component | Key Checks |
|---------|-----------|------------|
| 1.1 | Control Plane - API Server | Anonymous auth, RBAC, audit logging |
| 1.2 | Control Plane - API Server | Admission controllers, encryption |
| 1.3 | Control Plane - Controller Manager | Service account tokens, bind address |
| 1.4 | Control Plane - Scheduler | Profiling, bind address |
| 2.1 | etcd | Client cert auth, peer encryption |
| 3.1 | Control Plane - Authentication | OIDC, client certs |
| 4.1 | Worker - kubelet | Anonymous auth, authorization |
| 4.2 | Worker - kubelet | TLS, read-only port |
| 5.1 | Policies - RBAC | Cluster-admin usage, service accounts |
| 5.2 | Policies - Pod Security | Privileged, host namespaces |
| 5.3 | Policies - Network | Network policies per namespace |
| 5.7 | Policies - General | Secrets, security context |
## Output Example
```
[INFO] 1 Control Plane Security Configuration
[INFO] 1.1 Control Plane Node Configuration Files
[PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 600
[PASS] 1.1.2 Ensure that the API server pod specification file ownership is set to root:root
[FAIL] 1.1.3 Ensure that the controller manager pod specification file permissions are set to 600
[WARN] 1.1.4 Ensure that the scheduler pod specification file permissions are set to 600
== Summary ==
45 checks PASS
12 checks FAIL
8 checks WARN
0 checks INFO
```
## CI/CD Integration
### GitHub Actions
```yaml
name: kubernetes-hardening-kubernetes
on:
schedule:
- cron: '0 6 * * 1'
jobs:
kube-bench:
runs-on: ubuntu-latest
steps:
- name: Configure kubectl
uses: azure/setup-kubectl@v3
- name: Run kube-bench
run: |
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml
kubectl wait --for=condition=complete job/kube-bench --timeout=120s
kubectl logs job/kube-bench > kube-bench-report.txt
- name: Check for failures
run: |
FAILS=$(grep -c "\[FAIL\]" kube-bench-report.txt || true)
echo "Failed checks: $FAILS"
if [ "$FAILS" -gt 0 ]; then
echo "::warning::$FAILS CIS benchmark checks failed"
fi
- name: Upload report
uses: actions/upload-artifact@v4
with:
name: kube-bench-report
path: kube-bench-report.txt
```
## Remediation Examples
### 1.2.1 - Ensure --anonymous-auth is set to false
```yaml
# /etc/kubernetes/manifests/kube-apiserver.yaml
spec:
containers:
- command:
- kube-apiserver
- --anonymous-auth=false
```
### 4.2.1 - Ensure --anonymous-auth is set to false on kubelet
```yaml
# /var/libs/kubelet/config.yaml
authentication:
anonymous:
enabled: false
webhook:
enabled: true
```
### 5.2.1 - Minimize wildcard RBAC
```bash
# Find roles with wildcard permissions
kubectl get clusterroles -o json | jq '.items[] | select(.rules[].resources[] == "*") | .metadata.name'
```
## Best Practices
1. **Run kube-bench before and after** cluster provisioning
2. **Schedule weekly scans** via CronJob for drift detection
3. **Export JSON** for SIEM/compliance reporting
4. **Fix FAIL items first**, then address WARN items
5. **Use benchmark profiles** matching your Kubernetes distribution
6. **Track score over time** to measure security posture improvement
7. **Combine with admission controllers** to prevent drift
---
> Source: [DCx7C5/ai-marketplace](https://github.com/DCx7C5/ai-marketplace) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
章节与文件索引
按说明文件中的顺序排列。
概述
何时使用
先决条件
CIS 基准部分
最佳实践
文件/命令 -> pass/fail/warn · github.com/aquasecurity/kube-bench/releases/download/v0.7.3/kube-bench_0.7.3_linux_amd64.tar.gz · usr/local/bin · raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml · job/kube-bench · raw.githubusercontent.com/aquasecurity/kube-bench/main/job-master.yaml · raw.githubusercontent.com/aquasecurity/kube-bench/main/job-node.yaml · kube-bench-results.js
内容校验值 -> 8042fb19048c
当前原文的自动摘译,尚未人工审校。
概述
kube-bench 是 Aqua Security 的开源 Go 工具,可运行 CIS Kubernetes 基准检查。它根据安全最佳实践验证控制平面、etcd、工作节点和策略配置,生成可操作的通过/失败/警告报告。
何时使用
当进行涉及使用 kube bench 执行 kubernetes cis 基准测试的安全评估时 当遵循相关安全事件的事件响应程序时 当执行计划的安全测试或审核活动时 当通过实际测试验证安全控制时
先决条件
具有集群管理员访问权限的 Kubernetes 集群 (v1.24+) kubectl 用于直接运行或特权 pod 访问的节点访问权限
CIS 基准部分
部分 · 组件 · 关键检查 1.1 · 控制平面 - API 服务器 · 匿名身份验证、RBAC、审核日志记录 1.2 · 控制平面 - API 服务器 · 准入控制器、加密 1.3 · 控制平面 - 控制器管理器 · 服务帐户令牌、绑定地址 1.4 · 控制平面 - 调度程序 · 分析、绑定地址
最佳实践
在集群配置之前和之后运行 kube-bench 通过 CronJob 安排每周扫描以进行偏差检测 导出 JSON 以进行 SIEM/合规性报告 首先修复 FAIL 项目,然后解决 WARN 项目 使用与您的 Kubernetes 发行版匹配的基准配置文件