CVE-2023-46254 (published 2023-11-06T19:15Z)

capsule-proxy is a reverse proxy for Capsule kubernetes multi-tenancy framework. A bug in the RoleBinding reflector used by `capsule-proxy` gives ServiceAccount tenant owners the right to list Namespaces of other tenants backed by the same owner kind and name. For example consider two tenants `solar` and `wind`. Tenant `solar`, owned by a ServiceAccount named `tenant-owner` in the Namespace `solar`. Tenant `wind`, owned by a ServiceAccount named `tenant-owner` in the Namespace `wind`. The Tenant owner `solar` would be able to list the namespaces of the Tenant `wind` and vice-versa, although this is not correct. The bug introduces an exfiltration vulnerability since allows the listing of Namespace resources of other Tenants, although just in some specific conditions: 1. `capsule-proxy` runs with the `--disable-caching=false` (default value: `false`) and 2. Tenant owners are ServiceAccount, with the same resource name, but in different Namespaces. This vulnerability doesn't allow any privilege escalation on the outer tenant Namespace-scoped resources, since the Kubernetes RBAC is enforcing this. This issue has been addressed in version 0.4.5. Users are advised to upgrade. There are no known workarounds for this vulnerability.

CVSS v3 base score: 4.3, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N)

Weakness information:
cwe_id: NVD-CWE-noinfo
cwe_name: Insufficient Information
description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/projectcapsule/capsule-proxy
commit_details: repo_url: https://github.com/projectcapsule/capsule-proxy
author: Dario Tranchitella
author_date: 2023-10-30 09:27:00+01:00
msg: fix(rolebinding-reflector): namespaced name for serviceaccount users
repository: repo_url: https://github.com/projectcapsule/capsule-proxy
repo_name: projectcapsule/capsule-proxy
description: Reverse proxy for Capsule Operator.
repo_language: Go
owner: projectcapsule
file_changes: filename: role_bindings.go
change_type: ModificationType.MODIFY
diff: @@ -61,10 +61,12 @@ func (r *RoleBindingReflector) GetUserNamespacesFromRequest(req request.Request)
 	if strings.HasPrefix(username, serviceaccount.ServiceAccountUsernamePrefix) {
 		userOwnerKind = capsulev1beta2.ServiceAccountOwner
 
-		_, username, err = serviceaccount.SplitUsername(username)
-		if err != nil {
-			return nil, errors.Wrap(err, "Unable to parse serviceAccount name")
+		namespace, name, splitErr := serviceaccount.SplitUsername(username)
+		if splitErr != nil {
+			return nil, errors.Wrap(splitErr, "Unable to parse serviceAccount name")
 		}
+
+		username = fmt.Sprintf("%s-%s", namespace, name)
 	}
 
 	userRoleBindings, err = r.store.ByIndex(subjectIndex, fmt.Sprintf("%s-%s", userOwnerKind, username))
@@ -102,7 +104,15 @@ func OwnerRoleBindingsIndexFunc(obj interface{}) (result []string, err error) {
 	rb := obj.(*rbacv1.RoleBinding)
 
 	for _, subject := range rb.Subjects {
-		result = append(result, fmt.Sprintf("%s-%s", subject.Kind, subject.Name))
+		parts := []string{subject.Kind}
+
+		if len(subject.Namespace) > 0 {
+			parts = append(parts, subject.Namespace)
+		}
+
+		parts = append(parts, subject.Name)
+
+		result = append(result, strings.Join(parts, "-"))
 	}
 
 	return result, nil

programming_language: Go