mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-12-18 20:58:10 +00:00
35cf28c140
* Remove unnecessary whitespaces * Fix a typo * Add integration tests for cis 1.3 and cis 1.5 * Change the timeout of integration tests from 600s to 1200s * Avoid repeated codes
327 lines
18 KiB
Plaintext
327 lines
18 KiB
Plaintext
[INFO] 1 Master Node Security Configuration
|
|
[INFO] 1.1 API Server
|
|
[WARN] 1.1.1 Ensure that the --anonymous-auth argument is set to false (Not Scored)
|
|
[PASS] 1.1.2 Ensure that the --basic-auth-file argument is not set (Scored)
|
|
[PASS] 1.1.3 Ensure that the --insecure-allow-any-token argument is not set (Not Scored)
|
|
[PASS] 1.1.4 Ensure that the --kubelet-https argument is set to true (Scored)
|
|
[PASS] 1.1.5 Ensure that the --insecure-bind-address argument is not set (Scored)
|
|
[PASS] 1.1.6 Ensure that the --insecure-port argument is set to 0 (Scored)
|
|
[PASS] 1.1.7 Ensure that the --secure-port argument is not set to 0 (Scored)
|
|
[FAIL] 1.1.8 Ensure that the --profiling argument is set to false (Scored)
|
|
[FAIL] 1.1.9 Ensure that the --repair-malformed-updates argument is set to false (Scored)
|
|
[PASS] 1.1.10 Ensure that the admission control plugin AlwaysAdmit is not set (Scored)
|
|
[FAIL] 1.1.11 Ensure that the admission control plugin AlwaysPullImages is set (Scored)
|
|
[INFO] 1.1.12 [DEPRECATED] Ensure that the admission control plugin DenyEscalatingExec is set (Not Scored)
|
|
[WARN] 1.1.13 Ensure that the admission control plugin SecurityContextDeny is set (Not Scored)
|
|
[PASS] 1.1.14 Ensure that the admission control plugin NamespaceLifecycle is set (Scored)
|
|
[FAIL] 1.1.15 Ensure that the --audit-log-path argument is set as appropriate (Scored)
|
|
[FAIL] 1.1.16 Ensure that the --audit-log-maxage argument is set to 30 or as appropriate (Scored)
|
|
[FAIL] 1.1.17 Ensure that the --audit-log-maxbackup argument is set to 10 or as appropriate (Scored)
|
|
[FAIL] 1.1.18 Ensure that the --audit-log-maxsize argument is set to 100 or as appropriate (Scored)
|
|
[PASS] 1.1.19 Ensure that the --authorization-mode argument is not set to AlwaysAllow (Scored)
|
|
[PASS] 1.1.20 Ensure that the --token-auth-file parameter is not set (Scored)
|
|
[FAIL] 1.1.21 Ensure that the --kubelet-certificate-authority argument is set as appropriate (Scored)
|
|
[PASS] 1.1.22 Ensure that the --kubelet-client-certificate and --kubelet-client-key arguments are set as appropriate (Scored)
|
|
[PASS] 1.1.23 Ensure that the --service-account-lookup argument is set to true (Scored)
|
|
[FAIL] 1.1.24 Ensure that the admission control plugin PodSecurityPolicy is set (Scored)
|
|
[PASS] 1.1.25 Ensure that the --service-account-key-file argument is set as appropriate (Scored)
|
|
[PASS] 1.1.26 Ensure that the --etcd-certfile and --etcd-keyfile arguments are set as appropriate (Scored)
|
|
[PASS] 1.1.27 Ensure that the admission control plugin ServiceAccount is set(Scored)
|
|
[PASS] 1.1.28 Ensure that the --tls-cert-file and --tls-private-key-file arguments are set as appropriate (Scored)
|
|
[PASS] 1.1.29 Ensure that the --client-ca-file argument is set as appropriate (Scored)
|
|
[PASS] 1.1.30 Ensure that the --etcd-cafile argument is set as appropriate (Scored)
|
|
[WARN] 1.1.31 Ensure that the API Server only makes use of Strong Cryptographic Ciphers (Not Scored)
|
|
[PASS] 1.1.32 Ensure that the --authorization-mode argument is set to Node (Scored)
|
|
[PASS] 1.1.33 Ensure that the admission control plugin NodeRestriction is set (Scored)
|
|
[FAIL] 1.1.34 Ensure that the --encryption-provider-config argument is set as appropriate (Scored)
|
|
[WARN] 1.1.35 Ensure that the encryption provider is set to aescbc (Scored)
|
|
[FAIL] 1.1.36 Ensure that the admission control plugin EventRateLimit is set (Scored)
|
|
[PASS] 1.1.37a Ensure that the AdvancedAuditing argument is not set to false (Scored)
|
|
[FAIL] 1.1.37b Ensure that the AdvancedAuditing argument is not set to false (Scored)
|
|
[PASS] 1.1.38 Ensure that the --request-timeout argument is set as appropriate (Scored)
|
|
[PASS] 1.1.39 Ensure that the --authorization-mode argument includes RBAC (Scored)
|
|
[INFO] 1.2 Scheduler
|
|
[FAIL] 1.2.1 Ensure that the --profiling argument is set to false (Scored)
|
|
[PASS] 1.2.2 Ensure that the --address argument is set to 127.0.0.1 (Scored)
|
|
[INFO] 1.3 Controller Manager
|
|
[FAIL] 1.3.1 Ensure that the --terminated-pod-gc-threshold argument is set as appropriate (Scored)
|
|
[FAIL] 1.3.2 Ensure that the --profiling argument is set to false (Scored)
|
|
[PASS] 1.3.3 Ensure that the --use-service-account-credentials argument is set to true (Scored)
|
|
[PASS] 1.3.4 Ensure that the --service-account-private-key-file argument is set as appropriate (Scored)
|
|
[PASS] 1.3.5 Ensure that the --root-ca-file argument is set as appropriate (Scored)
|
|
[FAIL] 1.3.6 Ensure that the RotateKubeletServerCertificate argument is set to true (Scored)
|
|
[PASS] 1.3.7 Ensure that the --address argument is set to 127.0.0.1 (Scored)
|
|
[INFO] 1.4 Configuration Files
|
|
[PASS] 1.4.1 Ensure that the API server pod specification file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.2 Ensure that the API server pod specification file ownership is set to root:root (Scored)
|
|
[PASS] 1.4.3 Ensure that the controller manager pod specification file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.4 Ensure that the controller manager pod specification file ownership is set to root:root (Scored)
|
|
[PASS] 1.4.5 Ensure that the scheduler pod specification file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.6 Ensure that the scheduler pod specification file ownership is set to root:root (Scored)
|
|
[PASS] 1.4.7 Ensure that the etcd pod specification file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.8 Ensure that the etcd pod specification file ownership is set to root:root (Scored)
|
|
[WARN] 1.4.9 Ensure that the Container Network Interface file permissions are set to 644 or more restrictive (Not Scored)
|
|
[WARN] 1.4.10 Ensure that the Container Network Interface file ownership is set to root:root (Not Scored)
|
|
[PASS] 1.4.11 Ensure that the etcd data directory permissions are set to 700 or more restrictive (Scored)
|
|
[FAIL] 1.4.12 Ensure that the etcd data directory ownership is set to etcd:etcd (Scored)
|
|
[PASS] 1.4.13 Ensure that the admin.conf file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.14 Ensure that the admin.conf file ownership is set to root:root (Scored)
|
|
[PASS] 1.4.15 Ensure that the scheduler.conf file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.16 Ensure that the scheduler.conf file ownership is set to root:root (Scored)
|
|
[PASS] 1.4.17 Ensure that the controller-manager.conf file permissions are set to 644 or more restrictive (Scored)
|
|
[PASS] 1.4.18 Ensure that the controller-manager.conf file ownership is set to root:root (Scored)
|
|
[WARN] 1.4.19 Ensure that the Kubernetes PKI directory and file ownership is set to root:root (Scored)
|
|
[WARN] 1.4.20 Ensure that the Kubernetes PKI certificate file permissions are set to 644 or more restrictive (Scored)
|
|
[WARN] 1.4.21 Ensure that the Kubernetes PKI key file permissions are set to 600 or more restrictive (Scored)
|
|
[INFO] 1.5 etcd
|
|
[PASS] 1.5.1 Ensure that the --cert-file and --key-file arguments are set as appropriate (Scored)
|
|
[PASS] 1.5.2 Ensure that the --client-cert-auth argument is set to true (Scored)
|
|
[PASS] 1.5.3 Ensure that the --auto-tls argument is not set to true (Scored)
|
|
[PASS] 1.5.4 Ensure that the --peer-cert-file and --peer-key-file arguments are set as appropriate (Scored)
|
|
[PASS] 1.5.5 Ensure that the --peer-client-cert-auth argument is set to true (Scored)
|
|
[PASS] 1.5.6 Ensure that the --peer-auto-tls argument is not set to true (Scored)
|
|
[WARN] 1.5.7 Ensure that a unique Certificate Authority is used for etcd (Not Scored)
|
|
[INFO] 1.6 General Security Primitives
|
|
[WARN] 1.6.1 Ensure that the cluster-admin role is only used where required (Not Scored)
|
|
[WARN] 1.6.2 Create administrative boundaries between resources using namespaces (Not Scored)
|
|
[WARN] 1.6.3 Create network segmentation using Network Policies (Not Scored)
|
|
[WARN] 1.6.4 Ensure that the seccomp profile is set to docker/default in your pod definitions (Not Scored)
|
|
[WARN] 1.6.5 Apply Security Context to Your Pods and Containers (Not Scored)
|
|
[WARN] 1.6.6 Configure Image Provenance using ImagePolicyWebhook admission controller (Not Scored)
|
|
[WARN] 1.6.7 Configure Network policies as appropriate (Not Scored)
|
|
[WARN] 1.6.8 Place compensating controls in the form of PSP and RBAC for privileged containers usage (Not Scored)
|
|
[INFO] 1.7 PodSecurityPolicies
|
|
[WARN] 1.7.1 Do not admit privileged containers (Not Scored)
|
|
[WARN] 1.7.2 Do not admit containers wishing to share the host process ID namespace (Scored)
|
|
[WARN] 1.7.3 Do not admit containers wishing to share the host IPC namespace (Scored)
|
|
[WARN] 1.7.4 Do not admit containers wishing to share the host network namespace (Scored)
|
|
[WARN] 1.7.5 Do not admit containers with allowPrivilegeEscalation (Scored)
|
|
[WARN] 1.7.6 Do not admit root containers (Not Scored)
|
|
[WARN] 1.7.7 Do not admit containers with dangerous capabilities (Not Scored)
|
|
|
|
== Remediations ==
|
|
1.1.1 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the below parameter.
|
|
--anonymous-auth=false
|
|
|
|
1.1.8 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the below parameter.
|
|
--profiling=false
|
|
|
|
1.1.9 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the below parameter.
|
|
--repair-malformed-updates=false
|
|
|
|
1.1.11 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --enable-admission-plugins to
|
|
include AlwaysPullImages.
|
|
--enable-admission-plugins=...,AlwaysPullImages,...
|
|
|
|
1.1.13 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --enable-admission-plugins parameter to
|
|
include SecurityContextDeny.
|
|
--enable-admission-plugins=...,SecurityContextDeny,...
|
|
|
|
1.1.15 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --audit-log-path parameter 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.1.16 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --audit-log-maxage parameter to 30 or
|
|
as an appropriate number of days: --audit-log-maxage=30
|
|
|
|
1.1.17 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --audit-log-maxbackup parameter to 10
|
|
or to an appropriate value.
|
|
--audit-log-maxbackup=10
|
|
|
|
1.1.18 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --audit-log-maxsize parameter to an
|
|
appropriate size in MB. For example, to set it as 100 MB:
|
|
--audit-log-maxsize=100
|
|
|
|
1.1.21 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.yaml on the master node and set the --kubelet-certificate-authority
|
|
parameter to the path to the cert file for the certificate authority.
|
|
--kubelet-certificate-authority=<ca-string>
|
|
|
|
1.1.24 Follow the documentation and create Pod Security Policy objects as per your environment.
|
|
Then, edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the --enable-admission-plugins parameter to a
|
|
value that includes PodSecurityPolicy :
|
|
--enable-admission-plugins=...,PodSecurityPolicy,...
|
|
Then restart the API Server.
|
|
|
|
1.1.31 Edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
on the master node and set the below parameter.
|
|
--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_SHA256
|
|
|
|
1.1.34 [Manual test]
|
|
Follow the Kubernetes documentation and configure a EncryptionConfig file.
|
|
Then, edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the
|
|
master node and set the --encryption-provider-config parameter
|
|
to the path of that file:
|
|
--encryption-provider-config=</path/to/EncryptionConfig/File>
|
|
|
|
1.1.35 [Manual test]
|
|
Follow the Kubernetes documentation and configure a EncryptionConfig file. In this file,
|
|
choose aescbc as the encryption provider.
|
|
For example,
|
|
kind: EncryptionConfig
|
|
apiVersion: v1
|
|
resources:
|
|
- resources:
|
|
- secrets
|
|
providers:
|
|
- aescbc:
|
|
keys:
|
|
- name: key1
|
|
secret: <32-byte base64-encoded secret>
|
|
|
|
1.1.36 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.yaml and set the below parameters.
|
|
--enable-admission-plugins=...,EventRateLimit,...
|
|
--admission-control-config-file=<path/to/configuration/file>
|
|
|
|
1.1.37b Follow the Kubernetes documentation and set the desired audit policy in the
|
|
/etc/kubernetes/audit-policy.yaml file. Then, edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml
|
|
and set the below parameters.
|
|
--audit-policy-file=/etc/kubernetes/audit-policy.yaml
|
|
|
|
1.2.1 Edit the Scheduler pod specification file /etc/kubernetes/manifests/kube-scheduler.yaml
|
|
file on the master node and set the below parameter.
|
|
--profiling=false
|
|
|
|
1.3.1 Edit the Controller Manager pod specification file /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
on the master node and set the --terminated-pod-gc-threshold to an appropriate threshold, for example:
|
|
--terminated-pod-gc-threshold=10
|
|
|
|
1.3.2 Edit the Controller Manager pod specification file /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
on the master node and set the below parameter.
|
|
--profiling=false
|
|
|
|
1.3.6 Edit the Controller Manager pod specification file /etc/kubernetes/manifests/kube-controller-manager.yaml
|
|
controller-manager.yaml on the master node and set the --feature-gates parameter to
|
|
include RotateKubeletServerCertificate=true.
|
|
--feature-gates=RotateKubeletServerCertificate=true
|
|
|
|
1.4.9 [Manual test]
|
|
Run the below command (based on the file location on your system) on the master node.
|
|
For example,
|
|
chmod 644 <path/to/cni/files>
|
|
|
|
1.4.10 [Manual test]
|
|
Run the below command (based on the file location on your system) on the master node.
|
|
For example,
|
|
chown root:root <path/to/cni/files>
|
|
|
|
1.4.12 On the etcd server node, get the etcd data directory, passed as an argument --data-dir ,
|
|
from the below command:
|
|
ps -ef | grep etcd
|
|
Run the below command (based on the etcd data directory found above). For example,
|
|
chown etcd:etcd /var/lib/etcd
|
|
|
|
1.4.19 [Manual test]
|
|
Run the below command (based on the file location on your system) on the master node.
|
|
For example, chown -R root:root /etc/kubernetes/pki/
|
|
|
|
1.4.20 [Manual test]
|
|
Run the below command (based on the file location on your system) on the master node.
|
|
For example, chmod -R 644 /etc/kubernetes/pki/*.crt
|
|
|
|
1.4.21 [Manual test]
|
|
Run the below command (based on the file location on your system) on the master node.
|
|
For example, chmod -R 600 /etc/kubernetes/pki/*.key
|
|
|
|
1.5.7 [Manual test]
|
|
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.yaml on the
|
|
master node and set the below parameter.
|
|
--trusted-ca-file=</path/to/ca-file>
|
|
|
|
1.6.1 [Manual test]
|
|
Remove any unneeded clusterrolebindings :
|
|
kubectl delete clusterrolebinding [name]
|
|
|
|
1.6.2 [Manual test]
|
|
Follow the documentation and create namespaces for objects in your deployment as you
|
|
need them.
|
|
|
|
1.6.3 [Manual test]
|
|
Follow the documentation and create NetworkPolicy objects as you need them.
|
|
|
|
1.6.4 [Manual test]
|
|
Seccomp is an alpha feature currently. By default, all alpha features are disabled. So, you
|
|
would need to enable alpha features in the apiserver by passing "--feature-
|
|
gates=AllAlpha=true" argument.
|
|
Edit the /etc/kubernetes/manifests/kube-apiserver.yaml file on the master node and set the KUBE_API_ARGS
|
|
parameter to "--feature-gates=AllAlpha=true"
|
|
KUBE_API_ARGS="--feature-gates=AllAlpha=true"
|
|
Based on your system, restart the kube-apiserver service. For example:
|
|
systemctl restart kube-apiserver.service
|
|
Use annotations to enable the docker/default seccomp profile in your pod definitions. An
|
|
example is as below:
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata:
|
|
name: trustworthy-pod
|
|
annotations:
|
|
seccomp.security.alpha.kubernetes.io/pod: docker/default
|
|
spec:
|
|
containers:
|
|
- name: trustworthy-container
|
|
image: sotrustworthy:latest
|
|
|
|
1.6.5 [Manual test]
|
|
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.
|
|
|
|
1.6.6 [Manual test]
|
|
Follow the Kubernetes documentation and setup image provenance.
|
|
|
|
1.6.7 [Manual test]
|
|
Follow the Kubernetes documentation and setup network policies as appropriate.
|
|
For example, you could create a "default" isolation policy for a Namespace by creating a
|
|
NetworkPolicy that selects all pods but does not allow any traffic:
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: default-deny
|
|
spec:
|
|
podSelector:
|
|
|
|
1.6.8 [Manual test]
|
|
Follow Kubernetes documentation and setup PSP and RBAC authorization for your cluster.
|
|
|
|
1.7.1 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.privileged field is omitted or set to false.
|
|
|
|
1.7.2 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostPID field is omitted or set to false.
|
|
|
|
1.7.3 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostIPC field is omitted or set to false.
|
|
|
|
1.7.4 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.hostNetwork field is omitted or set to false.
|
|
|
|
1.7.5 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.allowPrivilegeEscalation field is omitted or set to false.
|
|
|
|
1.7.6 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.runAsUser.rule is set to either MustRunAsNonRoot or MustRunAs with the range of UIDs not including 0.
|
|
|
|
1.7.7 [Manual test]
|
|
Create a PSP as described in the Kubernetes documentation, ensuring that the .spec.requiredDropCapabilities is set to include either NET_RAW or ALL.
|
|
|
|
|
|
== Summary ==
|
|
49 checks PASS
|
|
17 checks FAIL
|
|
25 checks WARN
|
|
1 checks INFO |