GHSA-f9g8-6ppc-pqq4 Kyverno: ServiceAccount token leaked to external servers via apiCall service URL
SummaryKyverno's apiCall feature in ClusterPolicy automatically attaches the admission controller's ServiceAccount token to outgoing HTTP requests. The service URL has no validation — it can point anywhere, including attacker-controlled servers. Since the admission controller SA has permissions to patch webhook configurations, a stolen token leads to full cluster compromise.Affected versionTested on Kyverno v1.17.1 (Helm chart default installation). Likely affects all versions with apiCall service support.DetailsThere are two issues that combine into one attack chain.The first is in `pkg/engine/apicall/executor.go` around line 138. The service URL from the policy spec goes straight into `http.NewRequestWithContext()`:No scheme check, no IP restriction, no allowlist. The policy validation webhook (`pkg/validation/policy/validate.go`) only looks at JMESPath syntax.The second is at lines 155-159 of the same file. If the request doesn't already have an Authorization header, Kyverno reads its own SA token and injects it:The token is the admission controller's long-lived SA token from `/var/run/secrets/kubernetes.io/serviceaccount/token`. With the default Helm install, this SA (`kyverno-admission-controller`) can read and PATCH both `MutatingWebhookConfiguration` and `ValidatingWebhookConfiguration`.Reproduction**Environment**: Kyverno v1.17.1, K3s v1.34.5, single-node cluster, default Helm install**Step 1**: Start an HTTP listener on an attacker machine:**Step 2**: Create a ClusterPolicy that calls the attacker server:**Step 3**: Create any pod to trigger policy evaluation:**Step 4**: The listener receives the SA token immediately:Decoded JWT `sub` claim: `system:serviceaccount:kyverno:kyverno-admission-controller`Every subsequent pod creation sends the token again. No race condition, no timing — it fires every time.**Step 5**: Use the token to hijack webhooks:After this, every K8s API request that triggers the webhook goes to the attacker's server. The attacker can mutate any pod spec — inject containers, mount host paths, add privileged security contexts.Verified permissions of stolen tokenTested with the default Helm installation:| Action | Result |
|--------|--------|
| List pods (all namespaces) | Allowed |
| Read configmaps in kube-system | Allowed |
| PATCH MutatingWebhookConfiguration | **Allowed** |
| PATCH ValidatingWebhookConfiguration | **Allowed** |
| Read secrets (cluster-wide) | Denied (per-NS only) |ImpactAn attacker who can create ClusterPolicy resources (or who compromises a service account with that permission) can steal Kyverno's admission controller token and use it to:Hijack Kyverno's own mutating/validating webhooksIntercept and modify every API request flowing through the clusterInject malicious containers, escalate privileges, exfiltrate secretsThe token is also sent to internal endpoints — `http://169.254.169.254/latest/meta-data/` works, so on cloud-hosted clusters (EKS, GKE, AKS) this also leaks cloud IAM credentials.RBAC note: ClusterPolicy is a cluster-scoped resource, so creating one requires cluster-level RBAC. But in practice, platform teams often grant policy-write to team leads or automation pipelines. The auto-injection of the SA token is the unexpected part — nobody expects writing a policy to leak the controller's credentials.
CVSS v3.1 score: 8.1