Exploit databaseDownload repository ZIP
GH-7368a356851e2ea333b5afdf643e3371
ishankaru/cve-2026-23111-nftables-lab
Sources for CVE-2026-23111
7 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files5
ishankaru/cve-2026-23111-nftables-labRevision f50424c073a7
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
check-exposure.sh
Shell · 9,060 bytes#!/usr/bin/env bash
#
# CVE-2026-23111 exposure checker (defensive).
#
# Read-only. Reports whether this host is exposed to the nf_tables
# use-after-free local privilege escalation: kernel version vs the distro
# fixed build, nf_tables presence (attack surface), and whether unprivileged
# user namespaces (the exploit precondition) are open or restricted. Also
# scans the kernel ring buffer for crash signatures that can accompany a
# failed exploitation attempt.
#
# This does NOT exploit anything. Lab and incident-response use only.
set -u
GREEN=$'\033[32m'; RED=$'\033[31m'; YEL=$'\033[33m'; BOLD=$'\033[1m'; OFF=$'\033[0m'
say() { printf '%s\n' "$*"; }
ok() { printf '%s[ ok ]%s %s\n' "$GREEN" "$OFF" "$*"; }
bad() { printf '%s[risk]%s %s\n' "$RED" "$OFF" "$*"; }
warn() { printf '%s[warn]%s %s\n' "$YEL" "$OFF" "$*"; }
info() { printf ' %s\n' "$*"; }
# --- version compare: returns 0 if $1 < $2 (dpkg if available, else sort -V) ---
ver_lt() {
if command -v dpkg >/dev/null 2>&1; then
dpkg --compare-versions "$1" lt "$2"
else
[ "$1" != "$2" ] && [ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -1)" = "$1" ]
fi
}
KREL="$(uname -r)"
say "${BOLD}CVE-2026-23111 exposure check${OFF}"
say "kernel: $KREL"
say ""
# --- 1. distro + fixed-version comparison (best effort) -----------------------
DISTRO="unknown"; VID=""
if [ -r /etc/os-release ]; then . /etc/os-release; DISTRO="${ID:-unknown}"; VID="${VERSION_ID:-}"; fi
say "${BOLD}1. Kernel version vs fixed build${OFF}"
# Known fixed builds verified at publication. Vendors ship many flavors; when in
# doubt, the vendor tracker is authoritative, not this table.
KNUM="${KREL%%-*}" # e.g. 6.8.0
KBUILD="$(printf '%s' "$KREL" | sed -E 's/^[0-9.]+-([0-9]+).*/\1/')" # e.g. 79
verdict_version="unknown"
case "$DISTRO" in
ubuntu)
# 24.04 fixed builds per flavor: generic 6.8.0-107, aws 6.8.0-1051.
FIXED=""; FLAV=""
case "$KREL" in
6.8.0-*-generic) FIXED=107; FLAV="generic" ;;
6.8.0-*-aws) FIXED=1051; FLAV="aws" ;;
esac
if [ -n "$FIXED" ]; then
if [ "${KBUILD:-0}" -lt "$FIXED" ] 2>/dev/null; then
bad "Ubuntu $FLAV build ${KBUILD} is below the fixed 6.8.0-${FIXED}. VULNERABLE kernel."
verdict_version="vuln"
else
ok "Ubuntu $FLAV build ${KBUILD} is at or past 6.8.0-${FIXED} (fixed)."
verdict_version="fixed"
fi
else
warn "Ubuntu flavor not in this script's table. Check ubuntu.com/security/CVE-2026-23111 for your exact flavor."
fi ;;
debian)
# Fix lands by source-package version, not the ABI number in uname, so ask dpkg.
PKGVER=$(dpkg-query -W -f='${Version}' "linux-image-$KREL" 2>/dev/null)
case "${VERSION_CODENAME:-}" in
bookworm) FIXEDV="6.1.164-1" ;; # DSA-6163-1
trixie) FIXEDV="6.12.73-1" ;; # DSA-6141-1
*) FIXEDV="" ;;
esac
if [ -n "$PKGVER" ] && [ -n "$FIXEDV" ]; then
if dpkg --compare-versions "$PKGVER" lt "$FIXEDV"; then
bad "Debian ${VERSION_CODENAME} kernel $PKGVER is below the fixed $FIXEDV. VULNERABLE kernel."
verdict_version="vuln"
else
ok "Debian ${VERSION_CODENAME} kernel $PKGVER is at or past $FIXEDV (fixed)."
verdict_version="fixed"
fi
else
warn "Could not map this Debian kernel to a fixed version. Check security-tracker.debian.org/tracker/CVE-2026-23111."
fi ;;
rhel|centos|rocky|almalinux)
# Red Hat fixed builds vary per minor stream (el10_0/el10_1/el10_2 each have their
# own NVR series), so a single numeric compare across streams is unreliable. We only
# assert what is lab-confirmed and otherwise point at the RHSA.
RHBUILD=$(printf '%s' "$KREL" | sed -E 's/^[0-9.]+-([0-9.]+)\.el[0-9].*/\1/')
case "$KREL" in
*el10_1*)
bad "RHEL/Alma el10_1 kernel ($RHBUILD): the 6.12.0-124.x el10_1 series is vulnerable (lab-confirmed on 124.38.1). The fix ships in the 10.2 (211.x) stream. VULNERABLE."
verdict_version="vuln" ;;
*)
warn "RHEL-family build $RHBUILD: fixed builds vary per minor stream, confirm against access.redhat.com/security/cve/cve-2026-23111 (RHSA for your release)." ;;
esac ;;
fedora|amzn|sles|opensuse*|arch)
warn "Distro '$DISTRO': fixed-version table not encoded here. Compare $KREL against your vendor tracker for CVE-2026-23111."
;;
*)
warn "Unknown distro. Compare $KREL against your vendor's CVE-2026-23111 advisory."
;;
esac
say ""
# --- 2. nf_tables attack surface ---------------------------------------------
say "${BOLD}2. nf_tables attack surface${OFF}"
if ! command -v modinfo >/dev/null 2>&1; then
warn "modinfo not available here, cannot confirm nf_tables presence. On a normal distro it is present."
elif modinfo nf_tables >/dev/null 2>&1; then
info "nf_tables is present (loadable module). This is the attack surface, not proof of exploitability."
elif grep -qiE 'nf_tables' /lib/modules/"$KREL"/modules.builtin 2>/dev/null; then
info "nf_tables appears built into the kernel image. Attack surface present."
else
warn "nf_tables not found via modinfo or modules.builtin. Unusual on a stock distro, verify manually."
fi
say ""
# --- 3. unprivileged user namespaces: the exploit precondition ----------------
say "${BOLD}3. Unprivileged user namespaces (the precondition)${OFF}"
APP_RESTRICT="$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || echo NA)"
USERNS_CLONE="$(cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null || echo NA)"
MAXNS="$(cat /proc/sys/user/max_user_namespaces 2>/dev/null || echo NA)"
info "apparmor_restrict_unprivileged_userns = $APP_RESTRICT (1 = restricted, Ubuntu 23.10+)"
info "unprivileged_userns_clone = $USERNS_CLONE (0 = disabled, Debian/Ubuntu)"
info "user.max_user_namespaces = $MAXNS (0 = disabled)"
# The precondition must be tested as an UNPRIVILEGED user. If this script runs
# as root (e.g. under sudo), running unshare directly would always succeed and
# give a false "open", so drop to 'nobody' for the test.
test_userns() {
if [ "$(id -u)" -eq 0 ]; then
if command -v runuser >/dev/null 2>&1; then runuser -u nobody -- unshare -Ur id 2>&1
else sudo -u nobody unshare -Ur id 2>&1; fi
else
unshare -Ur id 2>&1
fi
}
precond="unknown"
if command -v unshare >/dev/null 2>&1; then
out="$(test_userns)"
if printf '%s' "$out" | grep -q 'uid=0'; then
bad "An unprivileged user CAN create a user namespace. Exploit precondition is OPEN."
precond="open"
elif printf '%s' "$out" | grep -qiE 'operation not permitted|permission denied|disabled'; then
# Only a genuine permission denial (the userns restriction) counts as closed.
ok "Unprivileged user namespace creation is blocked (tested as an unprivileged user). Precondition CLOSED."
info "(blocked: $(printf '%s' "$out" | head -1))"
precond="closed"
else
# unshare failed for some other reason (missing sudo/runuser, resource limit,
# etc.): do not claim mitigation. Verify manually as an unprivileged user.
warn "Could not determine the userns precondition; unshare did not run cleanly (not a clear permission denial)."
info "($(printf '%s' "$out" | head -1))"
precond="unknown"
fi
else
warn "unshare not available; relying on the sysctl values above."
[ "$MAXNS" = "0" ] && precond="closed"
[ "$USERNS_CLONE" = "0" ] && precond="closed"
[ "$APP_RESTRICT" = "1" ] && precond="closed"
fi
say ""
# --- 4. crash signatures from a possible exploitation attempt ------------------
say "${BOLD}4. Kernel log signatures (best-effort)${OFF}"
SIG='nf_tables|netfilter|KASAN|use-after-free|BUG: unable|general protection|slab-use-after-free'
hits="$( (dmesg -T 2>/dev/null; journalctl -k --since '14 days ago' 2>/dev/null) | grep -iE "$SIG" | tail -20)"
if [ -n "$hits" ]; then
warn "Found nf_tables / memory-corruption signatures in the kernel log (review, may be benign):"
printf '%s\n' "$hits" | sed 's/^/ /'
else
ok "No obvious nf_tables / UAF crash signatures in the recent kernel log."
fi
say ""
# --- verdict ------------------------------------------------------------------
say "${BOLD}Verdict${OFF}"
if [ "$verdict_version" = "vuln" ] && [ "$precond" = "open" ]; then
bad "EXPOSED: vulnerable kernel AND an open user-namespace path. Patch and restrict userns now."
elif [ "$verdict_version" = "vuln" ] && [ "$precond" = "closed" ]; then
warn "MITIGATED, NOT FIXED: kernel is vulnerable but the userns path is closed. Still patch the kernel."
elif [ "$verdict_version" = "vuln" ]; then
bad "VULNERABLE kernel; the userns precondition could not be confirmed here. Treat as exposed until you verify it as an unprivileged user, then patch and restrict userns."
elif [ "$verdict_version" = "fixed" ]; then
ok "Kernel is at or past the fixed build for this flavor. Keep userns restricted as defense in depth."
else
warn "UNDETERMINED: confirm $KREL against your vendor's CVE-2026-23111 advisory."
fi
exit 0