Summary
Kyverno's apiCall feature in ClusterPolicy automatically attached the admission controller's ServiceAccount token to outbound HTTP requests without validating the destination URL.
If a policy is configured to call an attacker-controlled endpoint, that endpoint can receive and reuse the token, potentially gaining permissions to patch webhook configurations and compromise the entire cluster.
Affected context
This vulnerability appears in Kyverno deployments that use ClusterPolicies with the apiCall feature enabled.
The issue manifests when:
- The policy's apiCall is configured with arbitrary URLs, including non-cluster endpoints.
- Outbound HTTP requests automatically carry the admission controller ServiceAccount token.
- Network controls allow egress from the admission controller pod to external or attacker-controlled services.
In such contexts, any misconfigured or malicious policy that references an untrusted URL exposes the attached token to that remote endpoint.
Exploit preconditions
- Attack surface: Kyverno admission controller's apiCall-based HTTP requests triggered during Kubernetes admission.
- Required access: Ability to create, modify, or influence ClusterPolicies (or associated configurations) that define apiCall URLs; or ability to cause Kyverno to load malicious policy bundles.
- Trigger point: Evaluation of a policy using apiCall that points to a URL under attacker control, causing Kyverno to send a request with its ServiceAccount token.
- Why exploitation is possible: The apiCall mechanism:
- Automatically attaches the admission controller ServiceAccount token to outbound requests.
- Does not validate or restrict the destination URL to trusted cluster-local services.
- Relies on this token for authentication, thereby exposing it directly to any endpoint the apiCall references.
Why this happens
The underlying issue combines two insecure patterns:
- Unvalidated outbound requests (CWE-918: Server-Side Request Forgery): Kyverno's apiCall feature allows arbitrary URLs to be configured, treating them as trusted destinations without enforcing scoping to known, internal services.
- Sensitive information exposure in transit (CWE-200: Exposure of Sensitive Information): The admission controller ServiceAccount token, a high-privilege credential, is automatically attached to all apiCall requests, regardless of the target's trust level.
Conceptually, this represents a flawed trust boundary where infrastructure control-plane credentials are reused for user-defined or policy-defined HTTP calls. By conflating policy-driven external integration with core control-plane authentication, the design allows untrusted destinations to receive privileged tokens, breaking the assumption that such tokens only traverse secure, internal paths.
Potential impact
- An attacker-controlled endpoint may capture the admission controller ServiceAccount token.
- Attackers could use the stolen token to call the Kubernetes API with the admission controller's permissions.
- The token may allow patching or reconfiguring mutating/validating webhooks, including Kyverno's own webhook configuration.
- Attackers might disable or alter cluster-wide security policies and admission controls.
- The cluster control plane could be effectively fully compromised, enabling workload modification, privilege escalation, or policy bypass.
General mitigation guidance
Effective mitigation focuses on both limiting where outbound requests can go and preventing automatic credential propagation:
- Constrain outbound destinations: Design policies so that apiCall endpoints are limited to well-defined, internal services. Consider patterns where URLs are selected from a fixed, policy-governed allowlist rather than arbitrary user input.
- Decouple credentials from untrusted calls: Avoid attaching high-privilege ServiceAccount tokens to requests that are influenced by policy data or user configuration. Instead, use scoped credentials specifically provisioned for external calls, following least privilege.
- Harden trust boundaries: Treat any configuration that controls network destinations as untrusted input. Apply validation, including hostname and scheme checks, and restrict connectivity via network policies or service meshes to prevent egress to unknown endpoints.
- Reduce token power: Ensure tokens used by admission components have only the permissions strictly required for their function. Prefer fine-grained roles and separate identities for configuration management and admission logic.
- Adopt secure defaults: Configure policy engines and admission controllers so that external integrations are disabled or heavily restricted by default, requiring explicit, security-reviewed configuration for outbound HTTP features.
How teams detect issues like this
Detection efforts can center on both configuration analysis and runtime observation:
- Policy and configuration review: Examine ClusterPolicies for apiCall blocks that reference non-cluster-local, IP-based, or otherwise unvetted URLs. Code review checklists can flag policies that call arbitrary domains or services outside a defined trust boundary.
- Static analysis and policy linting: Use static analysis or custom linters to detect:
- apiCall usage with dynamically constructed URLs.
- Policies that lack clear scoping or validation rules for endpoints.
- Patterns where tokens or headers are implicitly propagated to external URLs.
- Admission controller and RBAC audits: Inspect ServiceAccount roles for over-privileged permissions, especially the ability to patch ValidatingWebhookConfiguration and MutatingWebhookConfiguration objects. Automated RBAC analysis tools can highlight roles that can reconfigure webhooks.
- Network and log monitoring: Monitor outbound HTTP traffic from the admission controller pods. Network policies, service mesh telemetry, and HTTP logs can surface unexpected calls to external or untrusted domains. Alerting on anomalous destinations or unusual API invocation patterns helps detect misuse.
- Security policy enforcement: Implement organization-wide policies (e.g., via policy-as-code tools) that prohibit or require justification for apiCall endpoints outside a predefined set of internal services.

