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/restore-host.sh

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

INSTALL_ROOT="${HOST_INSTALL_ROOT:-}"
LAB_DIR="${INSTALL_ROOT}/opt/cve-2024-21626-lab"
TARGET="${LAB_DIR}/host-demo"
CLEAN_COPY="${LAB_DIR}/host-demo.clean"
INSTALL_OWNER_ARGS=()

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

(($# == 0)) || die 'Usage: sudo ./host/restore-host.sh'

if [[ -n "${INSTALL_ROOT}" ]]; then
    [[ "${INSTALL_ROOT}" == /* && "${INSTALL_ROOT}" != '/' &&
       -d "${INSTALL_ROOT}" && ! -L "${INSTALL_ROOT}" ]] ||
        die 'HOST_INSTALL_ROOT must be an absolute, non-linked staging directory.'
else
    ((EUID == 0)) || die 'Run this script with sudo on the Ubuntu host.'
    INSTALL_OWNER_ARGS=(-o root -g root)
fi
[[ -f "${CLEAN_COPY}" ]] || die "Missing clean backup: ${CLEAN_COPY}"
grep -aq 'CVE21626_HOST_DEMO' "${CLEAN_COPY}" ||
    die 'Clean backup does not contain the sacrificial executable marker.'

RESTORE_TMP="${LAB_DIR}/host-demo.restore.$$"
cleanup() {
    rm -f -- "${RESTORE_TMP}" 2>/dev/null || true
}
trap cleanup EXIT

install "${INSTALL_OWNER_ARGS[@]}" -m 0755 "${CLEAN_COPY}" "${RESTORE_TMP}"
mv -f -- "${RESTORE_TMP}" "${TARGET}"
cmp -s "${TARGET}" "${CLEAN_COPY}" || die 'Restored target does not match the clean backup.'

printf '[+] Restored %s from the clean lab copy.\n' "${TARGET}"
sha256sum "${TARGET}" "${CLEAN_COPY}"
printf '[!] A later Attack 3b attempt must repeat attacker-side FD discovery because restoration changes the target inode.\n'