From oss-security Tue Apr 16 21:48:15 2024 From: Rita Zhang Date: Tue, 16 Apr 2024 21:48:15 +0000 To: oss-security Subject: [oss-security] [kubernetes] CVE-2024-3177: Bypassing mountable secrets policy imposed by the Service Message-Id: X-MARC-Message: https://marc.info/?l=oss-security&m=171330407219681 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--000000000000b93c0106163db220" --000000000000b93c0106163db220 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Kubernetes Community, A security issue was discovered in Kubernetes where users may be able to launch containers that bypass the mountable secrets policy enforced by the ServiceAccount admission plugin when using containers, init containers, and ephemeral containers with the envFrom field populated. The policy ensures pods running with a service account may only reference secrets specified in the service account=E2=80=99s secrets field. Kubernetes clusters are only a= ffected if the ServiceAccount admission plugin and the kubernetes.io/enforce-mountable-secrets annotation are used together with containers, init containers, and ephemeral containers with the envFrom field populated. This issue has been rated Low CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:N/A:N , and assigned CVE-2024-3177 Am I vulnerable? Clusters are impacted by this vulnerability if all of the following are true: 1. The ServiceAccount admission plugin is used. Most cluster should have this on by default as recommended in https://kubernetes.io/docs/reference/access-authn-authz/admission-contro= llers/#serviceaccount 2. The kubernetes.io/enforce-mountable-secrets annotation is used by a service account. This annotation is not added by default. 3. Pods using containers, init containers, and ephemeral containers with the envFrom field populated. Affected Versions - kube-apiserver v1.29.0 - v1.29.3 - kube-apiserver v1.28.0 - v1.28.8 - kube-apiserver <=3D v1.27.12 How do I mitigate this vulnerability? This issue can be mitigated by applying the patch provided for the kube-apiserver component. The patch prevents containers, init containers, and ephemeral containers with the envFrom field populated from bypassing the mountable secrets policy enforced by the ServiceAccount admission plugin. Fixed Versions - kube-apiserver v1.29.4 - kube-apiserver v1.28.9 - kube-apiserver v1.27.13 These releases have been published today, April 16th, 2024. Detection Pod update requests using a container, init container, or ephemeral container with the envFrom field populated that exploits this vulnerability with unintended secret will be captured in API audit logs. You can also use the following kubectl command to find active pods using the kubernetes.io/enforce-mountable-secrets annotation. `kubectl get serviceaccounts --all-namespaces -o jsonpath=3D"{range .items[?(@.metadata.annotations['kubernetes\.io/enforce-mountable-secrets']= =3D=3D'true')]}{.metadata.namespace}{'\t'}{. metadata.name}{'\n'}{end}"` Additional Details See the GitHub issue for more details: https://github.com/kubernetes/kubernetes/issues/124336 Acknowledgements This vulnerability was reported by tha3e1vl. The issue was fixed and coordinated by the fix team: Rita Zhang @ritazh Joel Smith @joelsmith Mo Khan @enj and release managers: Sascha Grunert @saschagrunert Jeremy Rickard @jeremyrickard Thank You, Rita Zhang on behalf of the Kubernetes Security Response Committee --000000000000b93c0106163db220--