基礎(chǔ)介紹
- 為了保證集群以及容器應(yīng)用的安全,Kubernetes 提供了多種安全機(jī)制,限制容器的行為,減少容器和集群的攻擊面,保證整個(gè)系統(tǒng)的安全性。
- 互聯(lián)網(wǎng)安全中心(CIS,Center for Internet Security),是一個(gè)非盈利組織,致力為互聯(lián)網(wǎng)提供免費(fèi)的安全防御解決方案
- 官網(wǎng):https://www.cisecurity.org/
- k8s安全基準(zhǔn):https://www.cisecurity.org/benchmark/kubernetes
kube-beach介紹
- Kube-bench是容器安全廠商Aquq推出的工具,以CIS K8s基準(zhǔn)作為基礎(chǔ),來檢查K8s是否安全部署。
- 主要查找不安全的配置參數(shù)、敏感的文件權(quán)限、不安全的帳戶或公開端口等等。
- 開源地址:https://github.com/aquasecurity/kube-bench
- 二進(jìn)制包下載地址:https://github.com/aquasecurity/kube-bench/releases
- 大家根據(jù)需求下載相應(yīng)版本
kube-beach 下載
百度網(wǎng)盤下載
鏈接:https://pan.baidu.com/s/17AGxkwTDUkiDYSSZpPu45A?pwd=vqew
提取碼:vqew
–來自百度網(wǎng)盤超級(jí)會(huì)員V7的分享
wget下載
wget https://github.com/aquasecurity/kube-bench/releases/download/v0.6.19/kube-bench_0.6.19_linux_amd64.tar.gz
kube-beach安裝
- 解壓
tar -zxf kube-bench_0.6.19_linux_amd64.tar.gz
- 創(chuàng)建默認(rèn)配置路徑
mkdir -p /etc/kube-bench
- 復(fù)制配置文件至默認(rèn)目錄
mv cfg /etc/kube-bench/cfg
- 設(shè)置為系統(tǒng)命令
mv kube-bench /usr/bin/
kube-beach使用
基礎(chǔ)參數(shù)
-
使用kube-bench run進(jìn)行測(cè)試,該指令有以下常用參數(shù)
-
–targets 指定要基礎(chǔ)測(cè)試的目標(biāo),默認(rèn)配置目標(biāo)包括:master, controlplane, node, etcd, policies
-
–version:指定k8s版本,如果未指定會(huì)自動(dòng)檢測(cè)
-
–benchmark:手動(dòng)指定CIS基準(zhǔn)版本,不能與–version一起使用
-
查看幫助信息
kube-bench --help
配置信息解讀
- 在該目錄下 /etc/kube-bench/cfg
- 該版本默認(rèn)使用 cis-1.7
- 也支持其他 云廠商的驗(yàn)證基準(zhǔn) 【ack-1.0 容器服務(wù) Kubernetes 版 ACK】
示例
- 檢查master組件安全配置
kube-bench run --targets=master
修復(fù)建議
文章來源:http://www.zghlxwxcb.cn/news/detail-737870.html
修復(fù)一個(gè)安全漏洞【1.2.18】
- 安全漏洞
[FAIL] 1.2.18 Ensure that the --profiling argument is set to false (Automated)
- 修復(fù)建議
1.2.18 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
on the control plane node and set the below parameter.
--profiling=false
- 編輯 kube-apiserver.yaml ,增加 --profiling=false
- 修改完后 kube-apiserver 靜態(tài)pod進(jìn)行重啟
- 已通過安全掃描
結(jié)果說明
- [PASS]:測(cè)試通過
- [FAIL]:測(cè)試未通過,重點(diǎn)關(guān)注,在測(cè)試結(jié)果會(huì)給出修復(fù)建議
- [WARN]:警告,可做了解
- [INFO]:信息
- 大家可以根據(jù)實(shí)際情況,推薦的修復(fù)方案進(jìn)行實(shí)際的修復(fù)措施。
kube-beach跳過漏洞
- kube-beach 所有掃描出來的漏洞不一定需要全部修復(fù),如果需要跳過我們需要修改kube-beach的漏洞定義配置文件
漏洞定義
[FAIL] 1.4.1 Ensure that the --profiling argument is set to false (Automated)
- 在 /etc/kube-bench/cfg/cis-1.23【具體k8s版本】 目錄編輯 master.yaml
- 找到 1.4.1 配置信息
- id: 1.4.1
text: "Ensure that the --profiling argument is set to false (Automated)"
audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep"
tests:
test_items:
- flag: "--profiling"
compare:
op: eq
value: false
remediation: |
Edit the Scheduler pod specification file $schedulerconf file
on the control plane node and set the below parameter.
--profiling=false
scored: true
漏洞定義yaml說明
- id:編號(hào)
- text:提示的文本
- tests:測(cè)試項(xiàng)目
- remediation:修復(fù)方案
- scored:如果為true,kube-bench無法正常測(cè)試,則會(huì)生成FAIL,如果為false,無法正常測(cè)試,則會(huì)生成WARN。
- type:如果為manual則會(huì)生成WARN,如果為skip,則會(huì)生成INFO
漏洞生成為INFO
文章來源地址http://www.zghlxwxcb.cn/news/detail-737870.html
- 修改后的yaml
- id: 1.4.1
text: "Ensure zhangzihao that the --profiling argument is set to false (Automated)"
audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep"
tests:
test_items:
- flag: "--profiling"
compare:
op: eq
value: false
remediation: |
Edit the Scheduler pod specification file $schedulerconf file
on the control plane node and set the below parameter.
--profiling=false
scored: true
type: "skip"
到了這里,關(guān)于【云原生-K8s】Kubernetes安全組件CIS基準(zhǔn)kube-beach安裝及使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!