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

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