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

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