UAF in linux kernel >= 6.1.152 (psock->cork) # CVE-2025-39913 - Linux Kernel eBPF SOCKMAP (UAF)
**Author: Byte Reaper**
**My platform : https://www.bytrep.com/**
## Description
- This repository contains a technical proof-of-concept for CVE-2025-39913, a vulnerability in the Linux kernel's tcp_bpf_send_verdict() function. When bpf_msg_cork_bytes() fails to allocate psock->cork, the kernel may skip freeing sk_msg, leading to memory mismanagement. This can result in memory leaks or potential use-after-free (UAF) conditions under specific eBPF sk_msg operations.
Affects Linux kernel versions ≤ 6.12.38 with SOCKMAP support.
## Requirements :
```
Kernel ≤ 6.12.38
Linux x86_64
GCC
```
## Build :
```
1 - Create Makefile :
# touch Makefile
2 - Paste the content into the Makfile :
TARGET := CVE-2025-39913
KERNEL_PATH := /usr/src/linux-headers-$(shell uname -r)
BPF_OBJ := bpf_injection.o
USER_SRCS := main.c load_bpf.c check_bpfELf.c pingCheck.c com_c.c exit_asm.c sockmap_link.c check_elf.c result.c argparse.c
USER_OBJS := $(USER_SRCS:.c=.o)
ALL_OBJS := $(USER_OBJS) $(BPF_OBJ)
LIBS := -l:libbpf.a -lrt -lelf -lz
$(TARGET): $(ALL_OBJS)
gcc $(USER_OBJS) -o $@ $(LIBS)
%.o: %.c
gcc -c $< -o $@
$(BPF_OBJ): bpf_injection.c
clang -O2 -target bpf -c $< -o $@ \
-nostdinc \
-I/usr/lib/clang/19/include \
-I$(KERNEL_PATH)/arch/x86/include \
-I$(KERNEL_PATH)/arch/x86/include/generated \
-I$(KERNEL_PATH)/include \
-I$(KERNEL_PATH)/include/uapi \
-I$(KERNEL_PATH)/include/generated/uapi \
-I$(KERNEL_PATH)/include/asm-generic \
-I/usr/include
clean:
```
## Run :
```
1 - IP address :
# ./CVE-2025-39913 -i [server-ip]
2 - target port (default : 80) :
# ./CVE-2025-39913 -i [server-ip] -p [PORT]
3 - Full ARG :
# ./CVE-2025-39913 -h
4 - Check Obj file BPF :
# ./CVE-2025-39913 -i [server-ip] -p [PORT] -o
5 - Check debug tracing :
# ./CVE-2025-39913 -i [server-ip] -p [PORT] -c
```
## References
- **Linux BPF TCP** – <https://docs.kernel.org/networking/filter.html>
- **bpf.h** – <https://codebrowser.dev/linux/include/linux/bpf.h.html>
- **NVD (CVE-2025-39913)** – <https://nvd.nist.gov/vuln/detail/CVE-2025-39913>
- **Create SOCKMAP** – <https://docs.kernel.org/bpf/map_sockmap.html>
- **POC** – <https://bytrep.com/exploit39913.html>
## Observation :
- This is an exploitation taken from the platform https://bytrep.com/
## License :
MIT
Log in to view the POC file snapshot cached by Shenlong Bot
Log in to view