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’s secrets field. Kubernetes clusters are only affected 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:
-
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-controllers/#serviceaccount
-
The kubernetes.io/enforce-mountable-secrets annotation is used by a service account. This annotation is not added by default.
-
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 <= 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="{range .items[?(@.metadata.annotations['kubernetes\.io/enforce-mountable-secrets']=='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