CIS Kubernetes Benchmark v1.10.0
This CIS Kubernetes Benchmark provides prescriptive guidance for establishing a secure configuration posture for Kubernetes v1.28 - v1.31
Run this compliance with Prowler
Run in Prowler Cloudprowler kubernetes --compliance cis_1.10_kubernetesRequirements (130)
1 Control Plane Components5937
1.1.1Ensure that the API server pod specification file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the API server pod specification file has permissions of
600or more restrictive.- Default Value
By default, the
kube-apiserver.yamlfile has permissions of640.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/manifests/kube-apiserver.yamlVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The API server pod specification file controls various parameters that set the behavior of the API server. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/manifests/kube-apiserver.yaml
1.1.2Ensure that the API server pod specification file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the API server pod specification file ownership is set to
root:root.- Default Value
By default, the
kube-apiserver.yamlfile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/manifests/kube-apiserver.yamlVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The API server pod specification file controls various parameters that set the behavior of the API server. You should set its file ownership to maintain the integrity of the file. The file should be owned by
root:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/manifests/kube-apiserver.yaml
1.1.3Ensure that the controller manager pod specification file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the controller manager pod specification file has permissions of
600or more restrictive.- Default Value
By default, the
kube-controller-manager.yamlfile has permissions of640.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/manifests/kube-controller-manager.yamlVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The controller manager pod specification file controls various parameters that set the behavior of the Controller Manager on the master node. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/manifests/kube-controller-manager.yaml
1.1.4Ensure that the controller manager pod specification file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the controller manager pod specification file ownership is set to
root:root.- Default Value
By default,
kube-controller-manager.yamlfile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/manifests/kube-controller-manager.yamlVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The controller manager pod specification file controls various parameters that set the behavior of various components of the master node. You should set its file ownership to maintain the integrity of the file. The file should be owned by
root:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/manifests/kube-controller-manager.yaml
1.1.5Ensure that the scheduler pod specification file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the scheduler pod specification file has permissions of
600or more restrictive.- Default Value
By default,
kube-scheduler.yamlfile has permissions of640.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/manifests/kube-scheduler.yamlVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The scheduler pod specification file controls various parameters that set the behavior of the Scheduler service in the master node. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/manifests/kube-scheduler.yaml
1.1.6Ensure that the scheduler pod specification file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the scheduler pod specification file ownership is set to
root:root.- Default Value
By default,
kube-scheduler.yamlfile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/manifests/kube-scheduler.yamlVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The scheduler pod specification file controls various parameters that set the behavior of the
kube-schedulerservice in the master node. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/manifests/kube-scheduler.yaml
1.1.7Ensure that the etcd pod specification file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
/etc/kubernetes/manifests/etcd.yamlfile has permissions of600or more restrictive.- Default Value
By default,
/etc/kubernetes/manifests/etcd.yamlfile has permissions of640.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/manifests/etcd.yamlVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlcontrols various parameters that set the behavior of theetcdservice in the master node. etcd is a highly-available key-value store which Kubernetes uses for persistent storage of all of its REST API object. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/manifests/etcd.yaml
1.1.8Ensure that the etcd pod specification file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
/etc/kubernetes/manifests/etcd.yamlfile ownership is set toroot:root.- Default Value
By default,
/etc/kubernetes/manifests/etcd.yamlfile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/manifests/etcd.yamlVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlcontrols various parameters that set the behavior of theetcdservice in the master node. etcd is a highly-available key-value store which Kubernetes uses for persistent storage of all of its REST API object. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/manifests/etcd.yaml
1.1.9Ensure that the Container Network Interface file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the Container Network Interface files have permissions of
600or more restrictive.- Default Value
NA
- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %a <path/to/cni/files>Verify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Container Network Interface provides various networking options for overlay networking. You should consult their documentation and restrict their respective file permissions to maintain the integrity of those files. Those files should be writable by only the administrators on the system.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 <path/to/cni/files>
1.1.10Ensure that the Container Network Interface file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the Container Network Interface files have ownership set to
root:root.- Default Value
NA
- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G <path/to/cni/files>Verify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Container Network Interface provides various networking options for overlay networking. You should consult their documentation and restrict their respective file permissions to maintain the integrity of those files. Those files should be owned by
root:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root <path/to/cni/files>
1.1.11Ensure that the etcd data directory permissions are set to 700 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the etcd data directory has permissions of
700or more restrictive.- Default Value
By default, etcd data directory has permissions of
755.- Audit Procedure
On the etcd server node, get the etcd data directory, passed as an argument
--data-dir, from the below command:ps -ef | grep etcdRun the below command (based on the etcd data directory found above). For example,stat -c %a /var/lib/etcdVerify that the permissions are700or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key-value store used by Kubernetes deployments for persistent storage of all of its REST API objects. This data directory should be protected from any unauthorized reads or writes. It should not be readable or writable by any group members or the world.
- Remediation Procedure
On the etcd server node, get the etcd data directory, passed as an argument
--data-dir, from the below command:ps -ef | grep etcdRun the below command (based on the etcd data directory found above). For example,chmod 700 /var/lib/etcd
1.1.12Ensure that the etcd data directory ownership is set to etcd:etcd0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the etcd data directory ownership is set to
etcd:etcd.- Default Value
By default, etcd data directory ownership is set to
etcd:etcd.- Audit Procedure
On the etcd server node, get the etcd data directory, passed as an argument
--data-dir, from the below command:ps -ef | grep etcdRun the below command (based on the etcd data directory found above). For example,stat -c %U:%G /var/lib/etcdVerify that the ownership is set toetcd:etcd.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key-value store used by Kubernetes deployments for persistent storage of all of its REST API objects. This data directory should be protected from any unauthorized reads or writes. It should be owned by
etcd:etcd.- Remediation Procedure
On the etcd server node, get the etcd data directory, passed as an argument
--data-dir, from the below command:ps -ef | grep etcdRun the below command (based on the etcd data directory found above). For example,chown etcd:etcd /var/lib/etcd
1.1.13Ensure that the default administrative credential file permissions are set to 6000
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
admin.conffile (andsuper-admin.conffile, where it exists) have permissions of600.- Default Value
By default, admin.conf and super-admin.conf have permissions of
600.- Audit Procedure
Run the following command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/admin.confOn Kubernetes version 1.29 and higher run the following command as well :-stat -c %a /etc/kubernetes/super-admin.confVerify that the permissions are
600or more restrictive.- Impact Statement
None.
- Assessment Status
Automated
- Rationale Statement
As part of initial cluster setup, default kubeconfig files are created to be used by the administrator of the cluster. These files contain private keys and certificates which allow for privileged access to the cluster. You should restrict their file permissions to maintain the integrity and confidentiality of the file(s). The file(s) should be readable and writable by only the administrators on the system.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/admin.confOn Kubernetes 1.29+ the
super-admin.conffile should also be modified, if present. For example, chmod 600 /etc/kubernetes/super-admin.conf
1.1.14Ensure that the default administrative credential file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
admin.conf(andsuper-admin.conffile, where it exists) file ownership is set toroot:root.- Default Value
By default,
admin.confandsuper-admin.conffile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/admin.confOn Kubernetes version 1.29 and higher run the following command as well :-stat -c %U:%G /etc/kubernetes/super-admin.confVerify that the ownership is set to
root:root.- Impact Statement
None.
- Assessment Status
Automated
- Rationale Statement
As part of initial cluster setup, default kubeconfig files are created to be used by the administrator of the cluster. These files contain private keys and certificates which allow for privileged access to the cluster. You should set their file ownership to maintain the integrity and confidentiality of the file. The file(s) should be owned by root:root.
- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/admin.confOn Kubernetes 1.29+ the super-admin.conf file should also be modified, if present. For example,chown root:root /etc/kubernetes/super-admin.conf
1.1.15Ensure that the scheduler.conf file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
scheduler.conffile has permissions of600or more restrictive.- Default Value
By default,
scheduler.confhas permissions of640.- Audit Procedure
Run the following command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/scheduler.confVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
scheduler.conffile is the kubeconfig file for the Scheduler. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/scheduler.conf
1.1.16Ensure that the scheduler.conf file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
scheduler.conffile ownership is set toroot:root.- Default Value
By default,
scheduler.conffile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/scheduler.confVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
scheduler.conffile is the kubeconfig file for the Scheduler. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/scheduler.conf
1.1.17Ensure that the controller-manager.conf file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
controller-manager.conffile has permissions of 600 or more restrictive.- Default Value
By default,
controller-manager.confhas permissions of640.- Audit Procedure
Run the following command (based on the file location on your system) on the Control Plane node. For example,stat -c %a /etc/kubernetes/controller-manager.confVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
controller-manager.conffile is the kubeconfig file for the Controller Manager. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod 600 /etc/kubernetes/controller-manager.conf
1.1.18Ensure that the controller-manager.conf file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the
controller-manager.conffile ownership is set toroot:root.- Default Value
By default,
controller-manager.conffile ownership is set toroot:root.- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c %U:%G /etc/kubernetes/controller-manager.confVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
controller-manager.conffile is the kubeconfig file for the Controller Manager. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown root:root /etc/kubernetes/controller-manager.conf
1.1.19Ensure that the Kubernetes PKI directory and file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that the Kubernetes PKI directory and file ownership is set to
root:root.- Default Value
By default, the /etc/kubernetes/pki/ directory and all of the files and directories contained within it, are set to be owned by the root user.
- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,ls -laR /etc/kubernetes/pki/Verify that the ownership of all files and directories in this hierarchy is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Kubernetes makes use of a number of certificates as part of its operation. You should set the ownership of the directory containing the PKI information and all files in that directory to maintain their integrity. The directory and files should be owned by
root:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chown -R root:root /etc/kubernetes/pki/
1.1.20Ensure that the Kubernetes PKI certificate file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that Kubernetes PKI certificate files have permissions of
600or more restrictive.- Default Value
By default, the certificates used by Kubernetes are set to have permissions of
644- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c '%a' /etc/kubernetes/pki/.crtVerify that the permissions are
600or more restrictive.orls -l /etc/kubernetes/pki/.crtVerify -rw------- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Kubernetes makes use of a number of certificate files as part of the operation of its components. The permissions on these files should be set to
600or more restrictive to protect their integrity and confidentiality.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod -R 600 /etc/kubernetes/pki/*.crt
1.1.21Ensure that the Kubernetes PKI key file permissions are set to 6000
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.1 Control Plane Node Configuration Files
- Description
Ensure that Kubernetes PKI key files have permissions of
600.- Default Value
By default, the keys used by Kubernetes are set to have permissions of
600- Audit Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,stat -c '%a' /etc/kubernetes/pki/.keyVerify that the permissions are
600or more restrictive.orls -l /etc/kubernetes/pki/.keyVerify -rw------- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Kubernetes makes use of a number of key files as part of the operation of its components. The permissions on these files should be set to
600to protect their integrity and confidentiality.- Remediation Procedure
Run the below command (based on the file location on your system) on the Control Plane node. For example,chmod -R 600 /etc/kubernetes/pki/*.key
1.2.1Ensure that the --anonymous-auth argument is set to false1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Disable anonymous requests to the API server.
- Default Value
By default, anonymous access is enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--anonymous-authargument is set tofalse.Alternative Auditkubectl get pod -nkube-system -lcomponent=kube-apiserver -o=jsonpath='{range .items[]}{.spec.containers[].command} {}{end}' | grep '--anonymous-auth' | grep -i falseIf the exit code is '1', then the control isn't present / failed- Impact Statement
Anonymous requests will be rejected.
- Assessment Status
Manual
- Rationale Statement
When enabled, requests that are not rejected by other configured authentication methods are treated as anonymous requests. These requests are then served by the API server. You should rely on authentication to authorize access and disallow anonymous requests.If you are using RBAC authorization, it is generally considered reasonable to allow anonymous access to the API Server for health checks and discovery purposes, and hence this recommendation is not scored. However, you should consider whether anonymous discovery is an acceptable risk for your purposes.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the below parameter.--anonymous-auth=false
1.2.2Ensure that the --token-auth-file parameter is not set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Do not use token based authentication.
- Default Value
By default,
--token-auth-fileargument is not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--token-auth-fileargument does not exist.Alternative Audit Methodkubectl get pod -nkube-system -lcomponent=kube-apiserver -o=jsonpath='{range .items[]}{.spec.containers[].command} {}{end}' | grep '--token-auth-file' | grep -i falseIf the exit code is '1', then the control isn't present / failed- Impact Statement
You will have to configure and use alternate authentication mechanisms such as certificates. Static token based authentication could not be used.
- Assessment Status
Automated
- Rationale Statement
The token-based authentication utilizes static tokens to authenticate requests to the apiserver. The tokens are stored in clear-text in a file on the apiserver, and cannot be revoked or rotated without restarting the apiserver. Hence, do not use static token-based authentication.
- Remediation Procedure
Follow the documentation and configure alternate mechanisms for authentication. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and remove the--token-auth-file=<filename>parameter.
1.2.3Ensure that the DenyServiceExternalIPs is set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
This admission controller rejects all net-new usage of the Service field externalIPs.
- Default Value
By default, --enable-admission-plugins=DenyServiceExternalIP argument is not set, and the use of externalIPs is authorized.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the `DenyServiceExternalIPs' argument exist as a string value in --enable-admission-plugins.
- Impact Statement
When enabled, users of the cluster may not create new Services which use externalIPs and may not add new values to externalIPs on existing Service objects.
- Assessment Status
Manual
- Rationale Statement
Most users do not need the ability to set the
externalIPsfield for aServiceat all, and cluster admins should consider disabling this functionality by enabling theDenyServiceExternalIPsadmission controller. Clusters that do need to allow this functionality should consider using some custom policy to manage its usage.- Remediation Procedure
Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the master node and append the Kubernetes API server flag --enable-admission-plugins with the DenyServiceExternalIPs plugin. Note, the Kubernetes API server flag --enable-admission-plugins takes a comma-delimited list of admission control plugins to be enabled, even if they are in the list of plugins enabled by default.kube-apiserver --enable-admission-plugins=DenyServiceExternalIPs
1.2.4Ensure that the --kubelet-client-certificate and --kubelet-client-key arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Enable certificate based kubelet authentication.
- Default Value
By default, certificate-based kubelet authentication is not set.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--kubelet-client-certificateand--kubelet-client-keyarguments exist and they are set as appropriate.Alternative Auditkubectl get pod -nkube-system -lcomponent=kube-apiserver -o=jsonpath='{range .items[]}{.spec.containers[].command} {}{end}' | grep '--kubelet-client-certificate' | grep -i falseIf the exit code is '1', then the control isn't present / failed- Impact Statement
You require TLS to be configured on apiserver as well as kubelets.
- Assessment Status
Automated
- Rationale Statement
The apiserver, by default, does not authenticate itself to the kubelet's HTTPS endpoints. The requests from the apiserver are treated anonymously. You should set up certificate-based kubelet authentication to ensure that the apiserver authenticates itself to kubelets when submitting requests.
- Remediation Procedure
Follow the Kubernetes documentation and set up the TLS connection between the apiserver and kubelets. Then, edit API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the kubelet client certificate and key parameters as below.--kubelet-client-certificate=<path/to/client-certificate-file>--kubelet-client-key=<path/to/client-key-file>
1.2.5Ensure that the --kubelet-certificate-authority argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Verify kubelet's certificate before establishing connection.
- Default Value
By default,
--kubelet-certificate-authorityargument is not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--kubelet-certificate-authorityargument exists and is set as appropriate.Alternative Auditkubectl get pod -nkube-system -lcomponent=kube-apiserver -o=jsonpath='{range .items[]}{.spec.containers[].command} {}{end}' | grep '--kubelet-certificate-Authority' | grep -i falseIf the exit code is '1', then the control isn't present / failed- Impact Statement
You require TLS to be configured on apiserver as well as kubelets.
- Assessment Status
Automated
- Rationale Statement
The connections from the apiserver to the kubelet are used for fetching logs for pods, attaching (through kubectl) to running pods, and using the kubelet’s port-forwarding functionality. These connections terminate at the kubelet’s HTTPS endpoint. By default, the apiserver does not verify the kubelet’s serving certificate, which makes the connection subject to man-in-the-middle attacks, and unsafe to run over untrusted and/or public networks.
- Remediation Procedure
Follow the Kubernetes documentation and setup the TLS connection between the apiserver and kubelets. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--kubelet-certificate-authorityparameter to the path to the cert file for the certificate authority.--kubelet-certificate-authority=<ca-string>
1.2.6Ensure that the --authorization-mode argument is not set to AlwaysAllow1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- References
- https://kubernetes.io/docs/admin/kube-apiserver/:https://kubernetes.io/docs/admin/authorization/
- Sub Section
1.2 API Server
- Description
Do not always authorize all requests.
- Default Value
By default,
AlwaysAllowis not enabled.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--authorization-modeargument exists and is not set toAlwaysAllow.- Impact Statement
Only authorized requests will be served.
- Assessment Status
Automated
- Rationale Statement
The API Server, can be configured to allow all requests. This mode should not be used on any production cluster.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--authorization-modeparameter to values other thanAlwaysAllow. One such example could be as below.--authorization-mode=RBAC
1.2.7Ensure that the --authorization-mode argument includes Node1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Restrict kubelet nodes to reading only objects associated with them.
- Default Value
By default,
Nodeauthorization is not enabled.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--authorization-modeargument exists and is set to a value to includeNode.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
Nodeauthorization mode only allows kubelets to readSecret,ConfigMap,PersistentVolume, andPersistentVolumeClaimobjects associated with their nodes.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--authorization-modeparameter to a value that includesNode.--authorization-mode=Node,RBAC
1.2.8Ensure that the --authorization-mode argument includes RBAC1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Turn on Role Based Access Control.
- Default Value
By default,
RBACauthorization is not enabled.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--authorization-modeargument exists and is set to a value to includeRBAC.- Impact Statement
When RBAC is enabled you will need to ensure that appropriate RBAC settings (including Roles, RoleBindings and ClusterRoleBindings) are configured to allow appropriate access.
- Assessment Status
Automated
- Rationale Statement
Role Based Access Control (RBAC) allows fine-grained control over the operations that different entities can perform on different objects in the cluster. It is recommended to use the RBAC authorization mode.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--authorization-modeparameter to a value that includesRBAC, for example:--authorization-mode=Node,RBAC
1.2.9Ensure that the admission control plugin EventRateLimit is set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Limit the rate at which the API server accepts requests.
- Default Value
By default,
EventRateLimitis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--enable-admission-pluginsargument is set to a value that includesEventRateLimit.- Impact Statement
You need to carefully tune in limits as per your environment.
- Assessment Status
Manual
- Rationale Statement
Using
EventRateLimitadmission control enforces a limit on the number of events that the API Server will accept in a given time slice. A misbehaving workload could overwhelm and DoS the API Server, making it unavailable. This particularly applies to a multi-tenant cluster, where there might be a small percentage of misbehaving tenants which could have a significant impact on the performance of the cluster overall. Hence, it is recommended to limit the rate of events that the API server will accept.- Remediation Procedure
Follow the Kubernetes documentation and set the desired limits in a configuration file.Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamland set the below parameters.--enable-admission-plugins=...,EventRateLimit,...--admission-control-config-file=<path/to/configuration/file>
1.2.10Ensure that the admission control plugin AlwaysAdmit is not set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Do not allow all requests.
- Default Value
AlwaysAdmitis not in the list of default admission plugins.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that if the
--enable-admission-pluginsargument is set, its value does not includeAlwaysAdmit.- Impact Statement
Only requests explicitly allowed by the admissions control plugins would be served.
- Assessment Status
Automated
- Rationale Statement
Setting admission control plugin
AlwaysAdmitallows all requests and do not filter any requests.TheAlwaysAdmitadmission controller was deprecated in Kubernetes v1.13. Its behavior was equivalent to turning off all admission controllers.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and either remove the--enable-admission-pluginsparameter, or set it to a value that does not includeAlwaysAdmit.
1.2.11Ensure that the admission control plugin AlwaysPullImages is set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Always pull images.
- Default Value
By default,
AlwaysPullImagesis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--enable-admission-pluginsargument is set to a value that includesAlwaysPullImages.- Impact Statement
Credentials would be required to pull the private images every time. Also, in trusted environments, this might increases load on network, registry, and decreases speed.This setting could impact offline or isolated clusters, which have images pre-loaded and do not have access to a registry to pull in-use images. This setting is not appropriate for clusters which use this configuration.
- Assessment Status
Manual
- Rationale Statement
Setting admission control policy to
AlwaysPullImagesforces every new pod to pull the required images every time. In a multi-tenant cluster users can be assured that their private images can only be used by those who have the credentials to pull them. Without this admission control policy, once an image has been pulled to a node, any pod from any user can use it simply by knowing the image’s name, without any authorization check against the image ownership. When this plug-in is enabled, images are always pulled prior to starting containers, which means valid credentials are required.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--enable-admission-pluginsparameter to includeAlwaysPullImages.--enable-admission-plugins=...,AlwaysPullImages,...
1.2.12Ensure that the admission control plugin ServiceAccount is set1
Attributes
- Profile
Level 2
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Automate service accounts management.
- Default Value
By default,
ServiceAccountis set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--disable-admission-pluginsargument is set to a value that does not includesServiceAccount.- Impact Statement
None.
- Assessment Status
Automated
- Rationale Statement
When you create a pod, if you do not specify a service account, it is automatically assigned the
defaultservice account in the same namespace. You should create your own service account and let the API server manage its security tokens.- Remediation Procedure
Follow the documentation and create
ServiceAccountobjects as per your environment. Then, edit the API server pod specification file/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and ensure that the--disable-admission-pluginsparameter is set to a value that does not includeServiceAccount.
1.2.13Ensure that the admission control plugin NamespaceLifecycle is set1
Attributes
- Profile
Level 2
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Reject creating objects in a namespace that is undergoing termination.
- Default Value
By default,
NamespaceLifecycleis set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--disable-admission-pluginsargument is set to a value that does not includeNamespaceLifecycle.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Setting admission control policy to
NamespaceLifecycleensures that objects cannot be created in non-existent namespaces, and that namespaces undergoing termination are not used for creating the new objects. This is recommended to enforce the integrity of the namespace termination process and also for the availability of the newer objects.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--disable-admission-pluginsparameter to ensure it does not includeNamespaceLifecycle.
1.2.14Ensure that the admission control plugin NodeRestriction is set1
Attributes
- Profile
Level 2
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Limit the
NodeandPodobjects that a kubelet could modify.- Default Value
By default,
NodeRestrictionis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--enable-admission-pluginsargument is set to a value that includesNodeRestriction.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Using the
NodeRestrictionplug-in ensures that the kubelet is restricted to theNodeandPodobjects that it could modify as defined. Such kubelets will only be allowed to modify their ownNodeAPI object, and only modifyPodAPI objects that are bound to their node.- Remediation Procedure
Follow the Kubernetes documentation and configure
NodeRestrictionplug-in on kubelets. Then, edit the API server pod specification file/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the--enable-admission-pluginsparameter to a value that includesNodeRestriction.--enable-admission-plugins=...,NodeRestriction,...
1.2.15Ensure that the --profiling argument is set to false1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Disable profiling, if not needed.
- Default Value
By default, profiling is enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--profilingargument is set tofalse.- Impact Statement
Profiling information would not be available.
- Assessment Status
Automated
- Rationale Statement
Profiling allows for the identification of specific performance bottlenecks. It generates a significant amount of program data that could potentially be exploited to uncover system and program details. If you are not experiencing any bottlenecks and do not need the profiler for troubleshooting purposes, it is recommended to turn it off to reduce the potential attack surface.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the below parameter.--profiling=false
1.2.16Ensure that the --audit-log-path argument is set1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Enable auditing on the Kubernetes API Server and set the desired audit log path.
- Default Value
By default, auditing is not enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--audit-log-pathargument is set as appropriate.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Auditing the Kubernetes API Server provides a security-relevant chronological set of records documenting the sequence of activities that have affected system by individual users, administrators or other components of the system. Even though currently, Kubernetes provides only basic audit capabilities, it should be enabled. You can enable it by setting an appropriate audit log path.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--audit-log-pathparameter to a suitable path and file where you would like audit logs to be written, for example:--audit-log-path=/var/log/apiserver/audit.log
1.2.17Ensure that the --audit-log-maxage argument is set to 30 or as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Retain the logs for at least 30 days or as appropriate.
- Default Value
By default, auditing is not enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--audit-log-maxageargument is set to30or as appropriate.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Retaining logs for at least 30 days ensures that you can go back in time and investigate or correlate any events. Set your audit log retention period to 30 days or as per your business requirements.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--audit-log-maxageparameter to 30 or as an appropriate number of days:--audit-log-maxage=30
1.2.18Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Retain 10 or an appropriate number of old log files.
- Default Value
By default, auditing is not enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--audit-log-maxbackupargument is set to10or as appropriate.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Kubernetes automatically rotates the log files. Retaining old log files ensures that you would have sufficient log data available for carrying out any investigation or correlation. For example, if you have set file size of 100 MB and the number of old log files to keep as 10, you would approximate have 1 GB of log data that you could potentially use for your analysis.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--audit-log-maxbackupparameter to 10 or to an appropriate value.--audit-log-maxbackup=10
1.2.19Ensure that the --audit-log-maxsize argument is set to 100 or as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Rotate log files on reaching 100 MB or as appropriate.
- Default Value
By default, auditing is not enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--audit-log-maxsizeargument is set to100or as appropriate.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
Kubernetes automatically rotates the log files. Retaining old log files ensures that you would have sufficient log data available for carrying out any investigation or correlation. If you have set file size of 100 MB and the number of old log files to keep as 10, you would approximate have 1 GB of log data that you could potentially use for your analysis.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--audit-log-maxsizeparameter to an appropriate size in MB. For example, to set it as 100 MB:--audit-log-maxsize=100
1.2.20Ensure that the --request-timeout argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- References
- https://kubernetes.io/docs/admin/kube-apiserver/:https://github.com/kubernetes/kubernetes/pull/51415
- Sub Section
1.2 API Server
- Description
Set global request timeout for API server requests as appropriate.
- Default Value
By default,
--request-timeoutis set to 60 seconds.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--request-timeoutargument is either not set or set to an appropriate value.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Setting global request timeout allows extending the API server request timeout limit to a duration appropriate to the user's connection speed. By default, it is set to 60 seconds which might be problematic on slower connections making cluster resources inaccessible once the data volume for requests exceeds what can be transmitted in 60 seconds. But, setting this timeout limit to be too large can exhaust the API server resources making it prone to Denial-of-Service attack. Hence, it is recommended to set this limit as appropriate and change the default limit of 60 seconds only if needed.
- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamland set the below parameter as appropriate and if needed. For example,--request-timeout=300s
1.2.21Ensure that the --service-account-lookup argument is set to true1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Validate service account before validating token.
- Default Value
By default,
--service-account-lookupargument is set totrue.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that if the
--service-account-lookupargument exists it is set totrue.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
If
--service-account-lookupis not enabled, the apiserver only verifies that the authentication token is valid, and does not validate that the service account token mentioned in the request is actually present in etcd. This allows using a service account token even after the corresponding service account is deleted. This is an example of time of check to time of use security issue.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the below parameter. --service-account-lookup=trueAlternatively, you can delete the--service-account-lookupparameter from this file so that the default takes effect.
1.2.22Ensure that the --service-account-key-file argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Explicitly set a service account public key file for service accounts on the apiserver.
- Default Value
By default,
--service-account-key-fileargument is not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--service-account-key-fileargument exists and is set as appropriate.- Impact Statement
The corresponding private key must be provided to the controller manager. You would need to securely maintain the key file and rotate the keys based on your organization's key rotation policy.
- Assessment Status
Automated
- Rationale Statement
By default, if no
--service-account-key-fileis specified to the apiserver, it uses the private key from the TLS serving certificate to verify service account tokens. To ensure that the keys for service account tokens could be rotated as needed, a separate public/private key pair should be used for signing service account tokens. Hence, the public key should be specified to the apiserver with--service-account-key-file.- Remediation Procedure
Edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the Control Plane node and set the--service-account-key-fileparameter to the public key file for service accounts:--service-account-key-file=<filename>
1.2.23Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
etcd should be configured to make use of TLS encryption for client connections.
- Default Value
By default,
--etcd-certfileand--etcd-keyfilearguments are not set- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--etcd-certfileand--etcd-keyfilearguments exist and they are set as appropriate.- Impact Statement
TLS and client certificate authentication must be configured for etcd.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be protected by client authentication. This requires the API server to identify itself to the etcd server using a client certificate and key.
- Remediation Procedure
Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the etcd certificate and key file parameters.--etcd-certfile=<path/to/client-certificate-file> --etcd-keyfile=<path/to/client-key-file>
1.2.24Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Setup TLS connection on the API server.
- Default Value
By default,
--tls-cert-fileand--tls-private-key-fileare presented and created for use.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--tls-cert-fileand--tls-private-key-filearguments exist and they are set as appropriate.- Impact Statement
TLS and client certificate authentication must be configured for your Kubernetes cluster deployment.
- Assessment Status
Automated
- Rationale Statement
API server communication contains sensitive parameters that should remain encrypted in transit. Configure the API server to serve only HTTPS traffic.
- Remediation Procedure
Follow the Kubernetes documentation and set up the TLS connection on the apiserver. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the TLS certificate and private key file parameters.--tls-cert-file=<path/to/tls-certificate-file> --tls-private-key-file=<path/to/tls-key-file>
1.2.25Ensure that the --client-ca-file argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Setup TLS connection on the API server.
- Default Value
By default,
--client-ca-fileargument is not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--client-ca-fileargument exists and it is set as appropriate.- Impact Statement
TLS and client certificate authentication must be configured for your Kubernetes cluster deployment.
- Assessment Status
Automated
- Rationale Statement
API server communication contains sensitive parameters that should remain encrypted in transit. Configure the API server to serve only HTTPS traffic. If
--client-ca-fileargument is set, any request presenting a client certificate signed by one of the authorities in theclient-ca-fileis authenticated with an identity corresponding to the CommonName of the client certificate.- Remediation Procedure
Follow the Kubernetes documentation and set up the TLS connection on the apiserver. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the client certificate authority file.--client-ca-file=<path/to/client-ca-file>
1.2.26Ensure that the --etcd-cafile argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
etcd should be configured to make use of TLS encryption for client connections.
- Default Value
By default,
--etcd-cafileis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--etcd-cafileargument exists and it is set as appropriate.- Impact Statement
TLS and client certificate authentication must be configured for etcd.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be protected by client authentication. This requires the API server to identify itself to the etcd server using a SSL Certificate Authority file.
- Remediation Procedure
Follow the Kubernetes documentation and set up the TLS connection between the apiserver and etcd. Then, edit the API server pod specification file
/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the etcd certificate authority file parameter.--etcd-cafile=<path/to/ca-file>
1.2.27Ensure that the --encryption-provider-config argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Encrypt etcd key-value store.
- Default Value
By default,
--encryption-provider-configis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--encryption-provider-configargument is set to aEncryptionConfigfile. Additionally, ensure that theEncryptionConfigfile has all the desiredresourcescovered especially any secrets.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
etcd is a highly available key-value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be encrypted at rest to avoid any disclosures.
- Remediation Procedure
Follow the Kubernetes documentation and configure a
EncryptionConfigfile. Then, edit the API server pod specification file/etc/kubernetes/manifests/kube-apiserver.yamlon the master node and set the--encryption-provider-configparameter to the path of that file:--encryption-provider-config=</path/to/EncryptionConfig/File>
1.2.28Ensure that encryption providers are appropriately configured0
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Where
etcdencryption is used, appropriate providers should be configured.- Default Value
By default, no encryption provider is set.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverGet the
EncryptionConfigfile set for--encryption-provider-configargument. Verify thataescbc,kmsorsecretboxis set as the encryption provider for all the desiredresources.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Where
etcdencryption is used, it is important to ensure that the appropriate set of encryption providers is used. Currently, theaescbc,kmsandsecretboxare likely to be appropriate options.- Remediation Procedure
Follow the Kubernetes documentation and configure a
EncryptionConfigfile. In this file, chooseaescbc,kmsorsecretboxas the encryption provider.
1.2.29Ensure that the API Server only makes use of Strong Cryptographic Ciphers1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.2 API Server
- Description
Ensure that the API server is configured to only use strong cryptographic ciphers.
- Default Value
By default the Kubernetes API server supports a wide range of TLS ciphers
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-apiserverVerify that the
--tls-cipher-suitesargument is set as outlined in the remediation procedure below.- Impact Statement
API server clients that cannot support modern cryptographic ciphers will not be able to make connections to the API server.
- Assessment Status
Manual
- Rationale Statement
TLS ciphers have had a number of known vulnerabilities and weaknesses, which can reduce the protection provided by them. By default Kubernetes supports a number of TLS ciphersuites including some that have security concerns, weakening the protection provided.
- Remediation Procedure
Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the Control Plane node and set the below parameter.--tls-cipher-suites=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_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.
- Additional Information
Insecure values: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_RC4_128_SHA.
1.3.1Ensure that the --terminated-pod-gc-threshold argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Activate garbage collector on pod termination, as appropriate.
- Default Value
By default,
--terminated-pod-gc-thresholdis set to12500.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--terminated-pod-gc-thresholdargument is set as appropriate.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Garbage collection is important to ensure sufficient resource availability and avoiding degraded performance and availability. In the worst case, the system might crash or just be unusable for a long period of time. The current setting for garbage collection is 12,500 terminated pods which might be too high for your system to sustain. Based on your system resources and tests, choose an appropriate threshold value to activate garbage collection.
- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and set the--terminated-pod-gc-thresholdto an appropriate threshold, for example:--terminated-pod-gc-threshold=10
1.3.2Ensure that the --profiling argument is set to false1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Disable profiling, if not needed.
- Default Value
By default, profiling is enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--profilingargument is set tofalse.- Impact Statement
Profiling information would not be available.
- Assessment Status
Automated
- Rationale Statement
Profiling allows for the identification of specific performance bottlenecks. It generates a significant amount of program data that could potentially be exploited to uncover system and program details. If you are not experiencing any bottlenecks and do not need the profiler for troubleshooting purposes, it is recommended to turn it off to reduce the potential attack surface.
- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and set the below parameter.--profiling=false
1.3.3Ensure that the --use-service-account-credentials argument is set to true1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Use individual service account credentials for each controller.
- Default Value
By default,
--use-service-account-credentialsis set to false.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--use-service-account-credentialsargument is set totrue.- Impact Statement
Whatever authorizer is configured for the cluster, it must grant sufficient permissions to the service accounts to perform their intended tasks. When using the RBAC authorizer, those roles are created and bound to the appropriate service accounts in the
kube-systemnamespace automatically with default roles and rolebindings that are auto-reconciled on startup.If using other authorization methods (ABAC, Webhook, etc), the cluster deployer is responsible for granting appropriate permissions to the service accounts (the required permissions can be seen by inspecting thecontroller-roles.yamlandcontroller-role-bindings.yamlfiles for the RBAC roles.- Assessment Status
Automated
- Rationale Statement
The controller manager creates a service account per controller in the
kube-systemnamespace, generates a credential for it, and builds a dedicated API client with that service account credential for each controller loop to use. Setting the--use-service-account-credentialstotrueruns each control loop within the controller manager using a separate service account credential. When used in combination with RBAC, this ensures that the control loops run with the minimum permissions required to perform their intended tasks.- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node to set the below parameter.--use-service-account-credentials=true
1.3.4Ensure that the --service-account-private-key-file argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Explicitly set a service account private key file for service accounts on the controller manager.
- Default Value
By default,
--service-account-private-key-fileit not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--service-account-private-key-fileargument is set as appropriate.- Impact Statement
You would need to securely maintain the key file and rotate the keys based on your organization's key rotation policy.
- Assessment Status
Automated
- Rationale Statement
To ensure that keys for service account tokens can be rotated as needed, a separate public/private key pair should be used for signing service account tokens. The private key should be specified to the controller manager with
--service-account-private-key-fileas appropriate.- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and set the--service-account-private-key-fileparameter to the private key file for service accounts.--service-account-private-key-file=<filename>
1.3.5Ensure that the --root-ca-file argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Allow pods to verify the API server's serving certificate before establishing connections.
- Default Value
By default,
--root-ca-fileis not set.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--root-ca-fileargument exists and is set to a certificate bundle file containing the root certificate for the API server's serving certificate.- Impact Statement
You need to setup and maintain root certificate authority file.
- Assessment Status
Automated
- Rationale Statement
Processes running within pods that need to contact the API server must verify the API server's serving certificate. Failing to do so could be a subject to man-in-the-middle attacks.Providing the root certificate for the API server's serving certificate to the controller manager with the
--root-ca-fileargument allows the controller manager to inject the trusted bundle into pods so that they can verify TLS connections to the API server.- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and set the--root-ca-fileparameter to the certificate bundle file`.--root-ca-file=<path/to/file>
1.3.6Ensure that the RotateKubeletServerCertificate argument is set to true1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.3 Controller Manager
- Description
Enable kubelet server certificate rotation on controller-manager.
- Default Value
By default,
RotateKubeletServerCertificateis set to "true" this recommendation verifies that it has not been disabled.- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that
RotateKubeletServerCertificateargument exists and is set totrue.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
RotateKubeletServerCertificatecauses the kubelet to both request a serving certificate after bootstrapping its client credentials and rotate the certificate as its existing credentials expire. This automated periodic rotation ensures that the there are no downtimes due to expired certificates and thus addressing availability in the CIA security triad.Note: This recommendation only applies if you let kubelets get their certificates from the API server. In case your kubelet certificates come from an outside authority/tool (e.g. Vault) then you need to take care of rotation yourself.- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and set the--feature-gatesparameter to includeRotateKubeletServerCertificate=true.--feature-gates=RotateKubeletServerCertificate=true
1.3.7Ensure that the --bind-address argument is set to 127.0.0.11
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- References
- https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/
- Sub Section
1.3 Controller Manager
- Description
Do not bind the Controller Manager service to non-loopback insecure addresses.
- Default Value
By default, the
--bind-addressparameter is set to 0.0.0.0- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-controller-managerVerify that the
--bind-addressargument is set to 127.0.0.1- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The Controller Manager API service which runs on port 10252/TCP by default is used for health and metrics information and is available without authentication or encryption. As such it should only be bound to a localhost interface, to minimize the cluster's attack surface
- Remediation Procedure
Edit the Controller Manager pod specification file
/etc/kubernetes/manifests/kube-controller-manager.yamlon the Control Plane node and ensure the correct value for the--bind-addressparameter- Additional Information
Although the current Kubernetes documentation site says that
--addressis deprecated in favour of--bind-addressKubeadm 1.11 still makes use of--address
1.4.1Ensure that the --profiling argument is set to false1
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.4 Scheduler
- Description
Disable profiling, if not needed.
- Default Value
By default, profiling is enabled.
- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-schedulerVerify that the
--profilingargument is set tofalse.- Impact Statement
Profiling information would not be available.
- Assessment Status
Automated
- Rationale Statement
Profiling allows for the identification of specific performance bottlenecks. It generates a significant amount of program data that could potentially be exploited to uncover system and program details. If you are not experiencing any bottlenecks and do not need the profiler for troubleshooting purposes, it is recommended to turn it off to reduce the potential attack surface.
- Remediation Procedure
Edit the Scheduler pod specification file
/etc/kubernetes/manifests/kube-scheduler.yamlfile on the Control Plane node and set the below parameter.--profiling=false
1.4.2Ensure that the --bind-address argument is set to 127.0.0.11
Attributes
- Profile
Level 1
- Section
1 Control Plane Components
- Sub Section
1.4 Scheduler
- Description
Do not bind the scheduler service to non-loopback insecure addresses.
- Default Value
By default, the
--bind-addressparameter is set to 0.0.0.0- Audit Procedure
Run the following command on the Control Plane node:ps -ef | grep kube-schedulerVerify that the
--bind-addressargument is set to 127.0.0.1- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The Scheduler API service which runs on port 10251/TCP by default is used for health and metrics information and is available without authentication or encryption. As such it should only be bound to a localhost interface, to minimize the cluster's attack surface
- Remediation Procedure
Edit the Scheduler pod specification file
/etc/kubernetes/manifests/kube-scheduler.yamlon the Control Plane node and ensure the correct value for the--bind-addressparameter
2 etcd77
2.1Ensure that the --cert-file and --key-file arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
2 etcd
- References
- https://coreos.com/etcd/docs/latest/op-guide/security.html:https://kubernetes.io/docs/admin/etcd/
- Description
Configure TLS encryption for the etcd service.
- Default Value
By default, TLS encryption is not set.
- Audit Procedure
Run the following command on the etcd server nodeps -ef | grep etcdVerify that the
--cert-fileand the--key-filearguments are set as appropriate.- Impact Statement
Client connections only over TLS would be served.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be encrypted in transit.
- Remediation Procedure
Follow the etcd service documentation and configure TLS encryption.Then, edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and set the below parameters.--cert-file=</path/to/ca-file>--key-file=</path/to/key-file>
2.2Ensure that the --client-cert-auth argument is set to true1
Attributes
- Profile
Level 1
- Section
2 etcd
- Description
Enable client authentication on etcd service.
- Default Value
By default, the etcd service can be queried by unauthenticated clients.
- Audit Procedure
Run the following command on the etcd server node:ps -ef | grep etcdVerify that the
--client-cert-authargument is set totrue.- Impact Statement
All clients attempting to access the etcd server will require a valid client certificate.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should not be available to unauthenticated clients. You should enable the client authentication via valid certificates to secure the access to the etcd service.
- Remediation Procedure
Edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and set the below parameter.--client-cert-auth="true
2.3Ensure that the --auto-tls argument is not set to true1
Attributes
- Profile
Level 1
- Section
2 etcd
- Description
Do not use self-signed certificates for TLS.
- Default Value
By default,
--auto-tlsis set tofalse.- Audit Procedure
Run the following command on the etcd server node:ps -ef | grep etcdVerify that if the
--auto-tlsargument exists, it is not set totrue.- Impact Statement
Clients will not be able to use self-signed certificates for TLS.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should not be available to unauthenticated clients. You should enable the client authentication via valid certificates to secure the access to the etcd service.
- Remediation Procedure
Edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and either remove the--auto-tlsparameter or set it tofalse.--auto-tls=false
2.4Ensure that the --peer-cert-file and --peer-key-file arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
2 etcd
- References
- https://coreos.com/etcd/docs/latest/op-guide/security.html:https://kubernetes.io/docs/admin/etcd/
- Description
etcd should be configured to make use of TLS encryption for peer connections.
- Default Value
Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.By default, peer communication over TLS is not configured.
- Audit Procedure
Run the following command on the etcd server node:ps -ef | grep etcdVerify that the
--peer-cert-fileand--peer-key-filearguments are set as appropriate.Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.- Impact Statement
etcd cluster peers would need to set up TLS for their communication.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be encrypted in transit and also amongst peers in the etcd clusters.
- Remediation Procedure
Follow the etcd service documentation and configure peer TLS encryption as appropriate for your etcd cluster.Then, edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and set the below parameters.--peer-client-file=</path/to/peer-cert-file>--peer-key-file=</path/to/peer-key-file>
2.5Ensure that the --peer-client-cert-auth argument is set to true1
Attributes
- Profile
Level 1
- Section
2 etcd
- Description
etcd should be configured for peer authentication.
- Default Value
Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.By default,
--peer-client-cert-authargument is set tofalse.- Audit Procedure
Run the following command on the etcd server node:ps -ef | grep etcdVerify that the
--peer-client-cert-authargument is set totrue.Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.- Impact Statement
All peers attempting to communicate with the etcd server will require a valid client certificate for authentication.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be accessible only by authenticated etcd peers in the etcd cluster.
- Remediation Procedure
Edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and set the below parameter.--peer-client-cert-auth=true
2.6Ensure that the --peer-auto-tls argument is not set to true1
Attributes
- Profile
Level 1
- Section
2 etcd
- Description
Do not use automatically generated self-signed certificates for TLS connections between peers.
- Default Value
Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.By default,
--peer-auto-tlsargument is set tofalse.- Audit Procedure
Run the following command on the etcd server node:ps -ef | grep etcdVerify that if the
--peer-auto-tlsargument exists, it is not set totrue.Note: This recommendation is applicable only for etcd clusters. If you are using only one etcd server in your environment then this recommendation is not applicable.- Impact Statement
All peers attempting to communicate with the etcd server will require a valid client certificate for authentication.
- Assessment Status
Automated
- Rationale Statement
etcd is a highly-available key value store used by Kubernetes deployments for persistent storage of all of its REST API objects. These objects are sensitive in nature and should be accessible only by authenticated etcd peers in the etcd cluster. Hence, do not use self-signed certificates for authentication.
- Remediation Procedure
Edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and either remove the--peer-auto-tlsparameter or set it tofalse.--peer-auto-tls=false
2.7Ensure that a unique Certificate Authority is used for etcd1
Attributes
- Profile
Level 2
- Section
2 etcd
- Description
Use a different certificate authority for etcd from the one used for Kubernetes.
- Default Value
By default, no etcd certificate is created and used.
- Audit Procedure
Review the CA used by the etcd environment and ensure that it does not match the CA certificate file used for the management of the overall Kubernetes cluster.Run the following command on the master node:ps -ef | grep etcdNote the file referenced by the
--trusted-ca-fileargument. Run the following command on the master node: ps -ef | grep apiserverVerify that the file referenced by the--client-ca-filefor apiserver is different from the--trusted-ca-fileused by etcd.- Impact Statement
Additional management of the certificates and keys for the dedicated certificate authority will be required.
- Assessment Status
Manual
- Rationale Statement
etcd is a highly available key-value store used by Kubernetes deployments for persistent storage of all of its REST API objects. Its access should be restricted to specifically designated clients and peers only. Authentication to etcd is based on whether the certificate presented was issued by a trusted certificate authority. There is no checking of certificate attributes such as common name or subject alternative name. As such, if any attackers were able to gain access to any certificate issued by the trusted certificate authority, they would be able to gain full access to the etcd database.
- Remediation Procedure
Follow the etcd documentation and create a dedicated certificate authority setup for the etcd service.Then, edit the etcd pod specification file
/etc/kubernetes/manifests/etcd.yamlon the master node and set the below parameter.--trusted-ca-file=</path/to/ca-file>
3 Control Plane Configuration50
3.1.1Client certificate authentication should not be used for users0
Attributes
- Profile
Level 1
- Section
3 Control Plane Configuration
- Sub Section
3.1 Authentication and Authorization
- Description
Kubernetes provides the option to use client certificates for user authentication. However as there is no way to revoke these certificates when a user leaves an organization or loses their credential, they are not suitable for this purpose.It is not possible to fully disable client certificate use within a cluster as it is used for component to component authentication.
- Default Value
Client certificate authentication is enabled by default.
- Audit Procedure
Review user access to the cluster and ensure that users are not making use of Kubernetes client certificate authentication.
- Impact Statement
External mechanisms for authentication generally require additional software to be deployed.
- Assessment Status
Manual
- Rationale Statement
With any authentication mechanism the ability to revoke credentials if they are compromised or no longer required, is a key control. Kubernetes client certificate authentication does not allow for this due to a lack of support for certificate revocation.
- Remediation Procedure
Alternative mechanisms provided by Kubernetes such as the use of OIDC should be implemented in place of client certificates.
- Additional Information
The lack of certificate revocation was flagged up as a high risk issue in the recent Kubernetes security audit. Without this feature, client certificate authentication is not suitable for end users.
3.1.2Service account token authentication should not be used for users0
Attributes
- Profile
Level 1
- Section
3 Control Plane Configuration
- Sub Section
3.1 Authentication and Authorization
- Description
Kubernetes provides service account tokens which are intended for use by workloads running in the Kubernetes cluster, for authentication to the API server.These tokens are not designed for use by end-users and do not provide for features such as revocation or expiry, making them insecure. A newer version of the feature (Bound service account token volumes) does introduce expiry but still does not allow for specific revocation.
- Default Value
Service account token authentication is enabled by default.
- Audit Procedure
Review user access to the cluster and ensure that users are not making use of service account token authentication.
- Impact Statement
External mechanisms for authentication generally require additional software to be deployed.
- Assessment Status
Manual
- Rationale Statement
With any authentication mechanism the ability to revoke credentials if they are compromised or no longer required, is a key control. Service account token authentication does not allow for this due to the use of JWT tokens as an underlying technology.
- Remediation Procedure
Alternative mechanisms provided by Kubernetes such as the use of OIDC should be implemented in place of service account tokens.
3.1.3Bootstrap token authentication should not be used for users0
Attributes
- Profile
Level 1
- Section
3 Control Plane Configuration
- Sub Section
3.1 Authentication and Authorization
- Description
Kubernetes provides bootstrap tokens which are intended for use by new nodes joining the clusterThese tokens are not designed for use by end-users they are specifically designed for the purpose of bootstrapping new nodes and not for general authentication
- Default Value
Bootstrap token authentication is not enabled by default and requires an API server parameter to be set.
- Audit Procedure
Review user access to the cluster and ensure that users are not making use of bootstrap token authentication.
- Impact Statement
External mechanisms for authentication generally require additional software to be deployed.
- Assessment Status
Manual
- Rationale Statement
Bootstrap tokens are not intended for use as a general authentication mechanism and impose constraints on user and group naming that do not facilitate good RBAC design. They also cannot be used with MFA resulting in a weak authentication mechanism being available.
- Remediation Procedure
Alternative mechanisms provided by Kubernetes such as the use of OIDC should be implemented in place of bootstrap tokens.
3.2.1Ensure that a minimal audit policy is created0
Attributes
- Profile
Level 1
- Section
3 Control Plane Configuration
- Sub Section
3.2 Logging
- Description
Kubernetes can audit the details of requests made to the API server. The
--audit-policy-fileflag must be set for this logging to be enabled.- Default Value
Unless the
--audit-policy-fileflag is specified, no auditing will be carried out.- Audit Procedure
Run the following command on one of the cluster master nodes:ps -ef | grep kube-apiserverVerify that the
--audit-policy-fileis set. Review the contents of the file specified and ensure that it contains a valid audit policy.- Impact Statement
Audit logs will be created on the master nodes, which will consume disk space. Care should be taken to avoid generating too large volumes of log information as this could impact the available of the cluster nodes.
- Assessment Status
Manual
- Rationale Statement
Logging is an important detective control for all systems, to detect potential unauthorised access.
- Remediation Procedure
Create an audit policy file for your cluster.
3.2.2Ensure that the audit policy covers key security concerns0
Attributes
- Profile
Level 2
- Section
3 Control Plane Configuration
- Sub Section
3.2 Logging
- Description
Ensure that the audit policy created for the cluster covers key security concerns.
- Default Value
By default Kubernetes clusters do not log audit information.
- Audit Procedure
Review the audit policy provided for the cluster and ensure that it covers at least the following areas :-- Access to Secrets managed by the cluster. Care should be taken to only log Metadata for requests to Secrets, ConfigMaps, and TokenReviews, in order to avoid the risk of logging sensitive data.- Modification of
podanddeploymentobjects.- Use ofpods/exec,pods/portforward,pods/proxyandservices/proxy.For most requests, minimally logging at the Metadata level is recommended (the most basic level of logging).- Impact Statement
Increasing audit logging will consume resources on the nodes or other log destination.
- Assessment Status
Manual
- Rationale Statement
Security audit logs should cover access and modification of key resources in the cluster, to enable them to form an effective part of a security environment.
- Remediation Procedure
Consider modification of the audit policy in use on the cluster to include these items, at a minimum.
4 Worker Nodes2416
4.1.1Ensure that the kubelet service file permissions are set to 600 or more restrictive1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the
kubeletservice file has permissions of600or more restrictive.- Default Value
By default, the
kubeletservice file has permissions of640.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet service config file.Please set $kubelet_service_config=<PATH><filename> based on the file location on your system for example:export kubelet_service_config=/etc/systemd/system/kubelet.service.d/kubeadm.confTo perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %a /etc/systemd/system/kubelet.service.d/10-kubeadm.confVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
kubeletservice file controls various parameters that set the behavior of thekubeletservice in the worker node. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chmod 600 /etc/systemd/system/kubelet.service.d/kubeadm.conf
4.1.2Ensure that the kubelet service file ownership is set to root:root1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the
kubeletservice file ownership is set toroot:root.- Default Value
By default,
kubeletservice file ownership is set toroot:root.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet service config file.Please set $kubelet_service_config=<PATH><filename> based on the file location on your system for example:export kubelet_service_config=/etc/systemd/system/kubelet.service.d/kubeadm.confTo perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %U:%G /etc/systemd/system/kubelet.service.d/10-kubeadm.confVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
kubeletservice file controls various parameters that set the behavior of thekubeletservice in the worker node. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chown root:root /etc/systemd/system/kubelet.service.d/kubeadm.conf
4.1.3If proxy kubeconfig file exists ensure permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
If
kube-proxyis running, and if it is using a file-based kubeconfig file, ensure that the proxy kubeconfig file has permissions of600or more restrictive.- Default Value
By default, proxy file has permissions of
640.- Audit Procedure
Find the kubeconfig file being used by
kube-proxyby running the following command: ps -ef | grep kube-proxyIfkube-proxyis running, get the kubeconfig file location from the--kubeconfigparameter. To perform the audit:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %a <path><filename>Verify that a file is specified and it exists with permissions are600or more restrictive.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
The
kube-proxykubeconfig file controls various parameters of thekube-proxyservice in the worker node. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.It is possible to runkube-proxywith the kubeconfig parameters configured as a Kubernetes ConfigMap instead of a file. In this case, there is no proxy kubeconfig file.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chmod 600 <proxy kubeconfig file>
4.1.4If proxy kubeconfig file exists ensure ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
If
kube-proxyis running, ensure that the file ownership of its kubeconfig file is set toroot:root.- Default Value
By default,
proxyfile ownership is set toroot:root.- Audit Procedure
Find the kubeconfig file being used by
kube-proxyby running the following command: ps -ef | grep kube-proxyIfkube-proxyis running, get the kubeconfig file location from the--kubeconfigparameter. To perform the audit:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %U:%G <path><filename>Verify that the ownership is set toroot:root.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
The kubeconfig file for
kube-proxycontrols various parameters for thekube-proxyservice in the worker node. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chown root:root <proxy kubeconfig file>
4.1.5Ensure that the --kubeconfig kubelet.conf file permissions are set to 600 or more restrictive1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the
kubelet.conffile has permissions of600or more restrictive.- Default Value
By default,
kubelet.conffile has permissions of600.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet config file.Please set $kubelet_config=<PATH><filename> based on the file location on your system for example:export kubelet_config=/etc/kubernetes/kubelet.confTo perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %a /etc/kubernetes/kubelet.confVerify that the ownership is set to
root:root.Verify that the permissions are600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
kubelet.conffile is the kubeconfig file for the node, and controls various parameters that set the behavior and identity of the worker node. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chmod 600 /etc/kubernetes/kubelet.conf
4.1.6Ensure that the --kubeconfig kubelet.conf file ownership is set to root:root1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the
kubelet.conffile ownership is set toroot:root.- Default Value
By default,
kubelet.conffile ownership is set toroot:root.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet config file.Please set $kubelet_config=<PATH><filename> based on the file location on your system for example:export kubelet_config=/etc/kubernetes/kubelet.confTo perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %U:%G /etc/kubernetes/kubelet.confVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
kubelet.conffile is the kubeconfig file for the node, and controls various parameters that set the behavior and identity of the worker node. You should set its file ownership to maintain the integrity of the file. The file should be owned byroot:root.- Remediation Procedure
Run the below command (based on the file location on your system) on the each worker node. For example,chown root:root /etc/kubernetes/kubelet.conf
4.1.7Ensure that the certificate authorities file permissions are set to 600 or more restrictive0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the certificate authorities file has permissions of
600or more restrictive.- Default Value
By default no
--client-ca-fileis specified.- Audit Procedure
Run the following command: ps -ef | grep kubeletFind the file specified by the
--client-ca-fileargument.Run the following command: stat -c %a <filename>Verify that the permissions are644or more restrictive.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
The certificate authorities file controls the authorities used to validate API requests. You should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.
- Remediation Procedure
Run the following command to modify the file permissions of the
--client-ca-filechmod 600 <filename>
4.1.8Ensure that the client certificate authorities file ownership is set to root:root0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that the certificate authorities file ownership is set to
root:root.- Default Value
By default no
--client-ca-fileis specified.- Audit Procedure
Run the following command:ps -ef | grep kubeletFind the file specified by the
--client-ca-fileargument.Run the following command:stat -c %U:%G <filename>Verify that the ownership is set toroot:root.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
The certificate authorities file controls the authorities used to validate API requests. You should set its file ownership to maintain the integrity of the file. The file should be owned by
root:root.- Remediation Procedure
Run the following command to modify the ownership of the
--client-ca-file.chown root:root <filename>
4.1.9If the kubelet config.yaml configuration file is being used validate permissions set to 600 or more restrictive1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that if the kubelet refers to a configuration file with the
--configargument, that file has permissions of 600 or more restrictive.- Default Value
By default, the /var/lib/kubelet/config.yaml file as set up by
kubeadmhas permissions of 600.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet config yaml file.Please set $kubelet_config_yaml=<PATH><filename> based on the file location on your system for example:export kubelet_config_yaml=/var/lib/kubelet/config.yaml```To perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %a /var/lib/kubelet/config.yamlVerify that the permissions are
600or more restrictive.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The kubelet reads various parameters, including security settings, from a config file specified by the
--configargument. If this file is specified you should restrict its file permissions to maintain the integrity of the file. The file should be writable by only the administrators on the system.- Remediation Procedure
Run the following command (using the config file location identied in the Audit step)chmod 600 /var/lib/kubelet/config.yaml
4.1.10If the kubelet config.yaml configuration file is being used validate file ownership is set to root:root1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.1 Worker Node Configuration Files
- Description
Ensure that if the kubelet refers to a configuration file with the
--configargument, that file is owned by root:root.- Default Value
By default,
/var/lib/kubelet/config.yamlfile as set up bykubeadmis owned byroot:root.- Audit Procedure
Automated AAC auditing has been modified to allow CIS-CAT to input a variable for the <PATH>/<FILENAME> of the kubelet config yaml file.Please set $kubelet_config_yaml=<PATH><filename> based on the file location on your system for example:export kubelet_config_yaml=/var/lib/kubelet/config.yaml```To perform the audit manually:Run the below command (based on the file location on your system) on the each worker node. For example,stat -c %aU %G /var/lib/kubelet/config.yamlVerify that the ownership is set to
root:root.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The kubelet reads various parameters, including security settings, from a config file specified by the
--configargument. If this file is specified you should restrict its file permissions to maintain the integrity of the file. The file should be owned by root:root.- Remediation Procedure
Run the following command (using the config file location identied in the Audit step)chown root:root /etc/kubernetes/kubelet.conf
4.2.1Ensure that the --anonymous-auth argument is set to false1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Disable anonymous requests to the Kubelet server.
- Default Value
By default, anonymous access is enabled.
- Audit Procedure
If using a Kubelet configuration file, check that there is an entry for
authentication: anonymous: enabledset tofalse. Run the following command on each node:ps -ef | grep kubeletVerify that the--anonymous-authargument is set tofalse. This executable argument may be omitted, provided there is a corresponding entry set tofalsein the Kubelet config file.- Impact Statement
Anonymous requests will be rejected.
- Assessment Status
Automated
- Rationale Statement
When enabled, requests that are not rejected by other configured authentication methods are treated as anonymous requests. These requests are then served by the Kubelet server. You should rely on authentication to authorize access and disallow anonymous requests.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
authentication: anonymous: enabledtofalse. If using executable arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_SYSTEM_PODS_ARGSvariable.--anonymous-auth=falseBased on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.2Ensure that the --authorization-mode argument is not set to AlwaysAllow1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Do not allow all requests. Enable explicit authorization.
- Default Value
By default,
--authorization-modeargument is set toAlwaysAllow.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletIf the
--authorization-modeargument is present check that it is not set toAlwaysAllow. If it is not present check that there is a Kubelet config file specified by--config, and that file setsauthorization: modeto something other thanAlwaysAllow.It is also possible to review the running configuration of a Kubelet via the/configzendpoint on the Kubelet API port (typically10250/TCP). Accessing these with appropriate credentials will provide details of the Kubelet's configuration.- Impact Statement
Unauthorized requests will be denied.
- Assessment Status
Automated
- Rationale Statement
Kubelets, by default, allow all authenticated requests (even anonymous ones) without needing explicit authorization checks from the apiserver. You should restrict this behavior and only allow explicitly authorized requests.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
authorization: modetoWebhook. If using executable arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_AUTHZ_ARGSvariable.--authorization-mode=WebhookBased on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.3Ensure that the --client-ca-file argument is set as appropriate1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Enable Kubelet authentication using certificates.
- Default Value
By default,
--client-ca-fileargument is not set.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that the
--client-ca-fileargument exists and is set to the location of the client certificate authority file.If the--client-ca-fileargument is not present, check that there is a Kubelet config file specified by--config, and that the file setsauthentication: x509: clientCAFileto the location of the client certificate authority file.- Impact Statement
You require TLS to be configured on apiserver as well as kubelets.
- Assessment Status
Automated
- Rationale Statement
The connections from the apiserver to the kubelet are used for fetching logs for pods, attaching (through kubectl) to running pods, and using the kubelet’s port-forwarding functionality. These connections terminate at the kubelet’s HTTPS endpoint. By default, the apiserver does not verify the kubelet’s serving certificate, which makes the connection subject to man-in-the-middle attacks, and unsafe to run over untrusted and/or public networks. Enabling Kubelet certificate authentication ensures that the apiserver could authenticate the Kubelet before submitting any requests.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
authentication: x509: clientCAFileto the location of the client CA file. If using command line arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_AUTHZ_ARGSvariable.--client-ca-file=<path/to/client-ca-file>Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.4Verify that the --read-only-port argument is set to 01
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Disable the read-only port.
- Default Value
By default,
--read-only-portis set to10255/TCP. However, if a config file is specified by--configthe default value forreadOnlyPortis 0.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that the
--read-only-portargument exists and is set to0.If the--read-only-portargument is not present, check that there is a Kubelet config file specified by--config. Check that if there is areadOnlyPortentry in the file, it is set to0.- Impact Statement
Removal of the read-only port will require that any service which made use of it will need to be re-configured to use the main Kubelet API.
- Assessment Status
Manual
- Rationale Statement
The Kubelet process provides a read-only API in addition to the main Kubelet API. Unauthenticated access is provided to this read-only API which could possibly retrieve potentially sensitive information about the cluster.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
readOnlyPortto0.If using command line arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_SYSTEM_PODS_ARGSvariable.--read-only-port=0Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.5Ensure that the --streaming-connection-idle-timeout argument is not set to 01
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- References
- https://kubernetes.io/docs/admin/kubelet/:https://github.com/kubernetes/kubernetes/pull/18552
- Sub Section
4.2 Kubelet
- Description
Do not disable timeouts on streaming connections.
- Default Value
By default,
--streaming-connection-idle-timeoutis set to 4 hours.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that the
--streaming-connection-idle-timeoutargument is not set to0.If the argument is not present, and there is a Kubelet config file specified by--config, check that it does not setstreamingConnectionIdleTimeoutto 0.- Impact Statement
Long-lived connections could be interrupted.
- Assessment Status
Manual
- Rationale Statement
Setting idle timeouts ensures that you are protected against Denial-of-Service attacks, inactive connections and running out of ephemeral ports. Note: By default,
--streaming-connection-idle-timeoutis set to 4 hours which might be too high for your environment. Setting this as appropriate would additionally ensure that such streaming connections are timed out after serving legitimate use cases.- Remediation Procedure
If using a Kubelet config file, edit the file to set
streamingConnectionIdleTimeoutto a value other than 0. If using command line arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_SYSTEM_PODS_ARGSvariable.--streaming-connection-idle-timeout=5mBased on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.6Ensure that the --make-iptables-util-chains argument is set to true1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Allow Kubelet to manage iptables.
- Default Value
By default,
--make-iptables-util-chainsargument is set totrue.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that if the
--make-iptables-util-chainsargument exists then it is set totrue.If the--make-iptables-util-chainsargument does not exist, and there is a Kubelet config file specified by--config, verify that the file does not setmakeIPTablesUtilChainstofalse.- Impact Statement
Kubelet would manage the iptables on the system and keep it in sync. If you are using any other iptables management solution, then there might be some conflicts.
- Assessment Status
Automated
- Rationale Statement
Kubelets can automatically manage the required changes to iptables based on how you choose your networking options for the pods. It is recommended to let kubelets manage the changes to iptables. This ensures that the iptables configuration remains in sync with pods networking configuration. Manually configuring iptables with dynamic pod network configuration changes might hamper the communication between pods/containers and to the outside world. You might have iptables rules too restrictive or too open.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
makeIPTablesUtilChains: true.If using command line arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and remove the--make-iptables-util-chainsargument from theKUBELET_SYSTEM_PODS_ARGSvariable.Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.7Ensure that the --hostname-override argument is not set0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- References
- https://kubernetes.io/docs/admin/kubelet/:https://github.com/kubernetes/kubernetes/issues/22063
- Sub Section
4.2 Kubelet
- Description
Do not override node hostnames.
- Default Value
By default,
--hostname-overrideargument is not set.- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that
--hostname-overrideargument does not exist.Note This setting is not configurable via the Kubelet config file.- Impact Statement
Some cloud providers may require this flag to ensure that hostname matches names issued by the cloud provider. In these environments, this recommendation should not apply.
- Assessment Status
Manual
- Rationale Statement
Overriding hostnames could potentially break TLS setup between the kubelet and the apiserver. Additionally, with overridden hostnames, it becomes increasingly difficult to associate logs with a particular node and process them for security analytics. Hence, you should setup your kubelet nodes with resolvable FQDNs and avoid overriding the hostnames with IPs.
- Remediation Procedure
Edit the kubelet service file
/etc/systemd/system/kubelet.service.d/10-kubeadm.confon each worker node and remove the--hostname-overrideargument from theKUBELET_SYSTEM_PODS_ARGSvariable.Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.8Ensure that the eventRecordQPS argument is set to a level which ensures appropriate event capture1
Attributes
- Profile
Level 2
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Security relevant information should be captured. The eventRecordQPS on the Kubelet configuration can be used to limit the rate at which events are gathered and sets the maximum event creations per second. Setting this too low could result in relevant events not being logged, however the unlimited setting of
0could result in a denial of service on the kubelet.- Default Value
By default, eventRecordQPS argument is set to
5.- Audit Procedure
Run the following command on each node:sudo grep "eventRecordQPS" /etc/systemd/system/kubelet.service.d/10-kubeadm.confor If using command line arguments, kubelet service file is located /etc/systemd/system/kubelet.service.d/10-kubelet-args.confsudo grep "eventRecordQPS" /etc/systemd/system/kubelet.service.d/10-kubelet-args.confReview the value set for the argument and determine whether this has been set to an appropriate level for the cluster.If the argument does not exist, check that there is a Kubelet config file specified by
--configand review the value in this location.If using command line arguments- Impact Statement
Setting this parameter to
0could result in a denial of service condition due to excessive events being created. The cluster's event processing and storage systems should be scaled to handle expected event loads.- Assessment Status
Manual
- Rationale Statement
It is important to capture all events and not restrict event creation. Events are an important source of security information and analytics that ensure that your environment is consistently monitored using the event data.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
eventRecordQPS:to an appropriate level.If using command line arguments, edit the kubelet service file/etc/systemd/system/kubelet.service.d/10-kubeadm.confon each worker node and set the below parameter inKUBELET_ARGSvariable.Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.9Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Setup TLS connection on the Kubelets.
- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that the --tls-cert-file and --tls-private-key-file arguments exist and they are set as appropriate.If these arguments are not present, check that there is a Kubelet config specified by --config and that it contains appropriate settings for tlsCertFile and tlsPrivateKeyFile.
- Assessment Status
Manual
- Rationale Statement
The connections from the apiserver to the kubelet are used for fetching logs for pods, attaching (through kubectl) to running pods, and using the kubelet’s port-forwarding functionality. These connections terminate at the kubelet’s HTTPS endpoint. By default, the apiserver does not verify the kubelet’s serving certificate, which makes the connection subject to man-in-the-middle attacks, and unsafe to run over untrusted and/or public networks.
- Remediation Procedure
If using a Kubelet config file, edit the file to set tlsCertFile to the location of the certificate file to use to identify this Kubelet, and tlsPrivateKeyFile to the location of the corresponding private key file.If using command line arguments, edit the kubelet service file /etc/kubernetes/kubelet.conf on each worker node and set the below parameters in KUBELET_CERTIFICATE_ARGS variable.--tls-cert-file=<path/to/tls-certificate-file> --tls-private-key-file=<path/to/tls-key-file>Based on your system, restart the kubelet service. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.10Ensure that the --rotate-certificates argument is not set to false1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Enable kubelet client certificate rotation.
- Default Value
By default, kubelet client certificate rotation is enabled.
- Audit Procedure
Run the following command on each node:ps -ef | grep kubeletVerify that the
RotateKubeletServerCertificateargument is not present, or is set totrue.If the RotateKubeletServerCertificate argument is not present, verify that if there is a Kubelet config file specified by--config, that file does not containRotateKubeletServerCertificate: false.- Impact Statement
None
- Assessment Status
Automated
- Rationale Statement
The
--rotate-certificatessetting causes the kubelet to rotate its client certificates by creating new CSRs as its existing credentials expire. This automated periodic rotation ensures that the there is no downtime due to expired certificates and thus addressing availability in the CIA security triad.Note: This recommendation only applies if you let kubelets get their certificates from the API server. In case your kubelet certificates come from an outside authority/tool (e.g. Vault) then you need to take care of rotation yourself.Note: This feature also require theRotateKubeletClientCertificatefeature gate to be enabled (which is the default since Kubernetes v1.7)- Remediation Procedure
If using a Kubelet config file, edit the file to add the line
rotateCertificates: trueor remove it altogether to use the default value.If using command line arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and remove--rotate-certificates=falseargument from theKUBELET_CERTIFICATE_ARGSvariable or set --rotate-certificates=true .Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.11Verify that the RotateKubeletServerCertificate argument is set to true0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Enable kubelet server certificate rotation.
- Default Value
By default, kubelet server certificate rotation is enabled.
- Audit Procedure
Ignore this check if serverTLSBootstrap is true in the kubelet config file or if the --rotate-server-certificates parameter is set on kubeletRun the following command on each node:ps -ef | grep kubeletVerify that
RotateKubeletServerCertificateargument exists and is set totrue.- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
RotateKubeletServerCertificatecauses the kubelet to both request a serving certificate after bootstrapping its client credentials and rotate the certificate as its existing credentials expire. This automated periodic rotation ensures that the there are no downtimes due to expired certificates and thus addressing availability in the CIA security triad.Note: This recommendation only applies if you let kubelets get their certificates from the API server. In case your kubelet certificates come from an outside authority/tool (e.g. Vault) then you need to take care of rotation yourself.- Remediation Procedure
Edit the kubelet service file
/etc/kubernetes/kubelet.confon each worker node and set the below parameter inKUBELET_CERTIFICATE_ARGSvariable.--feature-gates=RotateKubeletServerCertificate=trueBased on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service
4.2.12Ensure that the Kubelet only makes use of Strong Cryptographic Ciphers1
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Ensure that the Kubelet is configured to only use strong cryptographic ciphers.
- Default Value
By default the Kubernetes API server supports a wide range of TLS ciphers
- Audit Procedure
The set of cryptographic ciphers currently considered secure is the following: -
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256-TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256-TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305-TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384-TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305-TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384-TLS_RSA_WITH_AES_256_GCM_SHA384-TLS_RSA_WITH_AES_128_GCM_SHA256Run the following command on each node:ps -ef | grep kubeletIf the--tls-cipher-suitesargument is present, ensure it only contains values included in this set. If it is not present check that there is a Kubelet config file specified by--config, and that file setsTLSCipherSuites:to only include values from this set.- Impact Statement
Kubelet clients that cannot support modern cryptographic ciphers will not be able to make connections to the Kubelet API.
- Assessment Status
Manual
- Rationale Statement
TLS ciphers have had a number of known vulnerabilities and weaknesses, which can reduce the protection provided by them. By default Kubernetes supports a number of TLS ciphersuites including some that have security concerns, weakening the protection provided.
- Remediation Procedure
If using a Kubelet config file, edit the file to set
TLSCipherSuites:toTLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256or to a subset of these values. If using executable arguments, edit the kubelet service file/etc/kubernetes/kubelet.confon each worker node and set the--tls-cipher-suitesparameter as follows, or to a subset of these values. --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256Based on your system, restart thekubeletservice. For example:systemctl daemon-reloadsystemctl restart kubelet.service- Additional Information
The list chosen above should be fine for modern clients. It's essentially the list from the Mozilla "Modern cipher" option with the ciphersuites supporting CBC mode removed, as CBC has traditionally had a lot of issues
4.2.13Ensure that a limit is set on pod PIDs0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.2 Kubelet
- Description
Ensure that the Kubelet sets limits on the number of PIDs that can be created by pods running on the node.
- Default Value
By default the number of PIDs is not limited.
- Audit Procedure
Review the Kubelet's start-up parameters for the value of
--pod-max-pids, and check the Kubelet configuration file for thePodPidsLimit. If neither of these values is set, then there is no limit in place.- Impact Statement
Setting this value will restrict the number of processes per pod. If this limit is lower than the number of PIDs required by a pod it will not operate.
- Assessment Status
Manual
- Rationale Statement
By default pods running in a cluster can consume any number of PIDs, potentially exhausting the resources available on the node. Setting an appropriate limit reduces the risk of a denial of service attack on cluster nodes.
- Remediation Procedure
Decide on an appropriate level for this parameter and set it, either via the
--pod-max-pidscommand line parameter or thePodPidsLimitconfiguration file setting.
4.3.1Ensure that the kube-proxy metrics service is bound to localhost0
Attributes
- Profile
Level 1
- Section
4 Worker Nodes
- Sub Section
4.3 kube-proxy
- Description
Do not bind the kube-proxy metrics port to non-loopback addresses.
- Default Value
The default value is
127.0.0.1:10249- Audit Procedure
review the start-up flags provided to kube proxyps -ef | grep -i kube-proxyEnsure that the
--metrics-bind-addressparameter is not set to a value other than 127.0.0.1. From the output of this command gather the location specified in the--configparameter. Review any file stored at that location and ensure that it does not specify a value other than 127.0.0.1 formetricsBindAddress.- Impact Statement
3rd party services which try to access metrics or configuration information related to kube-proxy will require access to the localhost interface of the node.
- Assessment Status
Manual
- Rationale Statement
kube-proxy has two APIs which provided access to information about the service and can be bound to network ports. The metrics API service includes endpoints (
/metricsand/configz) which disclose information about the configuration and operation of kube-proxy. These endpoints should not be exposed to untrusted networks as they do not support encryption or authentication to restrict access to the data they provide.- Remediation Procedure
Modify or remove any values which bind the metrics service to a non-localhost address
5 Policies3522
5.1.1Ensure that the cluster-admin role is only used where required1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
The RBAC role
cluster-adminprovides wide-ranging powers over the environment and should be used only where and when needed.- Default Value
By default a single
clusterrolebindingcalledcluster-adminis provided with thesystem:mastersgroup as its principal.- Audit Procedure
Obtain a list of the principals who have access to the
cluster-adminrole by reviewing theclusterrolebindingoutput for each role binding that has access to thecluster-adminrole.kubectl get clusterrolebindings -o=custom-columns=NAME:.metadata.name,ROLE:.roleRef.name,SUBJECT:.subjects[*].nameReview each principal listed and ensure thatcluster-adminprivilege is required for it.- Impact Statement
Care should be taken before removing any
clusterrolebindingsfrom the environment to ensure they were not required for operation of the cluster. Specifically, modifications should not be made toclusterrolebindingswith thesystem:prefix as they are required for the operation of system components.- Assessment Status
Automated
- Rationale Statement
Kubernetes provides a set of default roles where RBAC is used. Some of these roles such as
cluster-adminprovide wide-ranging privileges which should only be applied where absolutely necessary. Roles such ascluster-adminallow super-user access to perform any action on any resource. When used in aClusterRoleBinding, it gives full control over every resource in the cluster and in all namespaces. When used in aRoleBinding, it gives full control over every resource in the rolebinding's namespace, including the namespace itself.- Remediation Procedure
Identify all clusterrolebindings to the cluster-admin role. Check if they are used and if they need this role or if they could use a role with fewer privileges. Where possible, first bind users to a lower privileged role and then remove the clusterrolebinding to the cluster-admin role :kubectl delete clusterrolebinding [name]
5.1.2Minimize access to secrets1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
The Kubernetes API stores secrets, which may be service account tokens for the Kubernetes API or credentials used by workloads in the cluster. Access to these secrets should be restricted to the smallest possible group of users to reduce the risk of privilege escalation.
- Default Value
By default in a kubeadm cluster the following list of principals have
getprivileges onsecretobjectsCLUSTERROLEBINDING SUBJECT TYPE SA-NAMESPACEcluster-admin system:masters Group system:controller:clusterrole-aggregation-controller clusterrole-aggregation-controller ServiceAccount kube-systemsystem:controller:expand-controller expand-controller ServiceAccount kube-systemsystem:controller:generic-garbage-collector generic-garbage-collector ServiceAccount kube-systemsystem:controller:namespace-controller namespace-controller ServiceAccount kube-systemsystem:controller:persistent-volume-binder persistent-volume-binder ServiceAccount kube-systemsystem:kube-controller-manager system:kube-controller-manager User- Audit Procedure
Review the users who have
get,listorwatchaccess tosecretsobjects in the Kubernetes API.- Impact Statement
Care should be taken not to remove access to secrets to system components which require this for their operation
- Assessment Status
Automated
- Rationale Statement
Inappropriate access to secrets stored within the Kubernetes cluster can allow for an attacker to gain additional access to the Kubernetes cluster or external resources whose credentials are stored as secrets.
- Remediation Procedure
Where possible, remove
get,listandwatchaccess tosecretobjects in the cluster.
5.1.3Minimize wildcard use in Roles and ClusterRoles1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
Kubernetes Roles and ClusterRoles provide access to resources based on sets of objects and actions that can be taken on those objects. It is possible to set either of these to be the wildcard "*" which matches all items. Use of wildcards is not optimal from a security perspective as it may allow for inadvertent access to be granted when new resources are added to the Kubernetes API either as CRDs or in later versions of the product.
- Audit Procedure
Retrieve the roles defined across each namespaces in the cluster and review for wildcardskubectl get roles --all-namespaces -o yamlRetrieve the cluster roles defined in the cluster and review for wildcardskubectl get clusterroles -o yaml
- Assessment Status
Automated
- Rationale Statement
The principle of least privilege recommends that users are provided only the access required for their role and nothing more. The use of wildcard rights grants is likely to provide excessive rights to the Kubernetes API.
- Remediation Procedure
Where possible replace any use of wildcards in clusterroles and roles with specific objects or actions.
5.1.4Minimize access to create pods1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
The ability to create pods in a namespace can provide a number of opportunities for privilege escalation, such as assigning privileged service accounts to these pods or mounting hostPaths with access to sensitive data (unless Pod Security Policies are implemented to restrict this access)As such, access to create new pods should be restricted to the smallest possible group of users.
- Default Value
By default in a kubeadm cluster the following list of principals have
createprivileges onpodobjectsCLUSTERROLEBINDING SUBJECT TYPE SA-NAMESPACEcluster-admin system:masters Group system:controller:clusterrole-aggregation-controller clusterrole-aggregation-controller ServiceAccount kube-systemsystem:controller:daemon-set-controller daemon-set-controller ServiceAccount kube-systemsystem:controller:job-controller job-controller ServiceAccount kube-systemsystem:controller:persistent-volume-binder persistent-volume-binder ServiceAccount kube-systemsystem:controller:replicaset-controller replicaset-controller ServiceAccount kube-systemsystem:controller:replication-controller replication-controller ServiceAccount kube-systemsystem:controller:statefulset-controller statefulset-controller ServiceAccount kube-system- Audit Procedure
Review the users who have create access to pod objects in the Kubernetes API.
- Impact Statement
Care should be taken not to remove access to pods to system components which require this for their operation
- Assessment Status
Automated
- Rationale Statement
The ability to create pods in a cluster opens up possibilities for privilege escalation and should be restricted, where possible.
- Remediation Procedure
Where possible, remove
createaccess topodobjects in the cluster.
5.1.5Ensure that default service accounts are not actively used.0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
The
defaultservice account should not be used to ensure that rights granted to applications can be more easily audited and reviewed.- Default Value
By default the
defaultservice account allows for its service account token to be mounted in pods in its namespace.- Audit Procedure
For each namespace in the cluster, review the rights assigned to the default service account and ensure that it has no roles or cluster roles bound to it apart from the defaults.Additionally ensure that the
automountServiceAccountToken: falsesetting is in place for each default service account.- Impact Statement
All workloads which require access to the Kubernetes API will require an explicit service account to be created.
- Assessment Status
Automated
- Rationale Statement
Kubernetes provides a
defaultservice account which is used by cluster workloads where no specific service account is assigned to the pod.Where access to the Kubernetes API from a pod is required, a specific service account should be created for that pod, and rights granted to that service account.The default service account should be configured such that it does not provide a service account token and does not have any explicit rights assignments.- Remediation Procedure
Create explicit service accounts wherever a Kubernetes workload requires specific access to the Kubernetes API server.Modify the configuration of each default service account to include this value automountServiceAccountToken: false
5.1.6Ensure that Service Account Tokens are only mounted where necessary0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
Service accounts tokens should not be mounted in pods except where the workload running in the pod explicitly needs to communicate with the API server
- Default Value
By default, all pods get a service account token mounted in them.
- Audit Procedure
Review pod and service account objects in the cluster and ensure that the option below is set, unless the resource explicitly requires this access.automountServiceAccountToken: false
- Impact Statement
Pods mounted without service account tokens will not be able to communicate with the API server, except where the resource is available to unauthenticated principals.
- Assessment Status
Automated
- Rationale Statement
Mounting service account tokens inside pods can provide an avenue for privilege escalation attacks where an attacker is able to compromise a single pod in the cluster.Avoiding mounting these tokens removes this attack avenue.
- Remediation Procedure
Modify the definition of pods and service accounts which do not need to mount service account tokens to disable it.
5.1.7Avoid use of system:masters group0
Attributes
- Profile
Level 1
- Section
5 Policies
- References
- https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/rbac/escalation_check.go#L38
- Sub Section
5.1 RBAC and Service Accounts
- Description
The special group
system:mastersshould not be used to grant permissions to any user or service account, except where strictly necessary (e.g. bootstrapping access prior to RBAC being fully available)- Default Value
By default some clusters will create a "break glass" client certificate which is a member of this group. Access to this client certificate should be carefully controlled and it should not be used for general cluster operations.
- Audit Procedure
Review a list of all credentials which have access to the cluster and ensure that the group
system:mastersis not used.- Impact Statement
Once the RBAC system is operational in a cluster
system:mastersshould not be specifically required, as ordinary bindings from principals to thecluster-admincluster role can be made where unrestricted access is required.- Assessment Status
Manual
- Rationale Statement
The
system:mastersgroup has unrestricted access to the Kubernetes API hard-coded into the API server source code. An authenticated user who is a member of this group cannot have their access reduced, even if all bindings and cluster role bindings which mention it, are removed.When combined with client certificate authentication, use of this group can allow for irrevocable cluster-admin level credentials to exist for a cluster.- Remediation Procedure
Remove the
system:mastersgroup from all users in the cluster.
5.1.8Limit use of the Bind, Impersonate and Escalate permissions in the Kubernetes cluster0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
Cluster roles and roles with the impersonate, bind or escalate permissions should not be granted unless strictly required. Each of these permissions allow a particular subject to escalate their privileges beyond those explicitly granted by cluster administrators
- Default Value
In a default kubeadm cluster, the system:masters group and clusterrole-aggregation-controller service account have access to the escalate privilege. The system:masters group also has access to bind and impersonate.
- Audit Procedure
Review the users who have access to cluster roles or roles which provide the impersonate, bind or escalate privileges.
- Impact Statement
There are some cases where these permissions are required for cluster service operation, and care should be taken before removing these permissions from system service accounts.
- Assessment Status
Manual
- Rationale Statement
The impersonate privilege allows a subject to impersonate other users gaining their rights to the cluster. The bind privilege allows the subject to add a binding to a cluster role or role which escalates their effective permissions in the cluster. The escalate privilege allows a subject to modify cluster roles to which they are bound, increasing their rights to that level.Each of these permissions has the potential to allow for privilege escalation to cluster-admin level.
- Remediation Procedure
Where possible, remove the impersonate, bind and escalate rights from subjects.
5.1.9Minimize access to create persistent volumes1
Attributes
- Profile
Level 1
- Section
5 Policies
- References
- https://kubernetes.io/docs/concepts/security/rbac-good-practices/#persistent-volume-creation
- Sub Section
5.1 RBAC and Service Accounts
- Description
The ability to create persistent volumes in a cluster can provide an opportunity for privilege escalation, via the creation of
hostPathvolumes. As persistent volumes are not covered by Pod Security Admission, a user with access to create persistent volumes may be able to get access to sensitive files from the underlying host even where restrictive Pod Security Admission policies are in place.- Audit Procedure
Review the users who have create access to
PersistentVolumeobjects in the Kubernetes API.- Assessment Status
Manual
- Rationale Statement
The ability to create persistent volumes in a cluster opens up possibilities for privilege escalation and should be restricted, where possible.
- Remediation Procedure
Where possible, remove
createaccess toPersistentVolumeobjects in the cluster.
5.1.10Minimize access to the proxy sub-resource of nodes1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
Users with access to the
Proxysub-resource ofNodeobjects automatically have permissions to use the Kubelet API, which may allow for privilege escalation or bypass cluster security controls such as audit logs.The Kubelet provides an API which includes rights to execute commands in any container running on the node. Access to this API is covered by permissions to the main Kubernetes API via thenodeobject. The proxy sub-resource specifically allows wide ranging access to the Kubelet API.Direct access to the Kubelet API bypasses controls like audit logging (there is no audit log of Kubelet API access) and admission control.- Audit Procedure
Review the users who have access to the
proxysub-resource ofnodeobjects in the Kubernetes API.- Assessment Status
Manual
- Rationale Statement
The ability to use the
proxysub-resource ofnodeobjects opens up possibilities for privilege escalation and should be restricted, where possible.- Remediation Procedure
Where possible, remove access to the
proxysub-resource ofnodeobjects.
5.1.11Minimize access to the approval sub-resource of certificatesigningrequests objects1
Attributes
- Profile
Level 1
- Section
5 Policies
- References
- https://kubernetes.io/docs/concepts/security/rbac-good-practices/#csrs-and-certificate-issuing
- Sub Section
5.1 RBAC and Service Accounts
- Description
Users with access to the update the
approvalsub-resource ofcertificateaigningrequestsobjects can approve new client certificates for the Kubernetes API effectively allowing them to create new high-privileged user accounts.This can allow for privilege escalation to full cluster administrator, depending on users configured in the cluster- Audit Procedure
Review the users who have access to update the
approvalsub-resource ofcertificatesigningrequestsobjects in the Kubernetes API.- Assessment Status
Manual
- Rationale Statement
The ability to update certificate signing requests should be limited.
- Remediation Procedure
Where possible, remove access to the
approvalsub-resource ofcertificatesigningrequestsobjects.
5.1.12Minimize access to webhook configuration objects1
Attributes
- Profile
Level 1
- Section
5 Policies
- References
- https://kubernetes.io/docs/concepts/security/rbac-good-practices/#control-admission-webhooks
- Sub Section
5.1 RBAC and Service Accounts
- Description
Users with rights to create/modify/delete
validatingwebhookconfigurationsormutatingwebhookconfigurationscan control webhooks that can read any object admitted to the cluster, and in the case of mutating webhooks, also mutate admitted objects. This could allow for privilege escalation or disruption of the operation of the cluster.- Audit Procedure
Review the users who have access to
validatingwebhookconfigurationsormutatingwebhookconfigurationsobjects in the Kubernetes API.- Assessment Status
Manual
- Rationale Statement
The ability to manage webhook configuration should be limited
- Remediation Procedure
Where possible, remove access to the
validatingwebhookconfigurationsormutatingwebhookconfigurationsobjects
5.1.13Minimize access to the service account token creation1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.1 RBAC and Service Accounts
- Description
Users with rights to create new service account tokens at a cluster level, can create long-lived privileged credentials in the cluster. This could allow for privilege escalation and persistent access to the cluster, even if the users account has been revoked.
- Audit Procedure
Review the users who have access to create the
tokensub-resource ofserviceaccountobjects in the Kubernetes API.- Assessment Status
Manual
- Rationale Statement
The ability to create service account tokens should be limited.
- Remediation Procedure
Where possible, remove access to the
tokensub-resource ofserviceaccountobjects.
5.2.1Ensure that the cluster has at least one active policy control mechanism in place0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Every Kubernetes cluster should have at least one policy control mechanism in place to enforce the other requirements in this section. This could be the in-built Pod Security Admission controller, or a third party policy control system.
- Default Value
By default, Pod Security Admission is enabled but no policies are in place.
- Audit Procedure
Review the workloads deployed to the cluster to understand if Pod Security Admission or external admission control systems are in place.
- Impact Statement
Where policy control systems are in place, there is a risk that workloads required for the operation of the cluster may be stopped from running. Care is required when implementing admission control policies to ensure that this does not occur.
- Assessment Status
Manual
- Rationale Statement
Without an active policy control mechanism, it is not possible to limit the use of containers with access to underlying cluster nodes, via mechanisms like privileged containers, or the use of hostPath volume mounts.
- Remediation Procedure
Ensure that either Pod Security Admission or an external policy control system is in place for every namespace which contains user workloads.
5.2.2Minimize the admission of privileged containers1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run with the
securityContext.privilegedflag set totrue.- Default Value
By default, there are no restrictions on the creation of privileged containers.
- Audit Procedure
Run the following command:get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@..securityContext}n{end}'It will produce an inventory of all the privileged use on the cluster, if any (please, refer to a sample below). Further grepping can be done to automate each specific violation detection.calico-kube-controllers-57b57c56f-jtmk4: {} << No Elevated Privileges calico-node-c4xv4: {} {"privileged":true} {"privileged":true} {"privileged":true} {"privileged":true} << Violates 5.2.2 dashboard-metrics-scraper-7bc864c59-2m2xw: {"seccompProfile":{"type":"RuntimeDefault"}} {"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":2001,"runAsUser":1001}
- Impact Statement
Pods defined with
spec.containers[].securityContext.privileged: true,spec.initContainers[].securityContext.privileged: trueandspec.ephemeralContainers[].securityContext.privileged: truewill not be permitted.- Assessment Status
Manual
- Rationale Statement
Privileged containers have access to all Linux Kernel capabilities and devices. A container running with full privileges can do almost everything that the host can do. This flag exists to allow special use-cases, like manipulating the network stack and accessing devices. There should be at least one admission control policy defined which does not permit privileged containers. If you need to run privileged containers, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of privileged containers.
5.2.3Minimize the admission of containers wishing to share the host process ID namespace1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run with the
hostPIDflag set to true.- Default Value
By default, there are no restrictions on the creation of
hostPIDcontainers.- Audit Procedure
Fetch hostPID from each pod with
get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@.spec.hostPID}n{end}'- Impact Statement
Pods defined with
spec.hostPID: truewill not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
A container running in the host's PID namespace can inspect processes running outside the container. If the container also has access to ptrace capabilities this can be used to escalate privileges outside of the container.There should be at least one admission control policy defined which does not permit containers to share the host PID namespace.If you need to run containers which require hostPID, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Configure the Admission Controller to restrict the admission of
hostPIDcontainers.
5.2.4Minimize the admission of containers wishing to share the host IPC namespace1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run with the
hostIPCflag set to true.- Default Value
By default, there are no restrictions on the creation of
hostIPCcontainers.- Audit Procedure
To fetch hostIPC from each pod.get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@.spec.hostIPC}n{end}'
- Impact Statement
Pods defined with
spec.hostIPC: truewill not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
A container running in the host's IPC namespace can use IPC to interact with processes outside the container.There should be at least one admission control policy defined which does not permit containers to share the host IPC namespace.If you need to run containers which require hostIPC, this should be definited in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of
hostIPCcontainers.
5.2.5Minimize the admission of containers wishing to share the host network namespace1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run with the
hostNetworkflag set to true.- Default Value
By default, there are no restrictions on the creation of
hostNetworkcontainers.- Audit Procedure
To fetch hostNetwork from each pod.get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@.spec.hostNetwork}n{end}'
- Impact Statement
Pods defined with
spec.hostNetwork: truewill not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
A container running in the host's network namespace could access the local loopback device, and could access network traffic to and from other pods.There should be at least one admission control policy defined which does not permit containers to share the host network namespace.If you need to run containers which require access to the host's network namesapces, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of
hostNetworkcontainers.
5.2.6Minimize the admission of containers with allowPrivilegeEscalation1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run with the
allowPrivilegeEscalationflag set to true. Allowing this right can lead to a process running a container getting more rights than it started with.It's important to note that these rights are still constrained by the overall container sandbox, and this setting does not relate to the use of privileged containers.- Default Value
By default, there are no restrictions on contained process ability to escalate privileges, within the context of the container.
- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that each policy disallows the admission of containers which allow privilege escalation.To fetch hostNetwork from each pod.
get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@..securityContext}n{end}'- Impact Statement
Pods defined with
securityContext: allowPrivilegeEscalation: truewill not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
A container running with the
allowPrivilegeEscalationflag set totruemay have processes that can gain more privileges than their parent.There should be at least one admission control policy defined which does not permit containers to allow privilege escalation. The option exists (and is defaulted to true) to permit setuid binaries to run. If you have need to run containers which use setuid binaries or require privilege escalation, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of conatiners with
securityContext: allowPrivilegeEscalation: true
5.2.7Minimize the admission of root containers1
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers to be run as the root user.
- Default Value
By default, there are no restrictions on the use of root containers and if a User is not specified in the image, the container will run as root.
- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that each policy restricts the use of root containers by setting
MustRunAsNonRootorMustRunAswith the range of UIDs not including 0.- Impact Statement
Pods with containers which run as the root user will not be permitted.
- Assessment Status
Manual
- Rationale Statement
Containers may run as any Linux user. Containers which run as the root user, whilst constrained by Container Runtime security features still have a escalated likelihood of container breakout.Ideally, all containers should run as a defined non-UID 0 user.There should be at least one admission control policy defined which does not permit root containers.If you need to run root containers, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Create a policy for each namespace in the cluster, ensuring that either
MustRunAsNonRootorMustRunAswith the range of UIDs not including 0, is set.
5.2.8Minimize the admission of containers with the NET_RAW capability1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers with the potentially dangerous NET_RAW capability.
- Default Value
By default, there are no restrictions on the creation of containers with the
NET_RAWcapability.- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that at least one policy disallows the admission of containers with the
NET_RAWcapability.- Impact Statement
Pods with containers which run with the NET_RAW capability will not be permitted.
- Assessment Status
Manual
- Rationale Statement
Containers run with a default set of capabilities as assigned by the Container Runtime. By default this can include potentially dangerous capabilities. With Docker as the container runtime the NET_RAW capability is enabled which may be misused by malicious containers.Ideally, all containers should drop this capability.There should be at least one admission control policy defined which does not permit containers with the NET_RAW capability.If you need to run containers with this capability, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of containers with the
NET_RAWcapability.
5.2.9Minimize the admission of containers with added capabilities1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers with capabilities assigned beyond the default set.
- Default Value
By default, there are no restrictions on adding capabilities to containers.
- Audit Procedure
Ensure that allowedCapabilities is not present in policies for the cluster unless it is set to an empty array.get pods -A -o=jsonpath=$'{range .items[*]}{@.metadata.name}: {@..securityContext}n{end}'
- Impact Statement
Pods with containers which require capabilities outwith the default set will not be permitted.
- Assessment Status
Manual
- Rationale Statement
Containers run with a default set of capabilities as assigned by the Container Runtime. Capabilities outside this set can be added to containers which could expose them to risks of container breakout attacks.There should be at least one policy defined which prevents containers with capabilities beyond the default set from launching.If you need to run containers with additional capabilities, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Ensure that
allowedCapabilitiesis not present in policies for the cluster unless it is set to an empty array.
5.2.10Minimize the admission of containers with capabilities assigned1
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers with capabilities
- Default Value
By default, there are no restrictions on the creation of containers with additional capabilities
- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that at least one policy requires that capabilities are dropped by all containers.
- Impact Statement
Pods with containers require capabilities to operate will not be permitted.
- Assessment Status
Manual
- Rationale Statement
Containers run with a default set of capabilities as assigned by the Container Runtime. Capabilities are parts of the rights generally granted on a Linux system to the root user.In many cases applications running in containers do not require any capabilities to operate, so from the perspective of the principal of least privilege use of capabilities should be minimized.
- Remediation Procedure
Review the use of capabilities in applications running on your cluster. Where a namespace contains applications which do not require any Linux capabilities to operate consider adding a policy which forbids the admission of containers which do not drop all capabilities.
5.2.11Minimize the admission of Windows HostProcess Containers1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit Windows containers to be run with the
hostProcessflag set to true.- Default Value
By default, there are no restrictions on the creation of
hostProcesscontainers.- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that each policy disallows the admission of
hostProcesscontainers- Impact Statement
Pods defined with
securityContext.windowsOptions.hostProcess: truewill not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
A Windows container making use of the
hostProcessflag can interact with the underlying Windows cluster node. As per the Kubernetes documentation, this provides "privileged access" to the Windows node.Where Windows containers are used inside a Kubernetes cluster, there should be at least one admission control policy which does not permithostProcessWindows containers.If you need to run Windows containers which requirehostProcess, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of
hostProcesscontainers.
5.2.12Minimize the admission of HostPath volumes0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally admit containers which make use of
hostPathvolumes.- Default Value
By default, there are no restrictions on the creation of
hostPathvolumes.- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that each policy disallows the admission of containers with
hostPathvolumes.- Impact Statement
Pods defined which make use of
hostPathvolumes will not be permitted unless they are run under a spefific policy.- Assessment Status
Manual
- Rationale Statement
A container which mounts a
hostPathvolume as part of its specification will have access to the filesystem of the underlying cluster node. The use ofhostPathvolumes may allow containers access to privileged areas of the node filesystem.There should be at least one admission control policy defined which does not permit containers to mounthostPathvolumes.If you need to run containers which requirehostPathvolumes, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of containers which use
hostPathvolumes.
5.2.13Minimize the admission of containers which use HostPorts1
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.2 Ensure that the cluster has at least one active policy control mechanism in place
- Description
Do not generally permit containers which require the use of HostPorts.
- Default Value
By default, there are no restrictions on the use of HostPorts.
- Audit Procedure
List the policies in use for each namespace in the cluster, ensure that each policy disallows the admission of containers which have
hostPortsections.- Impact Statement
Pods defined with
hostPortsettings in either the container, initContainer or ephemeralContainer sections will not be permitted unless they are run under a specific policy.- Assessment Status
Manual
- Rationale Statement
Host ports connect containers directly to the host's network. This can bypass controls such as network policy.There should be at least one admission control policy defined which does not permit containers which require the use of HostPorts.If you need to run containers which require HostPorts, this should be defined in a separate policy and you should carefully check to ensure that only limited service accounts and users are given permission to use that policy.
- Remediation Procedure
Add policies to each namespace in the cluster which has user workloads to restrict the admission of containers which use
hostPortsections.
5.3.1Ensure that the CNI in use supports Network Policies0
Attributes
- Profile
Level 1
- Section
5 Policies
- References
- https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/
- Sub Section
5.3 Network Policies and CNI
- Description
There are a variety of CNI plugins available for Kubernetes. If the CNI in use does not support Network Policies it may not be possible to effectively restrict traffic in the cluster.
- Default Value
This will depend on the CNI plugin in use.
- Audit Procedure
Review the documentation of CNI plugin in use by the cluster, and confirm that it supports Ingress and Egress network policies.
- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Kubernetes network policies are enforced by the CNI plugin in use. As such it is important to ensure that the CNI plugin supports both Ingress and Egress network policies.
- Remediation Procedure
If the CNI plugin in use does not support network policies, consideration should be given to making use of a different plugin, or finding an alternate mechanism for restricting traffic in the Kubernetes cluster.
- Additional Information
One example here is Flannel (https://github.com/coreos/flannel) which does not support Network policy unless Calico is also in use.
5.3.2Ensure that all Namespaces have Network Policies defined0
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.3 Network Policies and CNI
- Description
Use network policies to isolate traffic in your cluster network.
- Default Value
By default, network policies are not created.
- Audit Procedure
Run the below command and review the
NetworkPolicyobjects created in the cluster.kubectl get networkpolicy --all-namespacesEnsure that each namespace defined in the cluster has at least one Network Policy.- Impact Statement
Once network policies are in use within a given namespace, traffic not explicitly allowed by a network policy will be denied. As such it is important to ensure that, when introducing network policies, legitimate traffic is not blocked.
- Assessment Status
Manual
- Rationale Statement
Running different applications on the same Kubernetes cluster creates a risk of one compromised application attacking a neighboring application. Network segmentation is important to ensure that containers can communicate only with those they are supposed to. A network policy is a specification of how selections of pods are allowed to communicate with each other and other network endpoints. Network Policies are namespace scoped. When a network policy is introduced to a given namespace, all traffic not allowed by the policy is denied. However, if there are no network policies in a namespace all traffic will be allowed into and out of the pods in that namespace.
- Remediation Procedure
Follow the documentation and create
NetworkPolicyobjects as you need them.
5.4.1Prefer using secrets as files over secrets as environment variables1
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.4 Secrets Management
- Description
Kubernetes supports mounting secrets as data volumes or as environment variables. Minimize the use of environment variable secrets.
- Default Value
By default, secrets are not defined
- Audit Procedure
Run the following command to find references to objects which use environment variables defined from secrets.kubectl get all -o jsonpath='{range .items[?(@..secretKeyRef)]} {.kind} {.metadata.name} {}{end}' -A
- Impact Statement
Application code which expects to read secrets in the form of environment variables would need modification
- Assessment Status
Manual
- Rationale Statement
It is reasonably common for application code to log out its environment (particularly in the event of an error). This will include any secret values passed in as environment variables, so secrets can easily be exposed to any user or entity who has access to the logs.
- Remediation Procedure
If possible, rewrite application code to read secrets from mounted secret files, rather than from environment variables.
- Additional Information
Mounting secrets as volumes has the additional benefit that secret values can be updated without restarting the pod
5.4.2Consider external secret storage0
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.4 Secrets Management
- Description
Consider the use of an external secrets storage and management system, instead of using Kubernetes Secrets directly, if you have more complex secret management needs. Ensure the solution requires authentication to access secrets, has auditing of access to and use of secrets, and encrypts secrets. Some solutions also make it easier to rotate secrets.
- Default Value
By default, no external secret management is configured.
- Audit Procedure
Review your secrets management implementation.
- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Kubernetes supports secrets as first-class objects, but care needs to be taken to ensure that access to secrets is carefully limited. Using an external secrets provider can ease the management of access to secrets, especially where secrests are used across both Kubernetes and non-Kubernetes environments.
- Remediation Procedure
Refer to the secrets management options offered by your cloud provider or a third-party secrets management solution.
5.5.1Configure Image Provenance using ImagePolicyWebhook admission controller0
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.5 Extensible Admission Control
- Description
Configure Image Provenance for your deployment.
- Default Value
By default, image provenance is not set.
- Audit Procedure
Review the pod definitions in your cluster and verify that image provenance is configured as appropriate.
- Impact Statement
You need to regularly maintain your provenance configuration based on container image updates.
- Assessment Status
Manual
- Rationale Statement
Kubernetes supports plugging in provenance rules to accept or reject the images in your deployments. You could configure such rules to ensure that only approved images are deployed in the cluster.
- Remediation Procedure
Follow the Kubernetes documentation and setup image provenance.
5.7.1Create administrative boundaries between resources using namespaces0
Attributes
- Profile
Level 1
- Section
5 Policies
- Sub Section
5.7 General Policies
- Description
Use namespaces to isolate your Kubernetes objects.
- Default Value
By default, Kubernetes starts with 4 initial namespaces:1.
default- The default namespace for objects with no other namespace1.kube-system- The namespace for objects created by the Kubernetes system1.kube-node-lease- Namespace used for node heartbeats1.kube-public- Namespace used for public information in a cluster- Audit Procedure
Run the below command and review the namespaces created in the cluster.kubectl get namespacesEnsure that these namespaces are the ones you need and are adequately administered as per your requirements.
- Impact Statement
You need to switch between namespaces for administration.
- Assessment Status
Manual
- Rationale Statement
Limiting the scope of user permissions can reduce the impact of mistakes or malicious activities. A Kubernetes namespace allows you to partition created resources into logically named groups. Resources created in one namespace can be hidden from other namespaces. By default, each resource created by a user in Kubernetes cluster runs in a default namespace, called
default. You can create additional namespaces and attach resources and users to them. You can use Kubernetes Authorization plugins to create policies that segregate access to namespace resources between different users.- Remediation Procedure
Follow the documentation and create namespaces for objects in your deployment as you need them.
5.7.2Ensure that the seccomp profile is set to docker/default in your pod definitions1
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.7 General Policies
- Description
Enable
docker/defaultseccomp profile in your pod definitions.- Default Value
By default, seccomp profile is set to
unconfinedwhich means that no seccomp profiles are enabled.- Audit Procedure
Review the pod definitions in your cluster. It should create a line as below:securityContext:seccompProfile:type: RuntimeDefault
- Impact Statement
If the
docker/defaultseccomp profile is too restrictive for you, you would have to create/manage your own seccomp profiles.- Assessment Status
Manual
- Rationale Statement
Seccomp (secure computing mode) is used to restrict the set of system calls applications can make, allowing cluster administrators greater control over the security of workloads running in the cluster. Kubernetes disables seccomp profiles by default for historical reasons. You should enable it to ensure that the workloads have restricted actions available within the container.
- Remediation Procedure
Use security context to enable the
docker/defaultseccomp profile in your pod definitions. An example is as below:securityContext:seccompProfile:type: RuntimeDefault
5.7.3Apply Security Context to Your Pods and Containers0
Attributes
- Profile
Level 2
- Section
5 Policies
- References
- https://kubernetes.io/docs/concepts/policy/security-context/:https://learn.cisecurity.org/benchmarks
- Sub Section
5.7 General Policies
- Description
Apply Security Context to Your Pods and Containers
- Default Value
By default, no security contexts are automatically applied to pods.
- Audit Procedure
Review the pod definitions in your cluster and verify that you have security contexts defined as appropriate.
- Impact Statement
If you incorrectly apply security contexts, you may have trouble running the pods.
- Assessment Status
Manual
- Rationale Statement
A security context defines the operating system security settings (uid, gid, capabilities, SELinux role, etc..) applied to a container. When designing your containers and pods, make sure that you configure the security context for your pods, containers, and volumes. A security context is a property defined in the deployment yaml. It controls the security parameters that will be assigned to the pod/container/volume. There are two levels of security context: pod level security context, and container level security context.
- Remediation Procedure
Follow the Kubernetes documentation and apply security contexts to your pods. For a suggested list of security contexts, you may refer to the CIS Security Benchmark for Docker Containers.
5.7.4The default namespace should not be used0
Attributes
- Profile
Level 2
- Section
5 Policies
- Sub Section
5.7 General Policies
- Description
Kubernetes provides a default namespace, where objects are placed if no namespace is specified for them. Placing objects in this namespace makes application of RBAC and other controls more difficult.
- Default Value
Unless a namespace is specific on object creation, the
defaultnamespace will be used- Audit Procedure
Run this command to list objects in default namespacekubectl get $(kubectl api-resources --verbs=list --namespaced=true -o name | paste -sd, -) --ignore-not-found -n defaultThe only entries there should be system managed resources such as the
kubernetesservice- Impact Statement
None
- Assessment Status
Manual
- Rationale Statement
Resources in a Kubernetes cluster should be segregated by namespace, to allow for security controls to be applied at that level and to make it easier to manage resources.
- Remediation Procedure
Ensure that namespaces are created to allow for appropriate segregation of Kubernetes resources and that all new resources are created in a specific namespace.