
Proof-of-concept local privilege escalation exploit for CVE-2017-7184, a Linux kernel XFRM netlink stack overflow. Demonstrates namespace abuse and kernel ROP to gain root without sudo.
This repository contains a proof-of-concept local privilege escalation exploit for CVE-2017-7184, a Linux kernel vulnerability in the XFRM (IPsec) netlink subsystem.
The exploit demonstrates how an unprivileged user can gain real root (UID 0) by:
Creating an unprivileged user + network namespace
Gaining CAP_NET_ADMIN inside the namespace
Triggering a kernel stack overflow in XFRM netlink handling
Executing a kernel ROP chain to call:
prepare_kernel_cred(NULL)commit_creds()Returning safely to userland with full root privileges
No sudo is required.
| Field | Value |
|---|---|
| CVE | CVE-2017-7184 |
| Component | Linux Kernel – XFRM Netlink |
| Bug Type | Kernel Stack Overflow |
| Impact | Local Privilege Escalation |
| Attack Vector | Local (unprivileged user) |
| Exploit Class | Namespace abuse + ROP |
| First Affected | Linux kernels ≤ 4.8 |
| Fixed In | Kernel patches released in 2017 |
Unprivileged User Namespace
unshare(CLONE_NEWUSER | CLONE_NEWNET)CAP_NET_ADMIN without sudoXFRM Netlink Abuse
NETLINK_XFRM socketXFRM_MSG_NEWSA messageKernel ROP Execution
Return to Userland
swapgs; iretqunprivileged_userns_clone = 1gcc with pthread supportCheck namespace support:
cat /proc/sys/kernel/unprivileged_userns_clone
Expected output:
1
gcc exploit.c -o exploit -pthread
./exploit
Do not use sudo.
If successful, you will obtain a real root shell:
uid=0(root) gid=0(root) groups=0(root)
The exploit attempts to:
Leak symbols from /proc/kallsyms
If restricted, fall back to hardcoded offsets for:
commit_credsprepare_kernel_cred⚠️ ROP gadgets and offsets are kernel-version specific. You must adjust them for other builds.
This still confirms the system is vulnerable.
sysctl -w kernel.unprivileged_userns_clone=0
This code is provided for educational and security research purposes only.
commit_creds exploitation