Skip to content
RCE Write-up Advanced

Kubernetes CVE-2024–10220 Attack and Defense

A Kubernetes vulnerability in the gitRepo volume allows an attacker to craft a malicious Git repository that tricks the git CLI into treating it as a bare repository, causing a post-checkout hook to execute arbitrary code as root on the Kubernetes node. This enables privilege escalation and container escape from a pod with gitRepo volume permissions.

medium.com

Published on medium.com

On November 22, 2024, a new Kubernetes vulnerability involving the gitRepo volume was disclosed. This vulnerability enables arbitrary code execution and privilege escalation, allowing container escape to the Kubernetes node.

Filip Žagar, on medium.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

The gitRepo volume driver runs git checkout inside a directory that can be made to look like a bare repository, causing git to execute a post-checkout hook from the attacker-controlled repository as root on the node.

Impact

An attacker with permissions to create pods can execute arbitrary code as root on the Kubernetes node, leading to full node compromise and potential cluster takeover.

What the attacker needed

Permissions to create pods with gitRepo volumes; Attacker controls the Git repository

How it was found

  1. Create a Git repository with a post-checkout hook containing malicious code.
  2. Structure the repository to appear as a bare repository by copying .git/HEAD, .git/config, .git/refs, and .git/objects to the root.
  3. Push the repository to a remote location.
  4. Configure a Kubernetes pod with a gitRepo volume pointing to the malicious repository and specifying a directory like some_dir/.git.
  5. When the pod is created, the kubelet clones the repository and runs git checkout, triggering the post-checkout hook as root on the node.

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 can mount a Git repository into a container using a feature called gitRepo. If an attacker controls that repository, they can include a special script that runs automatically when the repository is checked out. Because this script runs on the underlying server (the node) as the root user, the attacker can take full control of that server.

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.