Skip to content
RCE Write-up Intermediate

CVE-2021-25746: Ingress-nginx directive injection via annotations

An attacker with permission to create or modify ingresses in one namespace can inject arbitrary nginx configuration via the connection-proxy-header annotation, leading to file read on the ingress controller pod. This allows reading the service account token, which has permission to read secrets in all namespaces.

amlw.dev

Published on amlw.dev

Reference: https://github.com/kubernetes/ingress-nginx/issues/8503

The author, on amlw.dev

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 connection-proxy-header annotation value is inserted into the nginx configuration without proper quoting or validation, allowing an attacker to break out and inject arbitrary configuration directives.

Impact

An attacker could read arbitrary files from the ingress controller pod, including the service account token, which has permission to read secrets in all namespaces.

What the attacker needed

Permission to create/modify ingresses in one namespace; ingress-nginx deployed

How it was found

  1. Create a Kubernetes cluster (e.g., using minikube).
  2. Deploy ingress-nginx controller.
  3. Deploy a malicious Ingress resource with a crafted connection-proxy-header annotation.
  4. Look up the IP address of the ingress controller service.
  5. Send a GET request to the malicious host to read arbitrary files from the nginx pod.

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.

This is a vulnerability in a Kubernetes component that manages web traffic. Someone who can create certain configuration objects can sneak in extra instructions that let them read files on the server, including a credential that unlocks many secrets.

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.