Exploit database

GH-49753b08fbcec64093787273ddec5dd7

rnw29/cve-2024-21626-runc-lab

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-21626

15 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files13
rnw29/cve-2024-21626-runc-labRevision d33f0f7f8fe9

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

host/prepare-host.sh

Shell · 1,941 bytes
#!/usr/bin/env bash
set -Eeuo pipefail

LAB_DIR='/opt/cve-2024-21626-lab'
TARGET="${LAB_DIR}/host-demo"
CLEAN_COPY="${LAB_DIR}/host-demo.clean"
CANARY="${LAB_DIR}/attack2-host-canary.txt"
RESET=0

usage() {
    printf 'Usage: sudo %s [--reset]\n' "$0"
}

die() {
    printf '[-] %s\n' "$*" >&2
    exit 1
}

while (($#)); do
    case "$1" in
        --reset) RESET=1 ;;
        -h|--help) usage; exit 0 ;;
        *) usage >&2; die "Unknown argument: $1" ;;
    esac
    shift
done

((EUID == 0)) || die 'Run this script with sudo on the Ubuntu host.'
command -v gcc >/dev/null 2>&1 || die 'Install gcc and libc6-dev on the Ubuntu host first.'
command -v file >/dev/null 2>&1 || die 'Install file on the Ubuntu host first.'
command -v sha256sum >/dev/null 2>&1 || die 'sha256sum is required.'

SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$(mktemp -d)"
trap 'rm -rf -- "${BUILD_DIR}"' EXIT

if [[ -e "${TARGET}" && ${RESET} -ne 1 ]]; then
    die "${TARGET} already exists. Use --reset only after taking a VM snapshot and confirming this is the disposable lab path."
fi

printf '[*] Compiling the sacrificial executable statically...\n'
gcc -std=c11 -O2 -Wall -Wextra -Werror -static \
    -o "${BUILD_DIR}/host-demo" "${SCRIPT_DIR}/host-demo.c"
file "${BUILD_DIR}/host-demo" | grep -q 'statically linked' ||
    die 'Static compilation failed; install the host libc development files.'

install -d -o root -g root -m 0755 "${LAB_DIR}"
install -o root -g root -m 0755 "${BUILD_DIR}/host-demo" "${TARGET}"
install -o root -g root -m 0755 "${BUILD_DIR}/host-demo" "${CLEAN_COPY}"

printf 'ATTACK2_HOST_CANARY: host=%s created=%s\n' "$(hostname)" "$(date -Is)" >"${CANARY}"
chown root:root "${CANARY}"
chmod 0400 "${CANARY}"


printf '\n[+] Host lab assets prepared.\n'
ls -l "${CANARY}" "${TARGET}" "${CLEAN_COPY}"
sha256sum "${TARGET}" "${CLEAN_COPY}"
printf '[+] The two executable hashes above must match.\n'