Skip to content

Excessive permissions on kubewarden-controller ServiceAccount

High
viccuad published GHSA-5877-g4h3-mf3c Apr 17, 2023

Package

kubewarden-controller (Helm chart)

Affected versions

< 1.6.0 (kubewarden-controller-1.5.0)

Patched versions

1.6.0 (kubewarden-controller-1.5.0)

Description

Impact

Kubewarden is a policy engine for Kubernetes. The Kubewarden stack is deployed
via Helm charts. The Kubewarden stack has Deployments called
kubewarden-controller, that by default get randomly scheduled on cluster nodes.
The Deployments run under the ServiceAccount kubewarden-controller, and that
ServiceAccount is bound to a ClusterRole called
kubewarden-controller-manager-cluster-role. This cluster role has read
permissions ("get list watch" verbs) over the Secret resources of the cluster.

Thus, once an attacker has previous access to the worker node where the
kubewarden-controller deployment runs, they can leverage the ServiceAccount to
get read access of all the secrets in the entire cluster (i.e., cluster's admin
token if present), resulting in a cluster-level privilege escalation.

Patches

This problem is mitigated by reducing the scope of the ClusterRole
kubewarden-controller-manager-cluster-role ClusterRole, removing "get list
watch" verbs for secrets in it. This restricts access to only those secrets in
the namespace "kubewarden", assigned by the already existing Role
kubewarden-controller-manager-namespaced-role.

In addition, the kubewarden-controller image has been patched so the Kubernetes
go-clients used in the watches of controller-runtime neither watch nor cache
unneeded resources. Hence Secrets outside the default Kubewarden namespace are
not watched nor cached, even if the controller is not making use of them.

Workarounds

Reduce permissions of ClusterRole kubewarden-controller-manager-cluster-role
and remove Secrets from it.

Given that the kubewarden-controller image needed changes for its Kubernetes
go-client cache, it is not enough with reducing the scope of the
kubewarden-controller-manager-cluster-role ClusterRole. One must also consume
the image kubewarden-controller:v1.6.0 or later.

References

#216
kubewarden/kubewarden-controller#429

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
High
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H

CVE ID

CVE-2023-22645

Weaknesses

No CWEs

Credits