CVE-2021-41254 Privilege escalation to cluster admin on multi-tenant environments
Authenticated users can escalate to cluster admin by injecting shell commands into Secrets processed by the kustomize-controller in multi-tenant environments.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2021-41254?
CVE-2021-41254 is a high-severity command injection vulnerability in fluxcd kustomize-controller, published on 12 Nov 2021. Any signed-in user can exploit it over the network, with no action from the victim.
Official description
kustomize-controller is a Kubernetes operator, specialized in running continuous delivery pipelines for infrastructure and workloads defined with Kubernetes manifests and assembled with Kustomize. Users that can create Kubernetes Secrets, Service Accounts and Flux Kustomization objects, could execute commands inside the kustomize-controller container by embedding a shell script in a Kubernetes Secret. This can be used to run `kubectl` commands under the Service Account of kustomize-controller, thus allowing an authenticated Kubernetes user to gain cluster admin privileges. In affected versions multitenant environments where non-admin users have permissions to create Flux Kustomization objects are affected by this issue. This vulnerability was fixed in kustomize-controller v0.15.0 (included in flux2 v0.18.0) released on 2021-10-08. Starting with v0.15, the kustomize-controller no longer executes shell commands on the container OS and the `kubectl` binary has been removed from the container image. To prevent the creation of Kubernetes Service Accounts with `secrets` in namespaces owned by tenants, a Kubernetes validation webhook such as Gatekeeper OPA or Kyverno can be used.
Weakness: CWE-78
Which versions are affected by CVE-2021-41254?
4 open source packages ship an affected version, including github.com/fluxcd/kustomize-controller and kustomize. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
github.com/fluxcd/kustomize-controller Go | All versions | 0.15.0 |
github.com/fluxcd/kustomize-controller Go | All versions | 0.15.0 |
github.com/fluxcd/kustomize-controller Go | All versions | 0.15.0 |
kustomize Bitnami | All versions | 0.15.0 |
Products include Fluxcd Kustomize-Controller.
How do I fix CVE-2021-41254?
Upgrade github.com/fluxcd/kustomize-controller to 0.15.0 or later.
Upgrade, and pass arguments to programs as a list instead of through a shell. More about Command injection.
Is CVE-2021-41254 being exploited?
There is no known exploitation of CVE-2021-41254 in the wild and no public exploit code.
Sources
Also known as BIT-kustomize-2021-41254, GHSA-35rf-v2jv-gfg7, GO-2022-0260.