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