Skip to content
RCE Write-up Advanced

Exploiting Kubernetes through Operator Injection

A GraphQL API stored user input as a Kubernetes custom resource without validation, and a custom controller used that data to build a YAML deployment file. An attacker could inject YAML directives to deploy arbitrary Kubernetes resources, confirmed by an out-of-band DNS callback.

Zach Grace Follow

Published on praetorian.com

The Kubernetes documentation describes operators as “software extensions to Kubernetes that use custom resources to manage applications and their components.” These operators automate application resource deployment and management with custom controllers tied to one or more custom resource definitions. Custom…

Justin Copeland, on praetorian.com

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 application failed to validate or sanitise user-supplied input before storing it as a custom resource, and the controller then used that unvalidated data to construct a YAML document, allowing YAML document-start markers to break out of the intended context.

Impact

The vulnerability could allow an attacker to deploy arbitrary Kubernetes resources on the underlying cluster, affecting confidentiality, integrity, and availability; the blast radius depends on the controller's privileges, and in the observed case it was limited to a specific namespace but included broad namespace privileges and some cluster-level access.

What the attacker needed

Access to the GraphQL API; ability to submit a mutation with a vulnerable field; controller with permissions to deploy resources

The fix

All user-supplied input should be validated before being stored as a custom resource and before being processed by downstream controllers.

How it was found

  1. Craft a Kubernetes Deployment resource that runs a command to perform an out-of-band DNS lookup.
  2. Replace newlines with the literal characters 'n' and wrap the payload with YAML document start and end markers.
  3. Append the crafted payload to the vulnerable field in the GraphQL mutation.
  4. Call the mutation; the controller processes the stored data and executes the payload, confirmed by the DNS callback.

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.

Kubernetes operators are programs that watch for custom data and automatically create or change resources. Here, a web API saved user input as such custom data, and a controller later turned that input into a YAML file without checking it. By sneaking in special YAML markers, an attacker could make the controller deploy their own resources, like a pod that sends a network request back to them.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.