个人网站设计企业,2017年免费建网站,佛山教育平台网站建设,网站怎么加ico点击上方蓝字关注 #x1f446;#x1f446;↓推荐关注↓随着 Kubernetes 越来越受欢迎#xff0c;门槛也越来越低。但是安全问题仍然存在#xff0c;下面介绍两个审计集群安全的开源工具。kube-benchkube-bench[1] 是一个 Go 应用程序#xff0c;拥有 4.5k star。用于检查… 点击上方蓝字关注 ↓推荐关注↓随着 Kubernetes 越来越受欢迎门槛也越来越低。但是安全问题仍然存在下面介绍两个审计集群安全的开源工具。kube-benchkube-bench[1] 是一个 Go 应用程序拥有 4.5k star。用于检查 Kubernetes 集群是否符合CIS Kubernetes Benchmark[2]指南。CIS互联网安全中心。这是一个非营利组织利用来自社区的反馈来解决网络安全问题。建立一个免受网络攻击的环境的建议列表。这些建议包括寻找过于宽松的配置文件权限、集群组件的潜在风险设置、识别未受保护的帐户以及检查常规网络策略。通过配置 YAML 文件进行测试这样做的好处是该工具很容易随着测试的规范化而更新。运行运行 kube-bench 有多种方法[3]docker 容器运行在 Kubernetes 集群中运行在 AKS 集群中运行在 EKS 集群中运行在 OpenShift 上运行在 GKE 集群中运行在 ACK 集群中运行下面演示在 Docker 容器中运行 Kube-bench。它需要访问主机的 PID 名称空间以便检查正在运行的进程以及访问主机上配置文件等。docker run --rm --pidhost -v /etc:/etc:ro -v /var/lib/etcd:/var/lib/etcd:ro -v /var/lib/kubelet/config.yaml:/var/lib/kubelet/config.yaml:ro -v $(which kubectl):/usr/local/mount-from-host/bin/kubectl -v $HOME/.kube:/.kube -e KUBECONFIG/.kube/config -it aquasec/kube-bench:latest run运行后会输出检查报告该报告分为五个主题块从标题中即可看出主节点安全配置Etcd 节点配置控制平面配置工作节点安全配置Kubernetes Policy针对 Master Node 的配置文件检查结果如下[INFO] 1 Master Node Security Configuration
[INFO] 1.1 Master Node Configuration Files
[PASS] 1.1.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Automated)
# 省略
[FAIL] 1.1.7 Ensure that the etcd pod specification file permissions are set to 644 or more restrictive (Automated)
[FAIL] 1.1.8 Ensure that the etcd pod specification file ownership is set to root:root (Automated) Remediations master
1.1.7 Run the below command (based on the file location on your system) on the master node.
For example,
chmod 644 /etc/kubernetes/manifests/etcd.yaml1.1.8 Run the below command (based on the file location on your system) on the master node.
For example,
chown root:root /etc/kubernetes/manifests/etcd.yaml针对 Etcd 的检查[INFO] 2 Etcd Node Configuration
[INFO] 2 Etcd Node Configuration Files
[FAIL] 2.1 Ensure that the --cert-file and --key-file arguments are set as appropriate (Automated)
[FAIL] 2.2 Ensure that the --client-cert-auth argument is set to true (Automated) Remediations etcd
2.1 Follow the etcd service documentation and configure TLS encryption.
Then, edit the etcd pod specification file /etc/kubernetes/manifests/etcd.yaml
on the master node and set the below parameters.
--cert-file/path/to/ca-file
--key-file/path/to/key-file2.2 Edit the etcd pod specification file /etc/kubernetes/manifests/etcd.yaml on the master
node and set the below parameter.
--client-cert-authtrue检查结果为FAIL、WARN的会对应序号给出修改方案。但是修改方案是否试用于你的集群需要自行综合去判断应该全面了解修改会对集群产生什么影响。kube-hunter[4]是一个 Python 工具旨在发现 Kubernetes 集群中的漏洞。它从攻击者的角度评估集群安全。拥有 3.5K star。运行二进制容器Pod下面演示使用 docker 容器运行。docker run -it --rm --network host aquasec/kube-hunter运行之后需要选择扫描方式Choose one of the options below:
1. Remote scanning (scans one or more specific IPs or DNS names)
2. Interface scanning (scans subnets on all local network interfaces)
3. IP range scanning (scans a given IP range)远程扫描要指定远程机器进行扫描选项 1 或使用--remote选项容器方式运行docker run --rm aquasec/kube-hunter --remote 192.168.28.72接口扫描要指定接口扫描可以使用--interface选项这将扫描机器的所有网络接口容器方式运行docker run --rm aquasec/kube-hunter --interface网段扫描要指定要扫描的特定 CIDR使用--cidr选项容器方式运行docker run --rm aquasec/kube-hunter --cidr 192.168.0.0/24以下是运行检查之后输出的报告---------------------------------------------------------------------------------------------------------------------
| KHV002 | 192.168.28.154:6443 | Initial Access // | K8s Version | The kubernetes | v1.19.8 |
| | | Exposed sensitive | Disclosure | version could be | |
| | | interfaces | | obtained from the | |
| | | | | /version endpoint | |
---------------------------------------------------------------------------------------------------------------------
| KHV052 | 192.168.28.194:10255| Discovery // Access | Exposed Pods | An attacker could | count: 9 |
| | | Kubelet API | | view sensitive | |
| | | | | information about | |
| | | | | pods that are | |
| | | | | bound to a Node | |
| | | | | using the /pods | |
| | | | | endpoint | |
---------------------------------------------------------------------------------------------------------------------列出两个漏洞攻击者可以通过/version获取到 k8s 的版本攻击者可以通过/pods接口获取到集群节点上运行的 Pod 数量。Kubernetes 节点自动发现设置--k8s-auto-discover-nodes标志查询 Kubernetes 集群中的所有节点然后尝试扫描所有节点。默认情况下它将使用集群内配置[5]连接到 Kubernetes API。如果您想使用显式 kubeconfig 文件请设置--kubeconfig /root/.kube/kubeconfig.查看命令帮助可以运行# docker run -it --rm --network host aquasec/kube-hunter --helpkube-hunter 是用于 Kubernetes 集群渗透测试的可选择工具。它易于安装和运行并展示集群在攻击者视角的样子。但输出的报告没有修复方案提示需要运维人员自行评估方案。结论这两个实用程序都非常成熟且易于上手并提供了集群安全性的良好描述。尽管存在一些缺陷但对关注集群安全的人来说它们是一个不错的选择。安全性不仅限于集群配置让容器中运行的应用程序保持最新状态、防止未经授权访问镜像注册表、使用安全网络协议、监控应用程序活动等也同样值得注意。其他可选工具除了这两个分析工具。 kubescape [6]也是值得推荐的选择。Kubescape 提供了风险分析、安全合规、RBAC 可视化工具和镜像漏洞扫描等功能截至目前已有超过 5.1K star。参考资料[1]kube-bench: https://github.com/aquasecurity/kube-bench[2]CIS Kubernetes Benchmark: https://www.cisecurity.org/benchmark/kubernetes/[3]多种方法: https://github.com/aquasecurity/kube-bench/blob/main/docs/running.md[4]kube-hunter: https://github.com/aquasecurity/kube-hunter[5]集群内配置: https://kubernetes.io/docs/reference/access-authn-authz/rbac/[6]kubescape : https://github.com/armosec/kubescape[7]Kubernetes cluster security assessment with kube-bench and kube-hunter: https://blog.flant.com/kubernetes-security-with-kube-bench-and-kube-hunter/我发起一个抽奖欢迎您的参与后台回复“加群”带你进入高手如云交流群欢迎小伙伴们投稿原创文章~投稿格式markdown格式的md文件投稿邮箱: pubkubeinfo.cn推荐阅读一款强大的Kubernetes API流量查看神器Argo CD 发现高危漏洞对 K8s 有何影响Golang 从零搭建 LevelDB为什么云中的容器可以成为攻击者的天堂52 张图万字讲解 Linux建议收藏Win11将迎来首次重大更新终于要支持安卓应用了快叫女朋友来一起看烟花了超漂亮22 款必备的命令行生产力工具提高效率全靠它了有了这篇 Shell 脚本实践指南同事对我“刮目相看”全网粉丝20W的头部大号专注云原生、Golang、Linux实用脚本效率工具免费CSDN下载回复【golang】获取近 6 万 Star的资源回复【1024】获取全种类IT资料回复【红包封面】获取超好看封面回复【加群】进入高手如云技术交流群分享、点赞和在看支持我们分享更多好文章谢谢点击“阅读原文”查看更多 点个在看集群永保稳定