github.com/khulnasoft-lab/kube-bench@v0.2.1-0.20240330183753-9df52345ae58/cfg/cis-1.6-k3s/node.yaml (about) 1 --- 2 controls: 3 version: "cis-1.6-k3s" 4 id: 4 5 text: "Worker Node Security Configuration" 6 type: "node" 7 groups: 8 - id: 4.1 9 text: "Worker Node Configuration Files" 10 checks: 11 - id: 4.1.1 12 text: "Ensure that the kubelet service file permissions are set to 644 or more restrictive (Not Applicable)" 13 scored: false 14 15 - id: 4.1.2 16 text: "Ensure that the kubelet service file ownership is set to root:root (Not Applicable)" 17 scored: false 18 19 - id: 4.1.3 20 text: "If proxy kubeproxy.kubeconfig file exists ensure permissions are set to 644 or more restrictive (Automated)" 21 audit: stat -c %a $proxykubeconfig 22 tests: 23 bin_op: or 24 test_items: 25 - flag: "permissions" 26 set: true 27 compare: 28 op: bitmask 29 value: "644" 30 - flag: "$proxykubeconfig" 31 set: false 32 remediation: | 33 Run the below command (based on the file location on your system) on the each worker node. 34 For example, 35 chmod 644 $proxykubeconfig 36 scored: true 37 38 - id: 4.1.4 39 text: "Ensure that the proxy kubeconfig file ownership is set to root:root (Automated)" 40 audit: '/bin/sh -c ''if test -e $proxykubeconfig; then stat -c %U:%G $proxykubeconfig; fi'' ' 41 tests: 42 bin_op: or 43 test_items: 44 - flag: root:root 45 - flag: "$proxykubeconfig" 46 set: false 47 remediation: | 48 Run the below command (based on the file location on your system) on the each worker node. 49 For example, chown root:root $proxykubeconfig 50 scored: true 51 52 - id: 4.1.5 53 text: "Ensure that the --kubeconfig kubelet.conf file permissions are set to 644 or more restrictive (Automated)" 54 audit: '/bin/sh -c ''if test -e $kubeletkubeconfig; then stat -c permissions=%a $kubeletkubeconfig; fi'' ' 55 tests: 56 test_items: 57 - flag: "permissions" 58 compare: 59 op: bitmask 60 value: "644" 61 remediation: | 62 By default, K3s creates $kubeletkubeconfig with 644 permissions. No manual remediation needed. 63 scored: true 64 65 - id: 4.1.6 66 text: "Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root (Automated)" 67 audit: '/bin/sh -c ''if test -e $kubeletkubeconfig; then stat -c %U:%G $kubeletkubeconfig; fi'' ' 68 tests: 69 test_items: 70 - flag: root:root 71 remediation: | 72 By default, K3s creates $kubeletkubeconfig with root:root ownership. No manual remediation needed. 73 scored: true 74 75 - id: 4.1.7 76 text: "Ensure that the certificate authorities file permissions are set to 644 or more restrictive (Automated)" 77 audit: stat -c permissions=%a $kubeletcafile 78 tests: 79 test_items: 80 - flag: "permissions" 81 compare: 82 op: bitmask 83 value: "644" 84 remediation: | 85 By default, K3s creates $kubeletcafile with 644 permissions. 86 scored: true 87 88 - id: 4.1.8 89 text: "Ensure that the client certificate authorities file ownership is set to root:root (Automated)" 90 audit: stat -c %U:%G $kubeletcafile 91 tests: 92 test_items: 93 - flag: root:root 94 compare: 95 op: eq 96 value: root:root 97 remediation: | 98 By default, K3s creates $kubeletcafile with root:root ownership. 99 scored: true 100 101 - id: 4.1.9 102 text: "Ensure that the kubelet --config configuration file has permissions set to 644 or more restrictive (Not Applicable)" 103 scored: false 104 105 - id: 4.1.10 106 text: "Ensure that the kubelet --config configuration file ownership is set to root:root (Not Applicable)" 107 scored: false 108 109 - id: 4.2 110 text: "Kubelet" 111 checks: 112 - id: 4.2.1 113 text: "Ensure that the anonymous-auth argument is set to false (Automated)" 114 audit: journalctl -u k3s | grep "Running kube-apiserver" | tail -n1 | grep "anonymous-auth" 115 tests: 116 test_items: 117 - flag: "--anonymous-auth" 118 compare: 119 op: eq 120 value: false 121 remediation: | 122 By default, K3s starts kubelet with --anonymous-auth set to false. No manual remediation needed. 123 scored: true 124 125 - id: 4.2.2 126 text: "Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated)" 127 audit: journalctl -u k3s | grep "Running kube-apiserver" | tail -n1 | grep "authorization-mode" 128 tests: 129 test_items: 130 - flag: --authorization-mode 131 compare: 132 op: nothave 133 value: AlwaysAllow 134 remediation: | 135 K3s starts kubelet with Webhook as the value for the --authorization-mode argument. No manual remediation needed. 136 scored: true 137 138 - id: 4.2.3 139 text: "Ensure that the --client-ca-file argument is set as appropriate (Automated)" 140 audit: journalctl -u k3s | grep "Running kube-apiserver" | tail -n1 | grep "client-ca-file" 141 tests: 142 test_items: 143 - flag: --client-ca-file 144 remediation: | 145 By default, K3s starts the kubelet process with the --client-ca-file. No manual remediation needed. 146 scored: true 147 148 - id: 4.2.4 149 text: "Ensure that the --read-only-port argument is set to 0 (Automated)" 150 audit: journalctl -u k3s | grep "Running kubelet" | tail -n1 | grep "read-only-port" 151 tests: 152 bin_op: or 153 test_items: 154 - flag: "--read-only-port" 155 compare: 156 op: eq 157 value: 0 158 - flag: "--read-only-port" 159 set: false 160 remediation: | 161 By default, K3s starts the kubelet process with the --read-only-port argument set to 0. 162 scored: false 163 164 - id: 4.2.5 165 text: "Ensure that the --streaming-connection-idle-timeout argument is not set to 0 (Automated)" 166 audit: journalctl -u k3s | grep "Running kubelet" | tail -n1 | grep "streaming-connection-idle-timeout" 167 tests: 168 test_items: 169 - flag: --streaming-connection-idle-timeout 170 compare: 171 op: noteq 172 value: 0 173 - flag: --streaming-connection-idle-timeout 174 set: false 175 bin_op: or 176 remediation: | 177 By default, K3s does not set --streaming-connection-idle-timeout when starting kubelet. 178 scored: true 179 180 - id: 4.2.6 181 text: "Ensure that the --protect-kernel-defaults argument is set to true (Automated)" 182 audit: journalctl -u k3s | grep "Running kubelet" | tail -n1 | grep "protect-kernel-defaults" 183 tests: 184 test_items: 185 - flag: --protect-kernel-defaults 186 compare: 187 op: eq 188 value: true 189 remediation: | 190 K3s server needs to be started with the following, --protect-kernel-defaults=true. 191 scored: true 192 193 - id: 4.2.7 194 text: "Ensure that the --make-iptables-util-chains argument is set to true (Automated)" 195 audit: journalctl -u k3s | grep "Running kubelet" | tail -n1 | grep "make-iptables-util-chains" 196 tests: 197 test_items: 198 - flag: --make-iptables-util-chains 199 compare: 200 op: eq 201 value: true 202 - flag: --make-iptables-util-chains 203 set: false 204 bin_op: or 205 remediation: | 206 K3s server needs to be run with the following, --kube-apiserver-arg='make-iptables-util-chains=true'. 207 scored: true 208 209 - id: 4.2.8 210 text: "Ensure that the --hostname-override argument is not set (Not Applicable)" 211 scored: false 212 213 - id: 4.2.9 214 text: "Ensure that the --event-qps argument is set to 0 or a level which ensures appropriate event capture (Manual)" 215 audit: /bin/ps -fC containerd 216 tests: 217 test_items: 218 - flag: --event-qps 219 compare: 220 op: eq 221 value: 0 222 remediation: | 223 If using a Kubelet config file, edit the file to set eventRecordQPS: to an appropriate level. 224 If using command line arguments, edit the kubelet service file 225 $kubeletsvc on each worker node and 226 set the below parameter in KUBELET_SYSTEM_PODS_ARGS variable. 227 Based on your system, restart the kubelet service. For example: 228 systemctl daemon-reload 229 systemctl restart kubelet.service 230 scored: false 231 232 - id: 4.2.10 233 text: "Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate (Manual)" 234 audit: journalctl -u k3s | grep "Running kubelet" | tail -n1 | grep -E 'tls-cert-file|tls-private-key-file' 235 tests: 236 test_items: 237 - flag: --tls-cert-file 238 - flag: --tls-private-key-file 239 remediation: | 240 By default, K3s sets the --tls-cert-file and --tls-private-key-file arguments when executing the kubelet process. 241 scored: false 242 243 - id: 4.2.11 244 text: "Ensure that the --rotate-certificates argument is not set to false (Not Applicable)" 245 scored: false 246 247 - id: 4.2.12 248 text: "Verify that the RotateKubeletServerCertificate argument is set to true (Not Applicable)" 249 scored: false 250 251 - id: 4.2.13 252 text: "Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers (Not Applicable)" 253 scored: false