Kernel exploits are the privilege escalation of last resort: powerful, unreliable, and capable of crashing the target. This skill covers the disciplined approach on authorized engagements: identifying the exact kernel build, matching public CVEs honestly, sourcing exploits safely, and testing in a way that respects production systems. The default answer on production is to report the vulnerable kernel as a finding, not to run the exploit.
Quick Workflow
- Identify the exact kernel version and distribution build.
- Check the distribution's patch status: the version string alone lies (backported patches keep old numbers).
- Match CVEs to the exact build and configuration.
- Get explicit approval before running any kernel exploit on a non-lab system.
- Prefer a lab reproduction of the target kernel first.
- If approved, run the most stable exploit available, once, with monitoring.
- Report the vulnerable kernel regardless of whether you exploited it.
1. Identification beyond uname
# Version string is the start, not the answer
uname -a
cat /etc/os-release | head -5
# Distribution build info: backported patches live here
cat /proc/version
# Ubuntu/Debian: check the changelog for CVE fixes
dpkg -l | grep -E 'linux-image' | head -5
# RHEL: the release number carries the patch level
rpm -q kernel 2>/dev/null
# Configuration that decides exploitability
cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null
cat /proc/sys/kernel/kptr_restrict 2>/dev/null
ls /boot/config-$(uname -r) 2>/dev/null && grep -E 'USER_NS|KALLSYMS' /boot/config-$(uname -r)
A Ubuntu 20.04 box reporting kernel 5.4.0 may have every 2023 CVE
backported. Exploit-db entries matched on uname alone are how testers
waste days and crash hosts.
2. CVE matching with honesty
# List candidate CVEs for the kernel series, then verify each
# against the distro changelog before touching an exploit
# Example workflow for a 5.15 kernel:
# - CVE-2022-32250 (nftables): needs nftables, check lsmod
# - CVE-2023-2640 / CVE-2023-32629 (overlayfs): needs specific config
lsmod | grep -E 'nft|overlay'
id # unprivileged user namespace needed for several LPEs
# Search local exploit archives, never download blindly to the target
searchsploit linux kernel 5.15 privilege escalation 2>/dev/null | head -10
Read the exploit's requirements section before its usage section. Most kernel LPEs need a specific subsystem, namespace rights, or config flag; if the target lacks it, the exploit cannot work and running it only risks a crash.
3. Safe testing discipline
# Compile on your own machine or the engagement build box, not the target
gcc -o /tmp/exploit exploit.c -static 2>&1 | head -5
# Snapshot or backup before running on anything that matters
# On a VM target: snapshot. On bare metal: do not run without
# written approval stating the crash risk is accepted.
# Run once, with a timeout, watching from a second session
timeout 60 /tmp/exploit; echo "exit: $?"
id
One run, one observation. If it fails, read why (missing requirement, wrong offsets) instead of hammering variants; each failed kernel exploit is a dice roll on system stability.
Edge cases
- The exploit needs unprivileged user namespaces and they are disabled. That is a hardening win; note it and move on instead of fighting the configuration.
- The target is a container. Kernel exploits in a container attack the host kernel; the blast radius is the whole host, so the approval bar is higher and the default answer is to report, not run.
- No compiler on the target. Cross-compile for the target arch on your build box; never install a toolchain on the target.
- The CVE is real but the exploit is unreliable. Report the vulnerable kernel with the CVE list; an unexploited CVE is still a finding.
Escalation
- Approval granted and the exploit works: capture
idoutput, use the access for the engagement's objectives, and be ready to help restore if anything degrades. - Approval denied: the kernel finding stands on the CVE match and the missing patches; write it up with remediation (patch window, reboot plan).
- You need the exploit for a lab demo: reproduce the exact kernel in a local VM and run it there; lab proof transfers to the report safely.
Detection and defender view
Defenders see kernel exploitation as crashes, oops messages in dmesg, and sudden root processes with odd parents. EDR may catch the exploit technique (namespace games, unusual syscalls). The durable defense is patching on a schedule with reboots, live-patching where reboots are hard, disabling unneeded subsystems and unprivileged namespaces, and monitoring for kernel oops as a detection signal.
Key references
- MITRE ATT&CK T1068 (Exploitation for Privilege Escalation).
- CWE-269 (Improper Privilege Management).
- Distribution security trackers: Ubuntu CVE tracker, RHEL CVE database.
- Linux kernel stable release changelogs.
