github.com/khulnasoft-lab/kube-bench@v0.2.1-0.20240330183753-9df52345ae58/cfg/cis-1.8/master.yaml (about) 1 --- 2 controls: 3 version: "cis-1.8" 4 id: 1 5 text: "Control Plane Security Configuration" 6 type: "master" 7 groups: 8 - id: 1.1 9 text: "Control Plane Node Configuration Files" 10 checks: 11 - id: 1.1.1 12 text: "Ensure that the API server pod specification file permissions are set to 600 or more restrictive (Automated)" 13 audit: "/bin/sh -c 'if test -e $apiserverconf; then stat -c permissions=%a $apiserverconf; fi'" 14 tests: 15 test_items: 16 - flag: "permissions" 17 compare: 18 op: bitmask 19 value: "600" 20 remediation: | 21 Run the below command (based on the file location on your system) on the 22 control plane node. 23 For example, chmod 600 $apiserverconf 24 scored: true 25 26 - id: 1.1.2 27 text: "Ensure that the API server pod specification file ownership is set to root:root (Automated)" 28 audit: "/bin/sh -c 'if test -e $apiserverconf; then stat -c %U:%G $apiserverconf; fi'" 29 tests: 30 test_items: 31 - flag: "root:root" 32 remediation: | 33 Run the below command (based on the file location on your system) on the control plane node. 34 For example, chown root:root $apiserverconf 35 scored: true 36 37 - id: 1.1.3 38 text: "Ensure that the controller manager pod specification file permissions are set to 600 or more restrictive (Automated)" 39 audit: "/bin/sh -c 'if test -e $controllermanagerconf; then stat -c permissions=%a $controllermanagerconf; fi'" 40 tests: 41 test_items: 42 - flag: "permissions" 43 compare: 44 op: bitmask 45 value: "600" 46 remediation: | 47 Run the below command (based on the file location on your system) on the control plane node. 48 For example, chmod 600 $controllermanagerconf 49 scored: true 50 51 - id: 1.1.4 52 text: "Ensure that the controller manager pod specification file ownership is set to root:root (Automated)" 53 audit: "/bin/sh -c 'if test -e $controllermanagerconf; then stat -c %U:%G $controllermanagerconf; fi'" 54 tests: 55 test_items: 56 - flag: "root:root" 57 remediation: | 58 Run the below command (based on the file location on your system) on the control plane node. 59 For example, chown root:root $controllermanagerconf 60 scored: true 61 62 - id: 1.1.5 63 text: "Ensure that the scheduler pod specification file permissions are set to 600 or more restrictive (Automated)" 64 audit: "/bin/sh -c 'if test -e $schedulerconf; then stat -c permissions=%a $schedulerconf; fi'" 65 tests: 66 test_items: 67 - flag: "permissions" 68 compare: 69 op: bitmask 70 value: "600" 71 remediation: | 72 Run the below command (based on the file location on your system) on the control plane node. 73 For example, chmod 600 $schedulerconf 74 scored: true 75 76 - id: 1.1.6 77 text: "Ensure that the scheduler pod specification file ownership is set to root:root (Automated)" 78 audit: "/bin/sh -c 'if test -e $schedulerconf; then stat -c %U:%G $schedulerconf; fi'" 79 tests: 80 test_items: 81 - flag: "root:root" 82 remediation: | 83 Run the below command (based on the file location on your system) on the control plane node. 84 For example, chown root:root $schedulerconf 85 scored: true 86 87 - id: 1.1.7 88 text: "Ensure that the etcd pod specification file permissions are set to 600 or more restrictive (Automated)" 89 audit: "/bin/sh -c 'if test -e $etcdconf; then find $etcdconf -name '*etcd*' | xargs stat -c permissions=%a; fi'" 90 use_multiple_values: true 91 tests: 92 test_items: 93 - flag: "permissions" 94 compare: 95 op: bitmask 96 value: "600" 97 remediation: | 98 Run the below command (based on the file location on your system) on the control plane node. 99 For example, 100 chmod 600 $etcdconf 101 scored: true 102 103 - id: 1.1.8 104 text: "Ensure that the etcd pod specification file ownership is set to root:root (Automated)" 105 audit: "/bin/sh -c 'if test -e $etcdconf; then find $etcdconf -name '*etcd*' | xargs stat -c %U:%G; fi'" 106 use_multiple_values: true 107 tests: 108 test_items: 109 - flag: "root:root" 110 remediation: | 111 Run the below command (based on the file location on your system) on the control plane node. 112 For example, 113 chown root:root $etcdconf 114 scored: true 115 116 - id: 1.1.9 117 text: "Ensure that the Container Network Interface file permissions are set to 600 or more restrictive (Manual)" 118 audit: | 119 ps -ef | grep $kubeletbin | grep -- --cni-conf-dir | sed 's%.*cni-conf-dir[= ]\([^ ]*\).*%\1%' | xargs -I{} find {} -mindepth 1 | xargs --no-run-if-empty stat -c permissions=%a 120 find /var/lib/cni/networks -type f 2> /dev/null | xargs --no-run-if-empty stat -c permissions=%a 121 use_multiple_values: true 122 tests: 123 test_items: 124 - flag: "permissions" 125 compare: 126 op: bitmask 127 value: "600" 128 remediation: | 129 Run the below command (based on the file location on your system) on the control plane node. 130 For example, chmod 600 <path/to/cni/files> 131 scored: false 132 133 - id: 1.1.10 134 text: "Ensure that the Container Network Interface file ownership is set to root:root (Manual)" 135 audit: | 136 ps -ef | grep $kubeletbin | grep -- --cni-conf-dir | sed 's%.*cni-conf-dir[= ]\([^ ]*\).*%\1%' | xargs -I{} find {} -mindepth 1 | xargs --no-run-if-empty stat -c %U:%G 137 find /var/lib/cni/networks -type f 2> /dev/null | xargs --no-run-if-empty stat -c %U:%G 138 use_multiple_values: true 139 tests: 140 test_items: 141 - flag: "root:root" 142 remediation: | 143 Run the below command (based on the file location on your system) on the control plane node. 144 For example, 145 chown root:root <path/to/cni/files> 146 scored: false 147 148 - id: 1.1.11 149 text: "Ensure that the etcd data directory permissions are set to 700 or more restrictive (Automated)" 150 audit: | 151 DATA_DIR='' 152 for d in $(ps -ef | grep $etcdbin | grep -- --data-dir | sed 's%.*data-dir[= ]\([^ ]*\).*%\1%'); do 153 if test -d "$d"; then DATA_DIR="$d"; fi 154 done 155 if ! test -d "$DATA_DIR"; then DATA_DIR=$etcddatadir; fi 156 stat -c permissions=%a "$DATA_DIR" 157 tests: 158 test_items: 159 - flag: "permissions" 160 compare: 161 op: bitmask 162 value: "700" 163 remediation: | 164 On the etcd server node, get the etcd data directory, passed as an argument --data-dir, 165 from the command 'ps -ef | grep etcd'. 166 Run the below command (based on the etcd data directory found above). For example, 167 chmod 700 /var/lib/etcd 168 scored: true 169 170 - id: 1.1.12 171 text: "Ensure that the etcd data directory ownership is set to etcd:etcd (Automated)" 172 audit: | 173 DATA_DIR='' 174 for d in $(ps -ef | grep $etcdbin | grep -- --data-dir | sed 's%.*data-dir[= ]\([^ ]*\).*%\1%'); do 175 if test -d "$d"; then DATA_DIR="$d"; fi 176 done 177 if ! test -d "$DATA_DIR"; then DATA_DIR=$etcddatadir; fi 178 stat -c %U:%G "$DATA_DIR" 179 tests: 180 test_items: 181 - flag: "etcd:etcd" 182 remediation: | 183 On the etcd server node, get the etcd data directory, passed as an argument --data-dir, 184 from the command 'ps -ef | grep etcd'. 185 Run the below command (based on the etcd data directory found above). 186 For example, chown etcd:etcd /var/lib/etcd 187 scored: true 188 189 - id: 1.1.13 190 text: "Ensure that the admin.conf file permissions are set to 600 or more restrictive (Automated)" 191 audit: "/bin/sh -c 'if test -e /etc/kubernetes/admin.conf; then stat -c permissions=%a /etc/kubernetes/admin.conf; fi'" 192 tests: 193 test_items: 194 - flag: "permissions" 195 compare: 196 op: bitmask 197 value: "600" 198 remediation: | 199 Run the below command (based on the file location on your system) on the control plane node. 200 For example, chmod 600 /etc/kubernetes/admin.conf 201 scored: true 202 203 - id: 1.1.14 204 text: "Ensure that the admin.conf file ownership is set to root:root (Automated)" 205 audit: "/bin/sh -c 'if test -e /etc/kubernetes/admin.conf; then stat -c %U:%G /etc/kubernetes/admin.conf; fi'" 206 tests: 207 test_items: 208 - flag: "root:root" 209 remediation: | 210 Run the below command (based on the file location on your system) on the control plane node. 211 For example, chown root:root /etc/kubernetes/admin.conf 212 scored: true 213 214 - id: 1.1.15 215 text: "Ensure that the scheduler.conf file permissions are set to 600 or more restrictive (Automated)" 216 audit: "/bin/sh -c 'if test -e $schedulerkubeconfig; then stat -c permissions=%a $schedulerkubeconfig; fi'" 217 tests: 218 test_items: 219 - flag: "permissions" 220 compare: 221 op: bitmask 222 value: "600" 223 remediation: | 224 Run the below command (based on the file location on your system) on the control plane node. 225 For example, 226 chmod 600 $schedulerkubeconfig 227 scored: true 228 229 - id: 1.1.16 230 text: "Ensure that the scheduler.conf file ownership is set to root:root (Automated)" 231 audit: "/bin/sh -c 'if test -e $schedulerkubeconfig; then stat -c %U:%G $schedulerkubeconfig; fi'" 232 tests: 233 test_items: 234 - flag: "root:root" 235 remediation: | 236 Run the below command (based on the file location on your system) on the control plane node. 237 For example, 238 chown root:root $schedulerkubeconfig 239 scored: true 240 241 - id: 1.1.17 242 text: "Ensure that the controller-manager.conf file permissions are set to 600 or more restrictive (Automated)" 243 audit: "/bin/sh -c 'if test -e $controllermanagerkubeconfig; then stat -c permissions=%a $controllermanagerkubeconfig; fi'" 244 tests: 245 test_items: 246 - flag: "permissions" 247 compare: 248 op: bitmask 249 value: "600" 250 remediation: | 251 Run the below command (based on the file location on your system) on the control plane node. 252 For example, 253 chmod 600 $controllermanagerkubeconfig 254 scored: true 255 256 - id: 1.1.18 257 text: "Ensure that the controller-manager.conf file ownership is set to root:root (Automated)" 258 audit: "/bin/sh -c 'if test -e $controllermanagerkubeconfig; then stat -c %U:%G $controllermanagerkubeconfig; fi'" 259 tests: 260 test_items: 261 - flag: "root:root" 262 remediation: | 263 Run the below command (based on the file location on your system) on the control plane node. 264 For example, 265 chown root:root $controllermanagerkubeconfig 266 scored: true 267 268 - id: 1.1.19 269 text: "Ensure that the Kubernetes PKI directory and file ownership is set to root:root (Automated)" 270 audit: "find /etc/kubernetes/pki/ | xargs stat -c %U:%G" 271 use_multiple_values: true 272 tests: 273 test_items: 274 - flag: "root:root" 275 remediation: | 276 Run the below command (based on the file location on your system) on the control plane node. 277 For example, 278 chown -R root:root /etc/kubernetes/pki/ 279 scored: true 280 281 - id: 1.1.20 282 text: "Ensure that the Kubernetes PKI certificate file permissions are set to 600 or more restrictive (Manual)" 283 audit: "find /etc/kubernetes/pki/ -name '*.crt' | xargs stat -c permissions=%a" 284 use_multiple_values: true 285 tests: 286 test_items: 287 - flag: "permissions" 288 compare: 289 op: bitmask 290 value: "600" 291 remediation: | 292 Run the below command (based on the file location on your system) on the control plane node. 293 For example, 294 chmod -R 600 /etc/kubernetes/pki/*.crt 295 scored: false 296 297 - id: 1.1.21 298 text: "Ensure that the Kubernetes PKI key file permissions are set to 600 (Manual)" 299 audit: "find /etc/kubernetes/pki/ -name '*.key' | xargs stat -c permissions=%a" 300 use_multiple_values: true 301 tests: 302 test_items: 303 - flag: "permissions" 304 compare: 305 op: bitmask 306 value: "600" 307 remediation: | 308 Run the below command (based on the file location on your system) on the control plane node. 309 For example, 310 chmod -R 600 /etc/kubernetes/pki/*.key 311 scored: false 312 313 - id: 1.2 314 text: "API Server" 315 checks: 316 - id: 1.2.1 317 text: "Ensure that the --anonymous-auth argument is set to false (Manual)" 318 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 319 tests: 320 test_items: 321 - flag: "--anonymous-auth" 322 compare: 323 op: eq 324 value: false 325 remediation: | 326 Edit the API server pod specification file $apiserverconf 327 on the control plane node and set the below parameter. 328 --anonymous-auth=false 329 scored: false 330 331 - id: 1.2.2 332 text: "Ensure that the --token-auth-file parameter is not set (Automated)" 333 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 334 tests: 335 test_items: 336 - flag: "--token-auth-file" 337 set: false 338 remediation: | 339 Follow the documentation and configure alternate mechanisms for authentication. Then, 340 edit the API server pod specification file $apiserverconf 341 on the control plane node and remove the --token-auth-file=<filename> parameter. 342 scored: true 343 344 - id: 1.2.3 345 text: "Ensure that the --DenyServiceExternalIPs is set (Manual)" 346 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 347 tests: 348 bin_op: or 349 test_items: 350 - flag: "--enable-admission-plugins" 351 compare: 352 op: have 353 value: "DenyServiceExternalIPs" 354 remediation: | 355 Edit the API server pod specification file $apiserverconf 356 on the control plane node and remove the `DenyServiceExternalIPs` 357 from enabled admission plugins. 358 scored: false 359 360 - id: 1.2.4 361 text: "Ensure that the --kubelet-client-certificate and --kubelet-client-key arguments are set as appropriate (Automated)" 362 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 363 tests: 364 bin_op: and 365 test_items: 366 - flag: "--kubelet-client-certificate" 367 - flag: "--kubelet-client-key" 368 remediation: | 369 Follow the Kubernetes documentation and set up the TLS connection between the 370 apiserver and kubelets. Then, edit API server pod specification file 371 $apiserverconf on the control plane node and set the 372 kubelet client certificate and key parameters as below. 373 --kubelet-client-certificate=<path/to/client-certificate-file> 374 --kubelet-client-key=<path/to/client-key-file> 375 scored: true 376 377 - id: 1.2.5 378 text: "Ensure that the --kubelet-certificate-authority argument is set as appropriate (Automated)" 379 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 380 tests: 381 test_items: 382 - flag: "--kubelet-certificate-authority" 383 remediation: | 384 Follow the Kubernetes documentation and setup the TLS connection between 385 the apiserver and kubelets. Then, edit the API server pod specification file 386 $apiserverconf on the control plane node and set the 387 --kubelet-certificate-authority parameter to the path to the cert file for the certificate authority. 388 --kubelet-certificate-authority=<ca-string> 389 scored: true 390 391 - id: 1.2.6 392 text: "Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated)" 393 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 394 tests: 395 test_items: 396 - flag: "--authorization-mode" 397 compare: 398 op: nothave 399 value: "AlwaysAllow" 400 remediation: | 401 Edit the API server pod specification file $apiserverconf 402 on the control plane node and set the --authorization-mode parameter to values other than AlwaysAllow. 403 One such example could be as below. 404 --authorization-mode=RBAC 405 scored: true 406 407 - id: 1.2.7 408 text: "Ensure that the --authorization-mode argument includes Node (Automated)" 409 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 410 tests: 411 test_items: 412 - flag: "--authorization-mode" 413 compare: 414 op: has 415 value: "Node" 416 remediation: | 417 Edit the API server pod specification file $apiserverconf 418 on the control plane node and set the --authorization-mode parameter to a value that includes Node. 419 --authorization-mode=Node,RBAC 420 scored: true 421 422 - id: 1.2.8 423 text: "Ensure that the --authorization-mode argument includes RBAC (Automated)" 424 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 425 tests: 426 test_items: 427 - flag: "--authorization-mode" 428 compare: 429 op: has 430 value: "RBAC" 431 remediation: | 432 Edit the API server pod specification file $apiserverconf 433 on the control plane node and set the --authorization-mode parameter to a value that includes RBAC, 434 for example `--authorization-mode=Node,RBAC`. 435 scored: true 436 437 - id: 1.2.9 438 text: "Ensure that the admission control plugin EventRateLimit is set (Manual)" 439 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 440 tests: 441 test_items: 442 - flag: "--enable-admission-plugins" 443 compare: 444 op: has 445 value: "EventRateLimit" 446 remediation: | 447 Follow the Kubernetes documentation and set the desired limits in a configuration file. 448 Then, edit the API server pod specification file $apiserverconf 449 and set the below parameters. 450 --enable-admission-plugins=...,EventRateLimit,... 451 --admission-control-config-file=<path/to/configuration/file> 452 scored: false 453 454 - id: 1.2.10 455 text: "Ensure that the admission control plugin AlwaysAdmit is not set (Automated)" 456 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 457 tests: 458 bin_op: or 459 test_items: 460 - flag: "--enable-admission-plugins" 461 compare: 462 op: nothave 463 value: AlwaysAdmit 464 - flag: "--enable-admission-plugins" 465 set: false 466 remediation: | 467 Edit the API server pod specification file $apiserverconf 468 on the control plane node and either remove the --enable-admission-plugins parameter, or set it to a 469 value that does not include AlwaysAdmit. 470 scored: true 471 472 - id: 1.2.11 473 text: "Ensure that the admission control plugin AlwaysPullImages is set (Manual)" 474 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 475 tests: 476 test_items: 477 - flag: "--enable-admission-plugins" 478 compare: 479 op: has 480 value: "AlwaysPullImages" 481 remediation: | 482 Edit the API server pod specification file $apiserverconf 483 on the control plane node and set the --enable-admission-plugins parameter to include 484 AlwaysPullImages. 485 --enable-admission-plugins=...,AlwaysPullImages,... 486 scored: false 487 488 - id: 1.2.12 489 text: "Ensure that the admission control plugin SecurityContextDeny is set if PodSecurityPolicy is not used (Manual)" 490 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 491 tests: 492 bin_op: or 493 test_items: 494 - flag: "--enable-admission-plugins" 495 compare: 496 op: has 497 value: "SecurityContextDeny" 498 - flag: "--enable-admission-plugins" 499 compare: 500 op: has 501 value: "PodSecurityPolicy" 502 remediation: | 503 Edit the API server pod specification file $apiserverconf 504 on the control plane node and set the --enable-admission-plugins parameter to include 505 SecurityContextDeny, unless PodSecurityPolicy is already in place. 506 --enable-admission-plugins=...,SecurityContextDeny,... 507 scored: false 508 509 - id: 1.2.13 510 text: "Ensure that the admission control plugin ServiceAccount is set (Automated)" 511 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 512 tests: 513 bin_op: or 514 test_items: 515 - flag: "--disable-admission-plugins" 516 compare: 517 op: nothave 518 value: "ServiceAccount" 519 - flag: "--disable-admission-plugins" 520 set: false 521 remediation: | 522 Follow the documentation and create ServiceAccount objects as per your environment. 523 Then, edit the API server pod specification file $apiserverconf 524 on the control plane node and ensure that the --disable-admission-plugins parameter is set to a 525 value that does not include ServiceAccount. 526 scored: true 527 528 - id: 1.2.14 529 text: "Ensure that the admission control plugin NamespaceLifecycle is set (Automated)" 530 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 531 tests: 532 bin_op: or 533 test_items: 534 - flag: "--disable-admission-plugins" 535 compare: 536 op: nothave 537 value: "NamespaceLifecycle" 538 - flag: "--disable-admission-plugins" 539 set: false 540 remediation: | 541 Edit the API server pod specification file $apiserverconf 542 on the control plane node and set the --disable-admission-plugins parameter to 543 ensure it does not include NamespaceLifecycle. 544 scored: true 545 546 - id: 1.2.15 547 text: "Ensure that the admission control plugin NodeRestriction is set (Automated)" 548 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 549 tests: 550 test_items: 551 - flag: "--enable-admission-plugins" 552 compare: 553 op: has 554 value: "NodeRestriction" 555 remediation: | 556 Follow the Kubernetes documentation and configure NodeRestriction plug-in on kubelets. 557 Then, edit the API server pod specification file $apiserverconf 558 on the control plane node and set the --enable-admission-plugins parameter to a 559 value that includes NodeRestriction. 560 --enable-admission-plugins=...,NodeRestriction,... 561 scored: true 562 563 - id: 1.2.16 564 text: "Ensure that the --profiling argument is set to false (Automated)" 565 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 566 tests: 567 test_items: 568 - flag: "--profiling" 569 compare: 570 op: eq 571 value: false 572 remediation: | 573 Edit the API server pod specification file $apiserverconf 574 on the control plane node and set the below parameter. 575 --profiling=false 576 scored: true 577 578 - id: 1.2.17 579 text: "Ensure that the --audit-log-path argument is set (Automated)" 580 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 581 tests: 582 test_items: 583 - flag: "--audit-log-path" 584 remediation: | 585 Edit the API server pod specification file $apiserverconf 586 on the control plane node and set the --audit-log-path parameter to a suitable path and 587 file where you would like audit logs to be written, for example, 588 --audit-log-path=/var/log/apiserver/audit.log 589 scored: true 590 591 - id: 1.2.18 592 text: "Ensure that the --audit-log-maxage argument is set to 30 or as appropriate (Automated)" 593 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 594 tests: 595 test_items: 596 - flag: "--audit-log-maxage" 597 compare: 598 op: gte 599 value: 30 600 remediation: | 601 Edit the API server pod specification file $apiserverconf 602 on the control plane node and set the --audit-log-maxage parameter to 30 603 or as an appropriate number of days, for example, 604 --audit-log-maxage=30 605 scored: true 606 607 - id: 1.2.19 608 text: "Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate (Automated)" 609 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 610 tests: 611 test_items: 612 - flag: "--audit-log-maxbackup" 613 compare: 614 op: gte 615 value: 10 616 remediation: | 617 Edit the API server pod specification file $apiserverconf 618 on the control plane node and set the --audit-log-maxbackup parameter to 10 or to an appropriate 619 value. For example, 620 --audit-log-maxbackup=10 621 scored: true 622 623 - id: 1.2.20 624 text: "Ensure that the --audit-log-maxsize argument is set to 100 or as appropriate (Automated)" 625 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 626 tests: 627 test_items: 628 - flag: "--audit-log-maxsize" 629 compare: 630 op: gte 631 value: 100 632 remediation: | 633 Edit the API server pod specification file $apiserverconf 634 on the control plane node and set the --audit-log-maxsize parameter to an appropriate size in MB. 635 For example, to set it as 100 MB, --audit-log-maxsize=100 636 scored: true 637 638 - id: 1.2.21 639 text: "Ensure that the --request-timeout argument is set as appropriate (Manual)" 640 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 641 type: manual 642 remediation: | 643 Edit the API server pod specification file $apiserverconf 644 and set the below parameter as appropriate and if needed. 645 For example, --request-timeout=300s 646 scored: false 647 648 - id: 1.2.22 649 text: "Ensure that the --service-account-lookup argument is set to true (Automated)" 650 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 651 tests: 652 bin_op: or 653 test_items: 654 - flag: "--service-account-lookup" 655 set: false 656 - flag: "--service-account-lookup" 657 compare: 658 op: eq 659 value: true 660 remediation: | 661 Edit the API server pod specification file $apiserverconf 662 on the control plane node and set the below parameter. 663 --service-account-lookup=true 664 Alternatively, you can delete the --service-account-lookup parameter from this file so 665 that the default takes effect. 666 scored: true 667 668 - id: 1.2.23 669 text: "Ensure that the --service-account-key-file argument is set as appropriate (Automated)" 670 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 671 tests: 672 test_items: 673 - flag: "--service-account-key-file" 674 remediation: | 675 Edit the API server pod specification file $apiserverconf 676 on the control plane node and set the --service-account-key-file parameter 677 to the public key file for service accounts. For example, 678 --service-account-key-file=<filename> 679 scored: true 680 681 - id: 1.2.24 682 text: "Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate (Automated)" 683 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 684 tests: 685 bin_op: and 686 test_items: 687 - flag: "--etcd-certfile" 688 - flag: "--etcd-keyfile" 689 remediation: | 690 Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd. 691 Then, edit the API server pod specification file $apiserverconf 692 on the control plane node and set the etcd certificate and key file parameters. 693 --etcd-certfile=<path/to/client-certificate-file> 694 --etcd-keyfile=<path/to/client-key-file> 695 scored: true 696 697 - id: 1.2.25 698 text: "Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate (Automated)" 699 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 700 tests: 701 bin_op: and 702 test_items: 703 - flag: "--tls-cert-file" 704 - flag: "--tls-private-key-file" 705 remediation: | 706 Follow the Kubernetes documentation and set up the TLS connection on the apiserver. 707 Then, edit the API server pod specification file $apiserverconf 708 on the control plane node and set the TLS certificate and private key file parameters. 709 --tls-cert-file=<path/to/tls-certificate-file> 710 --tls-private-key-file=<path/to/tls-key-file> 711 scored: true 712 713 - id: 1.2.26 714 text: "Ensure that the --client-ca-file argument is set as appropriate (Automated)" 715 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 716 tests: 717 test_items: 718 - flag: "--client-ca-file" 719 remediation: | 720 Follow the Kubernetes documentation and set up the TLS connection on the apiserver. 721 Then, edit the API server pod specification file $apiserverconf 722 on the control plane node and set the client certificate authority file. 723 --client-ca-file=<path/to/client-ca-file> 724 scored: true 725 726 - id: 1.2.27 727 text: "Ensure that the --etcd-cafile argument is set as appropriate (Automated)" 728 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 729 tests: 730 test_items: 731 - flag: "--etcd-cafile" 732 remediation: | 733 Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd. 734 Then, edit the API server pod specification file $apiserverconf 735 on the control plane node and set the etcd certificate authority file parameter. 736 --etcd-cafile=<path/to/ca-file> 737 scored: true 738 739 - id: 1.2.28 740 text: "Ensure that the --encryption-provider-config argument is set as appropriate (Manual)" 741 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 742 tests: 743 test_items: 744 - flag: "--encryption-provider-config" 745 remediation: | 746 Follow the Kubernetes documentation and configure a EncryptionConfig file. 747 Then, edit the API server pod specification file $apiserverconf 748 on the control plane node and set the --encryption-provider-config parameter to the path of that file. 749 For example, --encryption-provider-config=</path/to/EncryptionConfig/File> 750 scored: false 751 752 - id: 1.2.29 753 text: "Ensure that encryption providers are appropriately configured (Manual)" 754 audit: | 755 ENCRYPTION_PROVIDER_CONFIG=$(ps -ef | grep $apiserverbin | grep -- --encryption-provider-config | sed 's%.*encryption-provider-config[= ]\([^ ]*\).*%\1%') 756 if test -e $ENCRYPTION_PROVIDER_CONFIG; then grep -A1 'providers:' $ENCRYPTION_PROVIDER_CONFIG | tail -n1 | grep -o "[A-Za-z]*" | sed 's/^/provider=/'; fi 757 tests: 758 test_items: 759 - flag: "provider" 760 compare: 761 op: valid_elements 762 value: "aescbc,kms,secretbox" 763 remediation: | 764 Follow the Kubernetes documentation and configure a EncryptionConfig file. 765 In this file, choose aescbc, kms or secretbox as the encryption provider. 766 scored: false 767 768 - id: 1.2.30 769 text: "Ensure that the API Server only makes use of Strong Cryptographic Ciphers (Manual)" 770 audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep" 771 tests: 772 test_items: 773 - flag: "--tls-cipher-suites" 774 compare: 775 op: valid_elements 776 value: "TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_3DES_EDE_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384" 777 remediation: | 778 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml 779 on the control plane node and set the below parameter. 780 --tls-cipher-suites=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256, 781 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 782 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 783 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, 784 TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 785 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, 786 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_3DES_EDE_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, 787 TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384 788 scored: false 789 790 - id: 1.3 791 text: "Controller Manager" 792 checks: 793 - id: 1.3.1 794 text: "Ensure that the --terminated-pod-gc-threshold argument is set as appropriate (Manual)" 795 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 796 tests: 797 test_items: 798 - flag: "--terminated-pod-gc-threshold" 799 remediation: | 800 Edit the Controller Manager pod specification file $controllermanagerconf 801 on the control plane node and set the --terminated-pod-gc-threshold to an appropriate threshold, 802 for example, --terminated-pod-gc-threshold=10 803 scored: false 804 805 - id: 1.3.2 806 text: "Ensure that the --profiling argument is set to false (Automated)" 807 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 808 tests: 809 test_items: 810 - flag: "--profiling" 811 compare: 812 op: eq 813 value: false 814 remediation: | 815 Edit the Controller Manager pod specification file $controllermanagerconf 816 on the control plane node and set the below parameter. 817 --profiling=false 818 scored: true 819 820 - id: 1.3.3 821 text: "Ensure that the --use-service-account-credentials argument is set to true (Automated)" 822 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 823 tests: 824 test_items: 825 - flag: "--use-service-account-credentials" 826 compare: 827 op: noteq 828 value: false 829 remediation: | 830 Edit the Controller Manager pod specification file $controllermanagerconf 831 on the control plane node to set the below parameter. 832 --use-service-account-credentials=true 833 scored: true 834 835 - id: 1.3.4 836 text: "Ensure that the --service-account-private-key-file argument is set as appropriate (Automated)" 837 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 838 tests: 839 test_items: 840 - flag: "--service-account-private-key-file" 841 remediation: | 842 Edit the Controller Manager pod specification file $controllermanagerconf 843 on the control plane node and set the --service-account-private-key-file parameter 844 to the private key file for service accounts. 845 --service-account-private-key-file=<filename> 846 scored: true 847 848 - id: 1.3.5 849 text: "Ensure that the --root-ca-file argument is set as appropriate (Automated)" 850 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 851 tests: 852 test_items: 853 - flag: "--root-ca-file" 854 remediation: | 855 Edit the Controller Manager pod specification file $controllermanagerconf 856 on the control plane node and set the --root-ca-file parameter to the certificate bundle file`. 857 --root-ca-file=<path/to/file> 858 scored: true 859 860 - id: 1.3.6 861 text: "Ensure that the RotateKubeletServerCertificate argument is set to true (Automated)" 862 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 863 tests: 864 bin_op: or 865 test_items: 866 - flag: "--feature-gates" 867 compare: 868 op: nothave 869 value: "RotateKubeletServerCertificate=false" 870 set: true 871 - flag: "--feature-gates" 872 set: false 873 remediation: | 874 Edit the Controller Manager pod specification file $controllermanagerconf 875 on the control plane node and set the --feature-gates parameter to include RotateKubeletServerCertificate=true. 876 --feature-gates=RotateKubeletServerCertificate=true 877 scored: true 878 879 - id: 1.3.7 880 text: "Ensure that the --bind-address argument is set to 127.0.0.1 (Automated)" 881 audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep" 882 tests: 883 bin_op: or 884 test_items: 885 - flag: "--bind-address" 886 compare: 887 op: eq 888 value: "127.0.0.1" 889 - flag: "--bind-address" 890 set: false 891 remediation: | 892 Edit the Controller Manager pod specification file $controllermanagerconf 893 on the control plane node and ensure the correct value for the --bind-address parameter 894 scored: true 895 896 - id: 1.4 897 text: "Scheduler" 898 checks: 899 - id: 1.4.1 900 text: "Ensure that the --profiling argument is set to false (Automated)" 901 audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep" 902 tests: 903 test_items: 904 - flag: "--profiling" 905 compare: 906 op: eq 907 value: false 908 remediation: | 909 Edit the Scheduler pod specification file $schedulerconf file 910 on the control plane node and set the below parameter. 911 --profiling=false 912 scored: true 913 914 - id: 1.4.2 915 text: "Ensure that the --bind-address argument is set to 127.0.0.1 (Automated)" 916 audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep" 917 tests: 918 bin_op: or 919 test_items: 920 - flag: "--bind-address" 921 compare: 922 op: eq 923 value: "127.0.0.1" 924 - flag: "--bind-address" 925 set: false 926 remediation: | 927 Edit the Scheduler pod specification file $schedulerconf 928 on the control plane node and ensure the correct value for the --bind-address parameter 929 scored: true