Share
## https://sploitus.com/exploit?id=90EC8998-FB96-54C8-B382-EB8D24257354
# eBPF Verifier Exploit Research โ€” s344024 Romano Simone

Research project for the Security Verification and Testing (SVT) course โ€”
analysis and exploit development for eBPF verifier vulnerabilities in the Linux kernel.

The primary focus is identifying unpatched or unexploited CVEs in `kernel/bpf/verifier.c`,
writing proofs of concept, and developing memory read/write primitives suitable for
Local Privilege Escalation (LPE).

---

## Project Structure

```
s344024_Romano_Simone/
โ”‚
โ”œโ”€โ”€ test/                               โ† Buildroot-based build & test environment
โ”‚   โ”œโ”€โ”€ build.sh                        โ† Interactive build script (CVE + kernel selection)
โ”‚   โ”œโ”€โ”€ buildroot/                      โ† Buildroot source tree
โ”‚   โ”œโ”€โ”€ configs/                        โ† Shared/base buildroot configs
โ”‚   โ”œโ”€โ”€ patches/                        โ† Per-kernel patch sets (linux-4.x ... 5.9.x)
โ”‚   โ”œโ”€โ”€ linux-6.8/kernel/bpf/           โ† Reference verifier source for diff/analysis
โ”‚   โ””โ”€โ”€ CVEs/                           โ† One folder per CVE under test
โ”‚       โ”œโ”€โ”€ CVE-2023-39191/
โ”‚       โ”‚   โ”œโ”€โ”€ configs/                โ† Per-kernel buildroot + kernel configs
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ v6.0/
โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ v6.1/
โ”‚       โ”‚   โ”œโ”€โ”€ exploit_overlay/
โ”‚       โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ CVE-2024-42072/
โ”‚       โ”‚   โ”œโ”€โ”€ configs/
โ”‚       โ”‚   โ”œโ”€โ”€ exploit_overlay/
โ”‚       โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ CVE-2024-43838/
โ”‚       โ”‚   โ”œโ”€โ”€ configs/
โ”‚       โ”‚   โ”œโ”€โ”€ exploit_overlay/
โ”‚       โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ CVE-2024-45020/
โ”‚       โ”‚   โ”œโ”€โ”€ configs/
โ”‚       โ”‚   โ”œโ”€โ”€ exploit_overlay/
โ”‚       โ”‚   โ””โ”€โ”€ src/
โ”‚       โ””โ”€โ”€ CVE-2024-58100/
โ”‚           โ”œโ”€โ”€ configs/
โ”‚           โ”œโ”€โ”€ exploit_overlay/
โ”‚           โ””โ”€โ”€ src/
โ”‚
โ”œโ”€โ”€ exploits/                           โ† Standalone exploit sources (outside Buildroot flow)
โ”‚   โ”œโ”€โ”€ CVE-2023-39191/src/             โ† poc.c, exploit.c 
โ”‚   โ”œโ”€โ”€ CVE-2024-42072/src/
โ”‚   โ”œโ”€โ”€ CVE-2024-45020/src/
โ”‚   โ””โ”€โ”€ CVE-2024-58100/src/             
โ”‚
โ”œโ”€โ”€ report/                             โ† LaTeX report
โ”‚   โ”œโ”€โ”€ main.tex
โ”‚   โ”œโ”€โ”€ compile.sh
โ”‚   โ”œโ”€โ”€ src/                            โ† Per-CVE chapter sources
โ”‚   โ”‚   โ”œโ”€โ”€ CVE-2023-39191.tex
โ”‚   โ”‚   โ”œโ”€โ”€ CVE-2024-42072.tex
โ”‚   โ”‚   โ”œโ”€โ”€ CVE-2024-45020.tex
โ”‚   โ”‚   โ””โ”€โ”€ CVE-2024-58100.tex
โ”‚   โ”œโ”€โ”€ img/
โ”‚   โ”œโ”€โ”€ out/                            โ† Build artifacts (aux, log, ...)
โ”‚   โ””โ”€โ”€ SVT_report.pdf                  โ† Compiled PDF
โ”‚
โ””โ”€โ”€ presentation/                       โ† LaTeX slides
    โ”œโ”€โ”€ main.tex
    โ”œโ”€โ”€ compile.sh
    โ”œโ”€โ”€ img/
    โ”œโ”€โ”€ out/
    โ””โ”€โ”€ SVT_presentation.pdf            โ† Compiled PDF
```

---

## CVEs

| CVE | Kernel Range | Bug Class | Memory Primitive | LPE Status |
|-----|-------------|-----------|-----------------|------------|
| CVE-2023-39191 | โ‰ค 6.1.19 / โ‰ค 6.2.6 | Dynptr type confusion (OOB via overlapping dynptrs on BPF stack) | Arbitrary OOB R/W via corrupted dynptr size | Full LPE (adaptive calibration + cred spray) |
| CVE-2024-42072 |  **Note:** `-m 9216` (9 GiB RAM) is **required** for CVE-2023-39191.
> The exploit's OOB target lands at ~8.2 GiB physical; less RAM makes it unreachable.

| VM Detail | Value |
|-----------|-------|
| Rootfs | Buildroot minimal image |
| Kernel | Per-CVE, selectable in build script |
| Virtualization | QEMU (no KVM required) |
| Login | `root` (no password) |
| BPF | Enabled, unprivileged BPF allowed |
| KASLR / RANDOMIZE_MEMORY | Disabled (for exploit reproducibility) |
| Binary delivery | Via Buildroot overlay โ†’ `/root/` in VM |

---

## Building & Running

### CVE-2023-39191 โ€” Dynptr Type Confusion LPE

```bash
# Build Buildroot image for kernel 5.19 (vulnerable)
cd test/
./build.sh   # select CVE-2023-39191, kernel v5.19

# Boot VM with 9 GB RAM
cd buildroot/
output/images/start-qemu.sh  --serial-only -- -m 9216

# Inside VM:
/root/poc      # Verify OOB R/W primitive
/home/user/exploit  # Full LPE โ†’ creates /tmp/rootsh
/tmp/rootsh    # Spawn root shell
```

### CVE-2024-42072

```bash
cd test/
./build.sh   # select CVE-2024-42072

cd buildroot/
output/images/start-qemu.sh  --serial-only

# Inside VM:
/root/poc      # OOB read primitive demo
/root/exploit  # Exploitation attempt
```

### CVE-2024-45020

```bash
cd test/
./build.sh   # select CVE-2024-45020

cd buildroot/
output/images/start-qemu.sh  --serial-only

# Inside VM:
/root/poc      # Dynptr OOB trigger
/root/exploit  # Exploitation attempt
```

### CVE-2024-58100 โ€” Stale PTR_TO_PACKET UAF

```bash
cd test/
./build.sh   # select CVE-2024-58100, kernel v6.12.24

cd buildroot/
output/images/start-qemu.sh -- -smp 4

# Inside VM (login as user, uid=1000):
/home/user/poc        # Verifier-accept demo (stale PTR_TO_PACKET load)
/home/user/exploit    # UAF R/W primitive + PE attempt via pipe_buffer.ops
```

> **Capabilities:** the init script (`exploit_overlay/etc/init.d/S99exploit`) grants
> `cap_bpf,cap_net_admin,cap_perfmon,cap_syslog+ep` to the exploit binary and sets
> `kptr_restrict=0`, `unprivileged_bpf_disabled=0`, `perf_event_paranoid=0`. This
> simulates a context where a service with BPF policy is compromised โ€” CVE-2024-58100
> is **not** exploitable by a fully unprivileged user on modern kernels.

---

## Report

The full technical report (LaTeX + PDF) is in `report/`. It covers:
- Methodology for CVE selection from the eBPF verifier bug class
- Technical analysis of each CVE (patch diff, root cause, exploitation path)
- Exploit design decisions and failed approaches
- Results and conclusions

Politecnico di Torino โ€” Cybersecurity (SVT) โ€” A.Y. 2025/2026