
A Proof of Concept (PoC) exploit for CVE-2015-1328
A Proof of Concept (PoC) exploit for CVE-2015-1328, a privilege escalation vulnerability affecting the Linux kernel's overlayfs implementation. This vulnerability allows local unprivileged users to gain root access by exploiting improper permission checks in overlayfs mount operations within user namespaces.
CVE-2015-1328 is a critical security vulnerability that affects Linux kernels with overlayfs support and user namespaces enabled. The vulnerability allows an unprivileged local user to:
unshare(CLONE_NEWUSER)/etc/ld.so.preloadThis PoC demonstrates the vulnerability by:
/etc/ld.so.preloadgetuid() to execute a root shellkernel.unprivileged_userns_clone=1)-m32 flag support)The project includes a Makefile for easy compilation:
make
This will compile:
ofs - The main exploit binary (static 32-bit)ofs-lib.so - The shared library for LD_PRELOAD hook (32-bit)If you prefer to compile manually:
# Compile main exploit
gcc -o ofs ofs.c -m32 -static
# Compile shared library
gcc -m32 -fPIC -shared -o ofs-lib.so ofs-lib.c -ldl -static-libgcc
⚠️ WARNING: This exploit will modify system files and attempt to gain root privileges. Only use in controlled environments with proper authorization.
Compile the exploit:
make
Run the exploit:
./ofs
If successful, the exploit will:
/etc/ld.so.preload/bin/su which triggers the malicious libraryunshare(CLONE_NEWUSER)clone() with CLONE_NEWNS/etc/ld.so.preload/tmp/ofs-lib.so/bin/su, which triggers the preloaded librarygetuid() and spawns a root shellclone() with a custom stack to create isolated mount namespacesofs-lib.so) hooks getuid() via LD_PRELOAD/bin/su calls getuid(), the malicious function is executed instead.
├── ofs.c # Main exploit code
├── ofs-lib.c # Shared library for privilege escalation
├── lib_so.h # Embedded binary library data
├── Makefile # Build configuration
└── README.md # This file
getuid() hook that spawns a root shellTo protect against this vulnerability:
echo 0 > /proc/sys/kernel/unprivileged_userns_clone
This code is provided for educational and security research purposes only.
This project is provided as-is for educational purposes. Use responsibly and in accordance with all applicable laws and regulations.