Skip to content

Commit b8c6ed9

Browse files
committed
Update to benchmark version 1.1.0
Signed-off-by: Kristian Vlaardingerbroek <[email protected]>
1 parent 9972b99 commit b8c6ed9

8 files changed

+167
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CIS Kubernetes Benchmark - InSpec Profile
22

33
## Description
4-
This profile implements [CIS Kubernetes 1.6 Benchmark v1.0.0](https://www.cisecurity.org/benchmark/kubernetes/).
4+
This profile implements the [CIS Kubernetes 1.1.0 Benchmark](https://www.cisecurity.org/benchmark/kubernetes/).
55

66
## License and Author
77

controls/1_1_master_node_api_server.rb

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
tag level: 1
318318

319319
describe processes('kube-apiserver').commands.to_s do
320-
it { should_not match(/--authorization-mode=AlwaysAllow/) }
320+
it { should_not match(/--authorization-mode=(?:.)*AlwaysAllow,*(?:.)*/) }
321321
it { should match(/--authorization-mode=/) }
322322
end
323323
end
@@ -467,3 +467,55 @@
467467
it { should match(/--etcd-cafile/) }
468468
end
469469
end
470+
471+
control 'cis-kubernetes-benchmark-1.1.32' do
472+
title 'Ensure that the --authorization-mode argument is set to Node'
473+
desc "Restrict kubelet nodes to reading only objects associated with them.\n\nRationale: The Node authorization mode only allows kubelets to read Secret, ConfigMap, PersistentVolume, and PersistentVolumeClaim objects associated with their nodes."
474+
impact 1.0
475+
476+
tag cis: 'kubernetes:1.1.32'
477+
tag level: 1
478+
479+
describe processes('kube-apiserver').commands.to_s do
480+
it { should match(/--authorization-mode=(?:.)*Node,*(?:.)*/) }
481+
end
482+
end
483+
484+
control 'cis-kubernetes-benchmark-1.1.33' do
485+
title 'Ensure that the admission control policy is set to NodeRestriction'
486+
desc "Limit the Node and Pod objects that a kubelet could modify.\n\nRationale: Using the NodeRestriction plug-in ensures that the kubelet is restricted to the Node and Pod objects that it could modify as defined. Such kubelets will only be allowed to modify their own Node API object, and only modify Pod API objects that are bound to their node."
487+
impact 1.0
488+
489+
tag cis: 'kubernetes:1.1.33'
490+
tag level: 1
491+
492+
describe processes('kube-apiserver').commands.to_s do
493+
it { should match(/--admission-control=(?:.)*NodeRestriction,*(?:.)*/) }
494+
end
495+
end
496+
497+
control 'cis-kubernetes-benchmark-1.1.34' do
498+
title 'Ensure that the --experimental-encryption-provider-config argument is set as appropriate'
499+
desc "Encrypt etcd key-value store.\n\nRationale: 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."
500+
impact 1.0
501+
502+
tag cis: 'kubernetes:1.1.34'
503+
tag level: 1
504+
505+
describe processes('kube-apiserver').commands.to_s do
506+
it { should match(/--experimental-encryption-provider-config=/) }
507+
end
508+
end
509+
510+
control 'cis-kubernetes-benchmark-1.1.35' do
511+
title 'Ensure that the encryption provider is set to aescbc'
512+
desc "Use aescbc encryption provider.\n\nRationale: aescbc is currently the strongest encryption provider, It should be preferred over other providers."
513+
impact 1.0
514+
515+
tag cis: 'kubernetes:1.1.35'
516+
tag level: 1
517+
518+
describe 'cis-kubernetes-benchmark-1.1.35' do
519+
skip 'Review the `EncryptionConfig` file and verify that `aescbc` is used as the encryption provider.'
520+
end
521+
end

controls/1_3_master_node_controller_manager.rb

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,53 +48,66 @@
4848
end
4949

5050
control 'cis-kubernetes-benchmark-1.3.3' do
51-
title 'Ensure that the --insecure-experimental-approve-all-kubelet-csrs-for-group argument is not set'
52-
desc "Do not accept all certificates.\n\nRationale: Setting the `--insecure-experimental-approve-all-kubelet-csrs-for-group` flag circumvents the desired “approval” process. All the certificates are auto-approved without checking their integrity. This flag is meant to be used for development and testing purposes only and hence should not be used in the production."
51+
title 'Ensure that the --use-service-account-credentials argument is set to true'
52+
desc "Use individual service account credentials for each controller.\n\nRationale: The controller manager creates a service account per controller in the `kube-system` namespace, 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-credentials` to `true` runs 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."
5353
impact 1.0
5454

5555
tag cis: 'kubernetes:1.3.3'
5656
tag level: 1
5757

5858
describe processes('kube-controller-manager').commands.to_s do
59-
it { should_not match(/--insecure-experimental-approve-all-kubelet-csrs-for-group/) }
59+
it { should match(/--use-service-account-credentials=true/) }
6060
end
6161
end
6262

6363
control 'cis-kubernetes-benchmark-1.3.4' do
64-
title 'Ensure that the --use-service-account-credentials argument is set to true'
65-
desc "Use individual service account credentials for each controller.\n\nRationale: The controller manager creates a service account per controller in the `kube-system` namespace, 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-credentials` to `true` runs 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."
64+
title 'Ensure that the --service-account-private-key-file argument is set as appropriate'
65+
desc "Explicitly set a service account private key file for service accounts on the controller manager.\n\nRationale: 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-file` as appropriate."
6666
impact 1.0
6767

6868
tag cis: 'kubernetes:1.3.4'
6969
tag level: 1
7070

7171
describe processes('kube-controller-manager').commands.to_s do
72-
it { should match(/--use-service-account-credentials=true/) }
72+
it { should match(/--service-account-private-key-file=/) }
7373
end
7474
end
7575

7676
control 'cis-kubernetes-benchmark-1.3.5' do
77-
title 'Ensure that the --service-account-private-key-file argument is set as appropriate'
78-
desc "Explicitly set a service account private key file for service accounts on the controller manager.\n\nRationale: 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-file` as appropriate."
77+
title 'Ensure that the --root-ca-file argument is set as appropriate'
78+
desc "Allow pods to verify the API server's serving certificate before establishing connections.\n\nRationale: 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-file` argument allows the controller manager to inject the trusted bundle into pods so that they can verify TLS connections to the API server."
7979
impact 1.0
8080

8181
tag cis: 'kubernetes:1.3.5'
8282
tag level: 1
8383

8484
describe processes('kube-controller-manager').commands.to_s do
85-
it { should match(/--service-account-private-key-file=/) }
85+
it { should match(/--root-ca-file=/) }
8686
end
8787
end
8888

8989
control 'cis-kubernetes-benchmark-1.3.6' do
90-
title 'Ensure that the --root-ca-file argument is set as appropriate'
91-
desc "Allow pods to verify the API server's serving certificate before establishing connections.\n\nRationale: 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-file` argument allows the controller manager to inject the trusted bundle into pods so that they can verify TLS connections to the API server."
92-
impact 1.0
90+
title 'Apply Security Context to Your Pods and Containers'
91+
desc "Apply Security Context to Your Pods and Containers.\n\nRationale: 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."
92+
impact 0.0
9393

9494
tag cis: 'kubernetes:1.3.6'
9595
tag level: 1
9696

97+
describe 'cis-kubernetes-benchmark-1.3.6' do
98+
skip 'Review the pod definitions in your cluster and verify that you have security contexts defined as appropriate.'
99+
end
100+
end
101+
102+
control 'cis-kubernetes-benchmark-1.3.7' do
103+
title 'Ensure that the RotateKubeletServerCertificate argument is set to true'
104+
desc "Enable kubelet server certificate rotation on controller-manager.\n\nRationale: RotateKubeletServerCertificate causes 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."
105+
impact 1.0
106+
107+
tag cis: 'kubernetes:1.3.7'
108+
tag level: 1
109+
97110
describe processes('kube-controller-manager').commands.to_s do
98-
it { should match(/--root-ca-file=/) }
111+
it { should match(/--feature-gates=(?:.)*RotateKubeletServerCertificate=true,*(?:.)*/) }
99112
end
100113
end

controls/1_6_master_node_general_security_primitives.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,53 +70,53 @@
7070
end
7171

7272
control 'cis-kubernetes-benchmark-1.6.5' do
73-
title 'Avoid using Kubernetes Secrets'
74-
desc "Avoid using Kubernetes `secret`.\n\nRationale: Kubernetes objects of type `secret` are intended to hold sensitive information, such as passwords, OAuth tokens, and ssh keys. Its current implementation is very basic. It has plenty of risks as highlighted in the reference links including storing secrets as plaintext. Avoid using Kubernetes secrets until you have devised a mechanism to protect them using your own means."
73+
title 'Ensure that the seccomp profile is set to docker/default in your pod definitions'
74+
desc "Enable `docker/default` seccomp profile in your pod definitions.\n\nRationale: 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."
7575
impact 0.0
7676

7777
tag cis: 'kubernetes:1.6.5'
7878
tag level: 2
7979

8080
describe 'cis-kubernetes-benchmark-1.6.5' do
81-
skip 'Review the output of `kubectl get secrets` and ensure they are the ones you need.'
81+
skip 'Review all the pod definitions in your cluster and verify that `seccomp` is enabled.'
8282
end
8383
end
8484

8585
control 'cis-kubernetes-benchmark-1.6.6' do
86-
title 'Ensure that the seccomp profile is set to docker/default in your pod definitions'
87-
desc "Enable `docker/default` seccomp profile in your pod definitions.\n\nRationale: 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."
86+
title 'Apply Security Context to Your Pods and Containers'
87+
desc "Apply Security Context to Your Pods and Containers\n\nRationale: 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."
8888
impact 0.0
8989

9090
tag cis: 'kubernetes:1.6.6'
9191
tag level: 2
9292

9393
describe 'cis-kubernetes-benchmark-1.6.6' do
94-
skip 'Review all the pod definitions in your cluster and verify that `seccomp` is enabled.'
94+
skip 'Review the pod definitions in your cluster and verify that you have security contexts defined as appropriate.'
9595
end
9696
end
9797

9898
control 'cis-kubernetes-benchmark-1.6.7' do
99-
title 'Apply Security Context to Your Pods and Containers'
100-
desc "Apply Security Context to Your Pods and Containers\n\nRationale: 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."
99+
title 'Configure Image Provenance using ImagePolicyWebhook admission controller'
100+
desc "Configure Image Provenance for your deployment.\n\nRationale: 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."
101101
impact 0.0
102102

103103
tag cis: 'kubernetes:1.6.7'
104104
tag level: 2
105105

106106
describe 'cis-kubernetes-benchmark-1.6.7' do
107-
skip 'Review the pod definitions in your cluster and verify that you have security contexts defined as appropriate.'
107+
skip 'Review the pod definitions in your cluster and verify that image provenance is configured as appropriate.'
108108
end
109109
end
110110

111111
control 'cis-kubernetes-benchmark-1.6.8' do
112-
title 'Configure Image Provenance using ImagePolicyWebhook admission controller'
113-
desc "Configure Image Provenance for your deployment.\n\nRationale: 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."
112+
title 'Configure Network policies as appropriate'
113+
desc "Configure Network policies as appropriate.\n\nRationale: The Network Policy API is now stable. Network policy, implemented through a network plug-in, allows users to set and enforce rules governing which pods can communicate with each other. You should leverage it as appropriate in your environment."
114114
impact 0.0
115115

116116
tag cis: 'kubernetes:1.6.8'
117117
tag level: 2
118118

119119
describe 'cis-kubernetes-benchmark-1.6.8' do
120-
skip 'Review the pod definitions in your cluster and verify that image provenance is configured as appropriate.'
120+
skip 'Review the network policies enforced and ensure that they are suitable for your requirements.'
121121
end
122122
end

controls/2_1_worker_node_kubelet.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
tag level: 1
5757

5858
describe processes('kubelet').commands.to_s do
59-
it { should_not match(/--authorization-mode=AlwaysAllow/) }
59+
it { should_not match(/--authorization-mode=(?:.)*AlwaysAllow,*(?:.)*/) }
6060
it { should match(/--authorization-mode=/) }
6161
end
6262
end
@@ -191,3 +191,29 @@
191191
it { should match(/--cadvisor-port=0/) }
192192
end
193193
end
194+
195+
control 'cis-kubernetes-benchmark-2.1.14' do
196+
title 'Ensure that the RotateKubeletClientCertificate argument is set to true'
197+
desc "Enable kubelet client certificate rotation.\n\nRationale: RotateKubeletClientCertificate 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 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."
198+
impact 1.0
199+
200+
tag cis: 'kubernetes:2.1.14'
201+
tag level: 1
202+
203+
describe processes('kubelet').commands.to_s do
204+
it { should match(/--feature-gates=(?:.)*RotateKubeletClientCertificate=true,*(?:.)*/) }
205+
end
206+
end
207+
208+
control 'cis-kubernetes-benchmark-2.1.15' do
209+
title 'Ensure that the RotateKubeletServerCertificate argument is set to true'
210+
desc "Enable kubelet server certificate rotation.\n\nRationale: RotateKubeletServerCertificate causes 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."
211+
impact 1.0
212+
213+
tag cis: 'kubernetes:2.1.15'
214+
tag level: 1
215+
216+
describe processes('kube-controller-manager').commands.to_s do
217+
it { should match(/--feature-gates=(?:.)*RotateKubeletServerCertificate=true,*(?:.)*/) }
218+
end
219+
end

controls/2_2_worker_node_configuration_files.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,46 @@
121121
it { should be_grouped_into 'root' }
122122
end
123123
end
124+
125+
control 'cis-kubernetes-benchmark-2.2.7' do
126+
title 'Ensure that the certificate authorities file permissions are set to 644 or more restrictive'
127+
desc "Ensure that the certificate authorities file has permissions of 644 or more restrictive.\n\nRationale: 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."
128+
impact 1.0
129+
130+
tag cis: 'kubernetes:2.2.7'
131+
tag level: 1
132+
133+
ca_cert_path = processes('kubelet').commands.to_s.scan(/--client-ca-file=(\S*)/)
134+
135+
if ca_cert_path.empty?
136+
describe 'cis-kubernetes-benchmark-2.2.7' do
137+
skip 'No client CA file specified for `kubelet` process'
138+
end
139+
else
140+
describe file(ca_cert_path.last.first).mode.to_s do
141+
it { should match(/[0246][024][024]/) }
142+
end
143+
end
144+
end
145+
146+
control 'cis-kubernetes-benchmark-2.2.8' do
147+
title 'Ensure that the client certificate authorities file ownership is set to root:root'
148+
desc "Ensure that the certificate authorities file ownership is set to root:root.\n\nRationale: 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."
149+
impact 1.0
150+
151+
tag cis: 'kubernetes:2.2.8'
152+
tag level: 1
153+
154+
ca_cert_path = processes('kubelet').commands.to_s.scan(/--client-ca-file=(\S*)/)
155+
156+
if ca_cert_path.empty?
157+
describe 'cis-kubernetes-benchmark-2.2.8' do
158+
skip 'No client CA file specified for `kubelet` process'
159+
end
160+
else
161+
describe file(ca_cert_path.last.first) do
162+
it { should be_owned_by 'root' }
163+
it { should be_grouped_into 'root' }
164+
end
165+
end
166+
end

controls/3_1_federation_api_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
tag level: 1
235235

236236
describe processes('federation-apiserver').commands.to_s do
237-
it { should_not match(/--authorization-mode=AlwaysAllow/) }
237+
it { should_not match(/--authorization-mode=(?:.)*AlwaysAllow,*(?:.)*/) }
238238
it { should match(/--authorization-mode=/) }
239239
end
240240
end

0 commit comments

Comments
 (0)