Skip to content
Pwnversity
LIN-KERNELexpert · 5 min · upd. 2026-10

Linux Kernel Exploits

T1068

When escalation via misconfigurations (sudo, SUID, cron, capabilities) bears no fruit, what remains is exploiting a vulnerability in the Linux kernel itself. A successful kernel exploit gives root directly, regardless of permissions and configurations. But it’s the last resort: many exploits are unstable, can cause a kernel panic and take down the host, and are very noisy. First exhaust the configuration paths (see Privilege Escalation).

The kernel is the ultimate trust boundary: it runs in ring 0 and mediates everything. A memory bug (use-after-free, overflow, race condition) in code reachable from an unprivileged user allows corrupting kernel structures and, ultimately, executing with root credentials (typically by calling commit_creds(prepare_kernel_cred(0))). The attacker gains absolute root, but accepts the risk of destabilizing the system.

  • Crash risk: a badly ported exploit can cause a kernel panic and bring down the server; in a real pentest against production, this is serious.
  • Noise: they tend to be EDR-detectable and leave traces (dmesg oops, loaded modules).
  • Variable reliability: they depend on the exact version, architecture, and mitigations (KASLR, SMEP/SMAP, KPTI). The same CVE can be trivial on one build and non-exploitable on another.

So: enumerate and try everything else first; the kernel only when there’s no other way.

Ventana de terminal
uname -a # exact version and architecture
cat /etc/os-release # distro (affects which patches are backported)
cat /proc/version
# version-based exploit suggesters
./linux-exploit-suggester.sh # (LES) maps CVEs/exploits to the kernel
searchsploit linux kernel 5.8 # cross-reference manually

Careful: the distro may have backported the patch without changing the version number. LES helps, but verify the package changelog (dpkg -l linux-image*, rpm -q kernel).

  • Dirty COW — CVE-2016-5195: copy-on-write race condition → write to read-only mapped files → root.
  • Dirty Pipe — CVE-2022-0847: pipe/page-cache flaw allowing overwrite of read-only files (e.g. /etc/passwd) → root. Usually stable.
  • nf_tables — CVE-2024-1086: use-after-free in netfilter nf_tables → local LPE.
  • OverlayFS: CVE-2021-3493 (Ubuntu), CVE-2023-0386 → LPE via setuid copy-up.
  • GameOver(lay): CVE-2023-2640 and CVE-2023-32629 in Ubuntu’s OverlayFS → root.
  • Sequoia — CVE-2021-33909: size_t underflow in the VFS seq_file → root.
  • PwnKit — CVE-2021-4034: actually pkexec (SUID), not kernel, but “universal root”; see SUID.

If you don’t know a CVE for certain, describe the class (UAF in a subsystem, COW race…) and don’t invent identifiers.

  1. uname -a → exact version and architecture.
  2. LES / searchsploit → candidates.
  3. Verify applicability (version, arch, active mitigations).
  4. Prefer known, well-tested exploits (Dirty Pipe is usually stable).
  5. Compile on the target (needs gcc) or port a compatible binary (mind glibc/arch).
  6. Test in a lab/snapshot first; never debut on production.
  7. Run, confirm root (id), and stabilize the shell.
Ventana de terminal
gcc exploit.c -o exploit && ./exploit # if gcc is on the target
id # uid=0(root) -> success
  • dmesg/journalctl -k: kernel oops, warnings, and stack traces right before an escalation are a strong IOC.
  • auditd: unexpected module loads (init_module/finit_module), execution of freshly compiled binaries in /tmp, gcc followed by an EUID 0 process.
  • EDR/eBPF that detects exploitation patterns (credential manipulation, commit_creds).
  • Keep the kernel patched (unattended-upgrades; livepatch/kpatch to avoid reboots): the #1 defense.
  • Active mitigations: KASLR, SMEP/SMAP, KPTI; kernel.unprivileged_userns_clone=0, kernel.kptr_restrict=2, kernel.dmesg_restrict=1.
  • Reduce surface: disable unnecessary modules and functionality; seccomp; AppArmor/SELinux.
  • Hardened kernels (grsecurity, lockdown) in critical environments; see hardening and patch management.

If kernel exploitation is confirmed: isolate, capture memory/artifacts (Linux DFIR), and rebuild the host (a compromised kernel isn’t trustworthy); prioritize patching across the whole fleet on the same version.

  • uname -a + distro → exact version and architecture
  • LES / searchsploit to map exploits
  • Verify applicability (version, arch, mitigations)
  • Having exhausted configuration paths first (privesc)
  • Prefer stable exploits (Dirty Pipe CVE-2022-0847)
  • Test in a lab/snapshot before the real target
  • Confirm root and stabilize the shell
  • Blue: patched kernel, mitigations, EDR, dmesg_restrict?