Summary
Kyverno's generate rules can allow a namespaced tenant to create resources outside their namespace when the rule's resource kind and namespace are supplied through variables. A tenant who can create a Policy and trigger a ConfigMap in their namespace may cause the privileged background controller to write resources into other namespaces.
Affected context
The issue affects Kyverno deployments with generate rules that template the resource kind and target namespace, where a namespaced tenant can create or influence the Policy and trigger resource. The background controller's privileges may let it create resources, such as NetworkPolicies or RoleBindings, in namespaces the tenant could not access directly.
Exploit preconditions
- Attack surface: Kyverno policy generation and its background controller
- Required access: Ability to create a Policy and a triggering ConfigMap in the tenant's namespace
- Trigger point: The controller processes the generated resource after the tenant's ConfigMap is created
- Why exploitation is possible: Templated kind and namespace values can direct the privileged controller to create resources outside the tenant's authorized scope
Why this happens
The underlying issue is an authorization bypass (CWE-863): authorization boundaries are not adequately enforced when a generate rule resolves templated resource kinds and namespaces. A controller with broader privileges may act on tenant-influenced values without sufficiently constraining the target resource or namespace to the tenant's permitted scope.
Potential impact
- A tenant may cause resources to be created in another namespace, potentially including
kube-system - Unauthorized NetworkPolicies could alter network access between workloads
- Unauthorized RoleBindings could grant users or service accounts additional permissions
- The controller's broad privileges could enable further cross-namespace impact
General mitigation guidance
Defensive approaches focus on preserving authorization boundaries between tenant-controlled policy inputs and privileged controller actions.
- Constrain or avoid templating resource kinds and target namespaces in tenant-controlled generate rules
- Validate resolved values against explicit, namespace-scoped allowlists before creating resources
- Apply secure-by-default policy rules that deny cross-namespace targets unless explicitly authorized
- Reduce the background controller's permissions to the minimum resources and namespaces it needs
- Treat tenant-supplied policies and trigger resources as untrusted input
How teams detect issues like this
- Review policies and templates for tenant-controlled values used as generated resource kinds or namespaces
- Use static analysis or policy checks to flag generate rules that can target namespaces beyond the policy's scope
- Audit controller permissions for broad create or bind capabilities across namespaces
- Monitor audit logs for controller-created resources in unexpected namespaces, especially sensitive namespaces
- Enforce admission policies that restrict generated resource kinds, namespaces, and RoleBindings

