aquasecurity / kube-bench

Checks whether Kubernetes is deployed according to security best practices as defined in the CIS Kubernetes Benchmark
Apache License 2.0
6.97k stars 1.21k forks source link

Overhaul of K3s scans #1659

Closed dereknola closed 6 days ago

dereknola commented 1 month ago

Background

Verification

k3s-cis-1.24

Tested on v1.24.17+k3s1 with the following config.yaml (standard hardening config from docs)

#/etc/rancher/k3s/config.yaml
cluster-init: true
protect-kernel-defaults: true
secrets-encryption: true
kube-controller-manager-arg:
  - 'terminated-pod-gc-threshold=10'
kubelet-arg:
  - 'streaming-connection-idle-timeout=5m'
  - 'make-iptables-util-chains=true'
  - 'event-qps=0'
  - "tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
kube-apiserver-arg:
  - 'audit-log-path=/var/lib/rancher/k3s/server/logs/audit.log'
  - 'audit-policy-file=/var/lib/rancher/k3s/server/audit.yaml'
  - 'audit-log-maxage=30'
  - 'audit-log-maxbackup=10'
  - 'audit-log-maxsize=100'
  - 'enable-admission-plugins=NodeRestriction,NamespaceLifecycle,ServiceAccount,PodSecurityPolicy'
Master PR
image image

k3s-cis-1.7

Tested on v1.25+k3s4 with the following config.yaml (standard hardening config from docs)

cluster-init: true
protect-kernel-defaults: true
secrets-encryption: true
kube-controller-manager-arg:
  - 'terminated-pod-gc-threshold=10'
kubelet-arg:
  - 'streaming-connection-idle-timeout=5m'
  - 'make-iptables-util-chains=true'
  - 'event-qps=0'
  - "tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
kube-apiserver-arg:
  - 'audit-log-path=/var/lib/rancher/k3s/server/logs/audit.log'
  - 'audit-policy-file=/var/lib/rancher/k3s/server/audit.yaml'
  - 'audit-log-maxage=30'
  - 'audit-log-maxbackup=10'
  - 'audit-log-maxsize=100'
  - 'admission-control-config-file=/var/lib/rancher/k3s/server/psa.yaml'
Master PR
image image

k3s-cis-1.8

Tested on v1.28.11+k3s1 with the same config as k3s-cis-1.7 image

Note: CIS-1.9 scans are on the TODO for RKE2 and K3s, they should be incoming within the next month or two.

dereknola commented 3 weeks ago

@chen-keinan can I get a review/merge on this when you have time.

mozillazg commented 3 weeks ago

@chen-keinan can I get a review/merge on this when you have time.

@dereknola Unfortunately, Chen is no longer working on aquasecurity. We are waiting for a new aquasecurity team member who has permission to review/merge PRs. That may take more than one week.

deven0t commented 1 week ago

Hi @itaysk can you help merging this PR. Thanks cc @sm171190

deven0t commented 1 week ago

@dereknola we need to rebase this branch. Please do it, so it can be merged

itaysk commented 1 week ago

@afdesk can you please look at this and merge?

afdesk commented 1 week ago

yes, sure. I took a look at this PR.