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