Kyverno SSRF & Service Account Token Leak
Kyverno's external API call feature sent the admission controller's Kubernetes service account token in the Authorization header to any configured endpoint, and also allowed requests to internal services and cloud metadata. An attacker could use this to exfiltrate data or authenticate against the Kubernetes API server.
tomcope.com
Published on tomcope.com
Kyverno is a Kubernetes native policy engine for validating and securing Kubernetes resources. It acts as an admission controller which can be configured to enforce specific policies e.g. “do not allow containers to run as root”, or “allow a maximum of 1G of RAM for containers”.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code that performs external API calls automatically added the service account token to the Authorization header without checking whether the caller had already set one, and the feature lacked restrictions on which URLs could be called.
Impact
An attacker could exfiltrate data to an external server, make requests to internal services or cloud metadata, and use the leaked service account token to authenticate against the Kubernetes API server and maintain control over policies and exceptions.
What the attacker needed
Ability to create or modify Kyverno policies; Kyverno with external API call feature enabled
The fix
The issue was fixed by adding blocklist/allowlist controls for HTTP calls and disabling CEL http.Get/http.Post in namespaced policies by default.
How it was found
- Create a local testing kind cluster.
- Install Kyverno using Helm.
- Apply a policy that uses the API Call feature to send a request to an external server.
- Start a listener server to receive the request.
- Apply a pod creation request that triggers the policy.
- Observe that the received HTTP request contains a valid JWT for the Kyverno service account in the Authorization header.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Kyverno is a tool that checks Kubernetes resources against policies. Its external API call feature lets a policy send data to an outside web address, but it also automatically attached a secret login token for the Kyverno service account. That meant anyone who could create a policy could send that token to a server they control and then use it to access the Kubernetes cluster.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.