# hoefler02/cve-2025-21756 architecture

> Architecture diagram of the GitHub repository hoefler02/cve-2025-21756, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hoefler02/cve-2025-21756
- Repository: https://github.com/hoefler02/cve-2025-21756

## Overview

##### Project type and purpose
- This is a proof-of-concept exploit tool targeting Linux kernel CVE-2025-21756 (vulnerable kernel 6.6.75).
- Its purpose is to build a minimal initramfs environment, boot a vulnerable kernel (e.g., under QEMU), execute the exploit binary (x.c compiled), gain kernel privileges, and retrieve a flag.

##### File structure
- Top‐level files and scripts:
- run.sh        → orchestrates build, packaging, and QEMU launch
- compress.sh   → builds or compresses the initramfs image
- extract-image.sh → unpacks an existing initramfs
- x.c           → C source for the exploit
- flag.txt      → placeholder for captured flag
- initramfs/ directory → the guest root filesystem:
- initramfs/bin/{busybox, sh}
- initramfs/etc/{inittab, init.d/rcS, motd, resolv.conf}
- initramfs/init → primary init script that runs the exploit

##### README for additional insights
- Confirms it’s an exploit for CVE-2025-21756
- References a full write-up covering exploitation of vsock

##### Diagramming recommendations
- Host components (scripts, toolchain) in blue
- Virtualized runtime (QEMU + kernel) in green
- Initramfs guest components in orange
- Exploit/vsock channel in red
- Script invocations (run.sh → compress.sh)
- Packaging steps (scripts → initramfs.cpio.gz)
- Boot flow (kernel → initramfs → init)
- Exploit communication (x → vsock → host)
- Optionally, annotate notes on critical files (e.g., “rcS: sets up network for vsock”)

##### Detail without over-splitting
- Logical step as its own component
- Don’t omit simple utilities (busybox/sh) because they’re part of the minimal environment
- The goal is to see at a glance: how the exploit gets into initramfs, how it’s executed, and how control returns to the host

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Host Environment"
        HS1["run.sh"]:::host
        HS2["compress.sh"]:::host
        HS3["extract-image.sh"]:::host
        HS4["x.c"]:::host
        HS5["flag.txt"]:::host
        HS6["readme.md"]:::host
        HS7["gcc & busybox utils"]:::host
    end

    HS1 -->|"calls"| HS2
    HS1 -->|"calls"| HS3
    HS1 -->|"compiles & packages"| HS7
    HS1 -->|"launches"| VM1

    subgraph "Virtualized Runtime"
        VM1["QEMU"]:::vm
        VM2["Kernel 6.6.75"]:::vm
    end

    VM1 -->|"loads"| VM2
    VM1 -->|"mounts initramfs.cpio.gz"| GuestRoot

    subgraph "Initramfs Guest"
        G1["initramfs/init"]:::guest
        G2["/bin/busybox"]:::guest
        G3["/bin/sh"]:::guest
        G4["/etc/inittab"]:::guest
        G5["/etc/init.d/rcS"]:::guest
        G6["/etc/motd"]:::guest
        G7["/etc/resolv.conf"]:::guest
        G8["x (exploit binary)"]:::guest
        G9["flag.txt"]:::guest
    end

    VM2 -->|"executes init"| G1
    G1 -->|"reads inittab & runs rcS"| G5
    G5 -->|"sets up env & spawns"| G8
    G2 -->|"provides"| G1
    G3 -->|"shell for scripts"| G5
    G8 -->|"writes flag"| G9

    G8 -->|"uses vsock"| Channel
    Channel["vsock channel"]:::channel
    Channel -->|"to exploit vulnerability on"| VM2
    Channel -->|"back to host"| HS1

    click HS1 "https://github.com/hoefler02/cve-2025-21756/blob/main/run.sh"
    click HS2 "https://github.com/hoefler02/cve-2025-21756/blob/main/compress.sh"
    click HS3 "https://github.com/hoefler02/cve-2025-21756/blob/main/extract-image.sh"
    click HS4 "https://github.com/hoefler02/cve-2025-21756/blob/main/x.c"
    click HS5 "https://github.com/hoefler02/cve-2025-21756/blob/main/flag.txt"
    click HS6 "https://github.com/hoefler02/cve-2025-21756/blob/main/readme.md"
    click G1 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/init"
    click G2 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/bin/busybox"
    click G3 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/bin/sh"
    click G4 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/etc/inittab"
    click G5 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/etc/init.d/rcS"
    click G6 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/etc/motd"
    click G7 "https://github.com/hoefler02/cve-2025-21756/blob/main/initramfs/etc/resolv.conf"
    click G8 "https://github.com/hoefler02/cve-2025-21756/tree/main/initramfs/x"

    classDef host fill:#D0E8FF,stroke:#0000FF,stroke-width:1px
    classDef vm fill:#DFFFE0,stroke:#00AA00,stroke-width:1px
    classDef guest fill:#FFE4B5,stroke:#FF8C00,stroke-width:1px
    classDef channel fill:#FFD0D0,stroke:#FF0000,stroke-width:1px
```
