github.com/khulnasoft-lab/kube-bench@v0.2.1-0.20240330183753-9df52345ae58/cfg/cis-1.24/master.yaml (about)

     1  ---
     2  controls:
     3  version: "cis-1.24"
     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 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              - flag: "--enable-admission-plugins"
   355                set: false
   356          remediation: |
   357            Edit the API server pod specification file $apiserverconf
   358            on the control plane node and remove the `DenyServiceExternalIPs`
   359            from enabled admission plugins.
   360          scored: true
   361  
   362        - id: 1.2.4
   363          text: "Ensure that the --kubelet-client-certificate and --kubelet-client-key arguments are set as appropriate (Automated)"
   364          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   365          tests:
   366            bin_op: and
   367            test_items:
   368              - flag: "--kubelet-client-certificate"
   369              - flag: "--kubelet-client-key"
   370          remediation: |
   371            Follow the Kubernetes documentation and set up the TLS connection between the
   372            apiserver and kubelets. Then, edit API server pod specification file
   373            $apiserverconf on the control plane node and set the
   374            kubelet client certificate and key parameters as below.
   375            --kubelet-client-certificate=<path/to/client-certificate-file>
   376            --kubelet-client-key=<path/to/client-key-file>
   377          scored: true
   378  
   379        - id: 1.2.5
   380          text: "Ensure that the --kubelet-certificate-authority argument is set as appropriate (Automated)"
   381          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   382          tests:
   383            test_items:
   384              - flag: "--kubelet-certificate-authority"
   385          remediation: |
   386            Follow the Kubernetes documentation and setup the TLS connection between
   387            the apiserver and kubelets. Then, edit the API server pod specification file
   388            $apiserverconf on the control plane node and set the
   389            --kubelet-certificate-authority parameter to the path to the cert file for the certificate authority.
   390            --kubelet-certificate-authority=<ca-string>
   391          scored: true
   392  
   393        - id: 1.2.6
   394          text: "Ensure that the --authorization-mode argument is not set to AlwaysAllow (Automated)"
   395          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   396          tests:
   397            test_items:
   398              - flag: "--authorization-mode"
   399                compare:
   400                  op: nothave
   401                  value: "AlwaysAllow"
   402          remediation: |
   403            Edit the API server pod specification file $apiserverconf
   404            on the control plane node and set the --authorization-mode parameter to values other than AlwaysAllow.
   405            One such example could be as below.
   406            --authorization-mode=RBAC
   407          scored: true
   408  
   409        - id: 1.2.7
   410          text: "Ensure that the --authorization-mode argument includes Node (Automated)"
   411          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   412          tests:
   413            test_items:
   414              - flag: "--authorization-mode"
   415                compare:
   416                  op: has
   417                  value: "Node"
   418          remediation: |
   419            Edit the API server pod specification file $apiserverconf
   420            on the control plane node and set the --authorization-mode parameter to a value that includes Node.
   421            --authorization-mode=Node,RBAC
   422          scored: true
   423  
   424        - id: 1.2.8
   425          text: "Ensure that the --authorization-mode argument includes RBAC (Automated)"
   426          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   427          tests:
   428            test_items:
   429              - flag: "--authorization-mode"
   430                compare:
   431                  op: has
   432                  value: "RBAC"
   433          remediation: |
   434            Edit the API server pod specification file $apiserverconf
   435            on the control plane node and set the --authorization-mode parameter to a value that includes RBAC,
   436            for example `--authorization-mode=Node,RBAC`.
   437          scored: true
   438  
   439        - id: 1.2.9
   440          text: "Ensure that the admission control plugin EventRateLimit is set (Manual)"
   441          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   442          tests:
   443            test_items:
   444              - flag: "--enable-admission-plugins"
   445                compare:
   446                  op: has
   447                  value: "EventRateLimit"
   448          remediation: |
   449            Follow the Kubernetes documentation and set the desired limits in a configuration file.
   450            Then, edit the API server pod specification file $apiserverconf
   451            and set the below parameters.
   452            --enable-admission-plugins=...,EventRateLimit,...
   453            --admission-control-config-file=<path/to/configuration/file>
   454          scored: false
   455  
   456        - id: 1.2.10
   457          text: "Ensure that the admission control plugin AlwaysAdmit is not set (Automated)"
   458          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   459          tests:
   460            bin_op: or
   461            test_items:
   462              - flag: "--enable-admission-plugins"
   463                compare:
   464                  op: nothave
   465                  value: AlwaysAdmit
   466              - flag: "--enable-admission-plugins"
   467                set: false
   468          remediation: |
   469            Edit the API server pod specification file $apiserverconf
   470            on the control plane node and either remove the --enable-admission-plugins parameter, or set it to a
   471            value that does not include AlwaysAdmit.
   472          scored: true
   473  
   474        - id: 1.2.11
   475          text: "Ensure that the admission control plugin AlwaysPullImages is set (Manual)"
   476          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   477          tests:
   478            test_items:
   479              - flag: "--enable-admission-plugins"
   480                compare:
   481                  op: has
   482                  value: "AlwaysPullImages"
   483          remediation: |
   484            Edit the API server pod specification file $apiserverconf
   485            on the control plane node and set the --enable-admission-plugins parameter to include
   486            AlwaysPullImages.
   487            --enable-admission-plugins=...,AlwaysPullImages,...
   488          scored: false
   489  
   490        - id: 1.2.12
   491          text: "Ensure that the admission control plugin SecurityContextDeny is set if PodSecurityPolicy is not used (Manual)"
   492          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   493          tests:
   494            bin_op: or
   495            test_items:
   496              - flag: "--enable-admission-plugins"
   497                compare:
   498                  op: has
   499                  value: "SecurityContextDeny"
   500              - flag: "--enable-admission-plugins"
   501                compare:
   502                  op: has
   503                  value: "PodSecurityPolicy"
   504          remediation: |
   505            Edit the API server pod specification file $apiserverconf
   506            on the control plane node and set the --enable-admission-plugins parameter to include
   507            SecurityContextDeny, unless PodSecurityPolicy is already in place.
   508            --enable-admission-plugins=...,SecurityContextDeny,...
   509          scored: false
   510  
   511        - id: 1.2.13
   512          text: "Ensure that the admission control plugin ServiceAccount is set (Automated)"
   513          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   514          tests:
   515            bin_op: or
   516            test_items:
   517              - flag: "--disable-admission-plugins"
   518                compare:
   519                  op: nothave
   520                  value: "ServiceAccount"
   521              - flag: "--disable-admission-plugins"
   522                set: false
   523          remediation: |
   524            Follow the documentation and create ServiceAccount objects as per your environment.
   525            Then, edit the API server pod specification file $apiserverconf
   526            on the control plane node and ensure that the --disable-admission-plugins parameter is set to a
   527            value that does not include ServiceAccount.
   528          scored: true
   529  
   530        - id: 1.2.14
   531          text: "Ensure that the admission control plugin NamespaceLifecycle is set (Automated)"
   532          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   533          tests:
   534            bin_op: or
   535            test_items:
   536              - flag: "--disable-admission-plugins"
   537                compare:
   538                  op: nothave
   539                  value: "NamespaceLifecycle"
   540              - flag: "--disable-admission-plugins"
   541                set: false
   542          remediation: |
   543            Edit the API server pod specification file $apiserverconf
   544            on the control plane node and set the --disable-admission-plugins parameter to
   545            ensure it does not include NamespaceLifecycle.
   546          scored: true
   547  
   548        - id: 1.2.15
   549          text: "Ensure that the admission control plugin NodeRestriction is set (Automated)"
   550          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   551          tests:
   552            test_items:
   553              - flag: "--enable-admission-plugins"
   554                compare:
   555                  op: has
   556                  value: "NodeRestriction"
   557          remediation: |
   558            Follow the Kubernetes documentation and configure NodeRestriction plug-in on kubelets.
   559            Then, edit the API server pod specification file $apiserverconf
   560            on the control plane node and set the --enable-admission-plugins parameter to a
   561            value that includes NodeRestriction.
   562            --enable-admission-plugins=...,NodeRestriction,...
   563          scored: true
   564  
   565        - id: 1.2.16
   566          text: "Ensure that the --secure-port argument is not set to 0 (Automated)"
   567          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   568          tests:
   569            bin_op: or
   570            test_items:
   571              - flag: "--secure-port"
   572                compare:
   573                  op: gt
   574                  value: 0
   575              - flag: "--secure-port"
   576                set: false
   577          remediation: |
   578            Edit the API server pod specification file $apiserverconf
   579            on the control plane node and either remove the --secure-port parameter or
   580            set it to a different (non-zero) desired port.
   581          scored: true
   582  
   583        - id: 1.2.17
   584          text: "Ensure that the --profiling argument is set to false (Automated)"
   585          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   586          tests:
   587            test_items:
   588              - flag: "--profiling"
   589                compare:
   590                  op: eq
   591                  value: false
   592          remediation: |
   593            Edit the API server pod specification file $apiserverconf
   594            on the control plane node and set the below parameter.
   595            --profiling=false
   596          scored: true
   597  
   598        - id: 1.2.18
   599          text: "Ensure that the --audit-log-path argument is set (Automated)"
   600          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   601          tests:
   602            test_items:
   603              - flag: "--audit-log-path"
   604          remediation: |
   605            Edit the API server pod specification file $apiserverconf
   606            on the control plane node and set the --audit-log-path parameter to a suitable path and
   607            file where you would like audit logs to be written, for example,
   608            --audit-log-path=/var/log/apiserver/audit.log
   609          scored: true
   610  
   611        - id: 1.2.19
   612          text: "Ensure that the --audit-log-maxage argument is set to 30 or as appropriate (Automated)"
   613          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   614          tests:
   615            test_items:
   616              - flag: "--audit-log-maxage"
   617                compare:
   618                  op: gte
   619                  value: 30
   620          remediation: |
   621            Edit the API server pod specification file $apiserverconf
   622            on the control plane node and set the --audit-log-maxage parameter to 30
   623            or as an appropriate number of days, for example,
   624            --audit-log-maxage=30
   625          scored: true
   626  
   627        - id: 1.2.20
   628          text: "Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate (Automated)"
   629          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   630          tests:
   631            test_items:
   632              - flag: "--audit-log-maxbackup"
   633                compare:
   634                  op: gte
   635                  value: 10
   636          remediation: |
   637            Edit the API server pod specification file $apiserverconf
   638            on the control plane node and set the --audit-log-maxbackup parameter to 10 or to an appropriate
   639            value. For example,
   640            --audit-log-maxbackup=10
   641          scored: true
   642  
   643        - id: 1.2.21
   644          text: "Ensure that the --audit-log-maxsize argument is set to 100 or as appropriate (Automated)"
   645          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   646          tests:
   647            test_items:
   648              - flag: "--audit-log-maxsize"
   649                compare:
   650                  op: gte
   651                  value: 100
   652          remediation: |
   653            Edit the API server pod specification file $apiserverconf
   654            on the control plane node and set the --audit-log-maxsize parameter to an appropriate size in MB.
   655            For example, to set it as 100 MB, --audit-log-maxsize=100
   656          scored: true
   657  
   658        - id: 1.2.22
   659          text: "Ensure that the --request-timeout argument is set as appropriate (Manual)"
   660          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   661          type: manual
   662          remediation: |
   663            Edit the API server pod specification file $apiserverconf
   664            and set the below parameter as appropriate and if needed.
   665            For example, --request-timeout=300s
   666          scored: false
   667  
   668        - id: 1.2.23
   669          text: "Ensure that the --service-account-lookup argument is set to true (Automated)"
   670          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   671          tests:
   672            bin_op: or
   673            test_items:
   674              - flag: "--service-account-lookup"
   675                set: false
   676              - flag: "--service-account-lookup"
   677                compare:
   678                  op: eq
   679                  value: true
   680          remediation: |
   681            Edit the API server pod specification file $apiserverconf
   682            on the control plane node and set the below parameter.
   683            --service-account-lookup=true
   684            Alternatively, you can delete the --service-account-lookup parameter from this file so
   685            that the default takes effect.
   686          scored: true
   687  
   688        - id: 1.2.24
   689          text: "Ensure that the --service-account-key-file argument is set as appropriate (Automated)"
   690          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   691          tests:
   692            test_items:
   693              - flag: "--service-account-key-file"
   694          remediation: |
   695            Edit the API server pod specification file $apiserverconf
   696            on the control plane node and set the --service-account-key-file parameter
   697            to the public key file for service accounts. For example,
   698            --service-account-key-file=<filename>
   699          scored: true
   700  
   701        - id: 1.2.25
   702          text: "Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate (Automated)"
   703          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   704          tests:
   705            bin_op: and
   706            test_items:
   707              - flag: "--etcd-certfile"
   708              - flag: "--etcd-keyfile"
   709          remediation: |
   710            Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd.
   711            Then, edit the API server pod specification file $apiserverconf
   712            on the control plane node and set the etcd certificate and key file parameters.
   713            --etcd-certfile=<path/to/client-certificate-file>
   714            --etcd-keyfile=<path/to/client-key-file>
   715          scored: true
   716  
   717        - id: 1.2.26
   718          text: "Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate (Automated)"
   719          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   720          tests:
   721            bin_op: and
   722            test_items:
   723              - flag: "--tls-cert-file"
   724              - flag: "--tls-private-key-file"
   725          remediation: |
   726            Follow the Kubernetes documentation and set up the TLS connection on the apiserver.
   727            Then, edit the API server pod specification file $apiserverconf
   728            on the control plane node and set the TLS certificate and private key file parameters.
   729            --tls-cert-file=<path/to/tls-certificate-file>
   730            --tls-private-key-file=<path/to/tls-key-file>
   731          scored: true
   732  
   733        - id: 1.2.27
   734          text: "Ensure that the --client-ca-file argument is set as appropriate (Automated)"
   735          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   736          tests:
   737            test_items:
   738              - flag: "--client-ca-file"
   739          remediation: |
   740            Follow the Kubernetes documentation and set up the TLS connection on the apiserver.
   741            Then, edit the API server pod specification file $apiserverconf
   742            on the control plane node and set the client certificate authority file.
   743            --client-ca-file=<path/to/client-ca-file>
   744          scored: true
   745  
   746        - id: 1.2.28
   747          text: "Ensure that the --etcd-cafile argument is set as appropriate (Automated)"
   748          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   749          tests:
   750            test_items:
   751              - flag: "--etcd-cafile"
   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 authority file parameter.
   756            --etcd-cafile=<path/to/ca-file>
   757          scored: true
   758  
   759        - id: 1.2.29
   760          text: "Ensure that the --encryption-provider-config argument is set as appropriate (Manual)"
   761          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   762          tests:
   763            test_items:
   764              - flag: "--encryption-provider-config"
   765          remediation: |
   766            Follow the Kubernetes documentation and configure a EncryptionConfig file.
   767            Then, edit the API server pod specification file $apiserverconf
   768            on the control plane node and set the --encryption-provider-config parameter to the path of that file.
   769            For example, --encryption-provider-config=</path/to/EncryptionConfig/File>
   770          scored: false
   771  
   772        - id: 1.2.30
   773          text: "Ensure that encryption providers are appropriately configured (Manual)"
   774          audit: |
   775            ENCRYPTION_PROVIDER_CONFIG=$(ps -ef | grep $apiserverbin | grep -- --encryption-provider-config | sed 's%.*encryption-provider-config[= ]\([^ ]*\).*%\1%')
   776            if test -e $ENCRYPTION_PROVIDER_CONFIG; then grep -A1 'providers:' $ENCRYPTION_PROVIDER_CONFIG | tail -n1 | grep -o "[A-Za-z]*" | sed 's/^/provider=/'; fi
   777          tests:
   778            test_items:
   779              - flag: "provider"
   780                compare:
   781                  op: valid_elements
   782                  value: "aescbc,kms,secretbox"
   783          remediation: |
   784            Follow the Kubernetes documentation and configure a EncryptionConfig file.
   785            In this file, choose aescbc, kms or secretbox as the encryption provider.
   786          scored: false
   787  
   788        - id: 1.2.31
   789          text: "Ensure that the API Server only makes use of Strong Cryptographic Ciphers (Manual)"
   790          audit: "/bin/ps -ef | grep $apiserverbin | grep -v grep"
   791          tests:
   792            test_items:
   793              - flag: "--tls-cipher-suites"
   794                compare:
   795                  op: valid_elements
   796                  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"
   797          remediation: |
   798            Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
   799            on the control plane node and set the below parameter.
   800            --tls-cipher-suites=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256,
   801            TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
   802            TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
   803            TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
   804            TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
   805            TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
   806            TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_3DES_EDE_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,
   807            TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384
   808          scored: false
   809  
   810    - id: 1.3
   811      text: "Controller Manager"
   812      checks:
   813        - id: 1.3.1
   814          text: "Ensure that the --terminated-pod-gc-threshold argument is set as appropriate (Manual)"
   815          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   816          tests:
   817            test_items:
   818              - flag: "--terminated-pod-gc-threshold"
   819          remediation: |
   820            Edit the Controller Manager pod specification file $controllermanagerconf
   821            on the control plane node and set the --terminated-pod-gc-threshold to an appropriate threshold,
   822            for example, --terminated-pod-gc-threshold=10
   823          scored: false
   824  
   825        - id: 1.3.2
   826          text: "Ensure that the --profiling argument is set to false (Automated)"
   827          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   828          tests:
   829            test_items:
   830              - flag: "--profiling"
   831                compare:
   832                  op: eq
   833                  value: false
   834          remediation: |
   835            Edit the Controller Manager pod specification file $controllermanagerconf
   836            on the control plane node and set the below parameter.
   837            --profiling=false
   838          scored: true
   839  
   840        - id: 1.3.3
   841          text: "Ensure that the --use-service-account-credentials argument is set to true (Automated)"
   842          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   843          tests:
   844            test_items:
   845              - flag: "--use-service-account-credentials"
   846                compare:
   847                  op: noteq
   848                  value: false
   849          remediation: |
   850            Edit the Controller Manager pod specification file $controllermanagerconf
   851            on the control plane node to set the below parameter.
   852            --use-service-account-credentials=true
   853          scored: true
   854  
   855        - id: 1.3.4
   856          text: "Ensure that the --service-account-private-key-file argument is set as appropriate (Automated)"
   857          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   858          tests:
   859            test_items:
   860              - flag: "--service-account-private-key-file"
   861          remediation: |
   862            Edit the Controller Manager pod specification file $controllermanagerconf
   863            on the control plane node and set the --service-account-private-key-file parameter
   864            to the private key file for service accounts.
   865            --service-account-private-key-file=<filename>
   866          scored: true
   867  
   868        - id: 1.3.5
   869          text: "Ensure that the --root-ca-file argument is set as appropriate (Automated)"
   870          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   871          tests:
   872            test_items:
   873              - flag: "--root-ca-file"
   874          remediation: |
   875            Edit the Controller Manager pod specification file $controllermanagerconf
   876            on the control plane node and set the --root-ca-file parameter to the certificate bundle file`.
   877            --root-ca-file=<path/to/file>
   878          scored: true
   879  
   880        - id: 1.3.6
   881          text: "Ensure that the RotateKubeletServerCertificate argument is set to true (Automated)"
   882          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   883          tests:
   884            bin_op: or
   885            test_items:
   886              - flag: "--feature-gates"
   887                compare:
   888                  op: nothave
   889                  value: "RotateKubeletServerCertificate=false"
   890                set: true
   891              - flag: "--feature-gates"
   892                set: false
   893          remediation: |
   894            Edit the Controller Manager pod specification file $controllermanagerconf
   895            on the control plane node and set the --feature-gates parameter to include RotateKubeletServerCertificate=true.
   896            --feature-gates=RotateKubeletServerCertificate=true
   897          scored: true
   898  
   899        - id: 1.3.7
   900          text: "Ensure that the --bind-address argument is set to 127.0.0.1 (Automated)"
   901          audit: "/bin/ps -ef | grep $controllermanagerbin | grep -v grep"
   902          tests:
   903            bin_op: or
   904            test_items:
   905              - flag: "--bind-address"
   906                compare:
   907                  op: eq
   908                  value: "127.0.0.1"
   909              - flag: "--bind-address"
   910                set: false
   911          remediation: |
   912            Edit the Controller Manager pod specification file $controllermanagerconf
   913            on the control plane node and ensure the correct value for the --bind-address parameter
   914          scored: true
   915  
   916    - id: 1.4
   917      text: "Scheduler"
   918      checks:
   919        - id: 1.4.1
   920          text: "Ensure that the --profiling argument is set to false (Automated)"
   921          audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep"
   922          tests:
   923            test_items:
   924              - flag: "--profiling"
   925                compare:
   926                  op: eq
   927                  value: false
   928          remediation: |
   929            Edit the Scheduler pod specification file $schedulerconf file
   930            on the control plane node and set the below parameter.
   931            --profiling=false
   932          scored: true
   933  
   934        - id: 1.4.2
   935          text: "Ensure that the --bind-address argument is set to 127.0.0.1 (Automated)"
   936          audit: "/bin/ps -ef | grep $schedulerbin | grep -v grep"
   937          tests:
   938            bin_op: or
   939            test_items:
   940              - flag: "--bind-address"
   941                compare:
   942                  op: eq
   943                  value: "127.0.0.1"
   944              - flag: "--bind-address"
   945                set: false
   946          remediation: |
   947            Edit the Scheduler pod specification file $schedulerconf
   948            on the control plane node and ensure the correct value for the --bind-address parameter
   949          scored: true