FreeBSD /dev/dsp (OSS) Negative-Offset mmap Kernel Memory Corruption LPE (CVE-2026-45258)
by Yayoi-cs · 2026-07-05
- Severity
- Critical
- CVE
- CVE-2026-45258
- Category
- binary
- Affected product
- FreeBSD kernel (OSS//dev/dsp sound driver mmap handling)
- Affected versions
- per source repository (offset PRIV_CHECK_CRED_OFF 0x950af0 hardcoded for tested kernel build)
- Disclosed
- 2026-07-05
- Patch status
- unpatched
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-07 |
| Author / Researcher | Yayoi-cs |
| CVE / Advisory | CVE-2026-45258 |
| Category | binary |
| Severity | Critical |
| CVSS Score | Not specified in source |
| Status | PoC |
| Tags | freebsd, kernel, lpe, privilege-escalation, oss, dev-dsp, mmap, setuid, 1day |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | FreeBSD kernel (OSS//dev/dsp sound driver mmap handling) |
| Versions Affected | per source repository (offset PRIV_CHECK_CRED_OFF 0x950af0 hardcoded for tested kernel build) |
| Language / Platform | C |
| Authentication Required | Local (unprivileged local user/shell access) |
| Network Access Required | No |
Summary
This PoC targets a FreeBSD kernel local privilege escalation reachable through the OSS /dev/dsp audio device driver. By configuring device fragment sizes via ioctl(SNDCTL_DSP_SETFRAGMENT, ...) and then mmap-ing the device with a crafted negative file offset, the exploit tricks the kernel into mapping kernel virtual memory (rather than the intended device buffer) into the process address space. It then locates and overwrites the priv_check_cred kernel function with a stub that always returns success (xor eax,eax; ret), effectively disabling the kernel’s privilege/credential check, and finally calls setuid(0)/setgid(0) to obtain root before spawning /bin/sh.
Vulnerability Details
Root Cause
The OSS /dev/dsp driver’s mmap handler does not properly validate/clamp a negative file offset supplied by userspace when computing the resulting kernel buffer mapping. By pre-mapping many “spray” file descriptors of the same device to learn the driver’s KVA (kernel virtual address) layout via sysctl(KERN_PROC_VMMAP), the exploit computes an offset/length pair that, when passed to a second mmap() call with a negative offset, causes the kernel to map memory pages that live before the intended buffer in kernel address space — including the priv_check_cred function’s code page — into the calling process as PROT_READ | PROT_WRITE shared memory. This gives the unprivileged process direct read/write access to arbitrary kernel memory relative to the leaked buffer KVA and the kernel base address (obtained via kldstat).
Attack Vector
- Resolve the running kernel’s base address using
kldstat(). - Compute the absolute target address of the
priv_check_credfunction using a hardcoded offset (PRIV_CHECK_CRED_OFF) from kernel base. - Open and
mmapmany/dev/dspfile descriptors (spraying) after configuring OSS fragment parameters viaioctl(SNDCTL_DSP_SETFRAGMENT)to influence kernel buffer allocation/placement. - Use
sysctl(KERN_PROC_VMMAP)on the exploit’s own process to discover the kernel virtual address (KVA) backing one of the mapped/dev/dspbuffers. - Compute a negative
mmapoffset/length such that mapping the device again lands the mapping’s userspace address on the kernel page containingpriv_check_cred. - Write a small patch (
31 c0 c3 90 90 90 90 90, i.e.xor eax,eax; ret; nop*4) directly into the mapped kernel memory, neutralizing the credential-check function so it always reports success. - Call
setuid(0)andsetgid(0)— now unconditionally allowed becausepriv_check_credno longer denies the operation — andexecv("/bin/sh")to obtain a root shell.
Impact
A local unprivileged user with access to the OSS /dev/dsp device node can gain arbitrary kernel read/write and escalate to full root privileges on the affected FreeBSD system.
Environment / Lab Setup
Target: FreeBSD kernel build matching the hardcoded PRIV_CHECK_CRED_OFF (0x950af0) offset.
Requirements: local shell access, read/write permission on /dev/dsp (OSS sound driver present/enabled).
Attacker tooling: cc/clang to compile exp.c on the target (or statically compile for the target ABI).
Proof of Concept
PoC Script
See
exp.c(and demonstration screenshotlpe.png) in this folder.
| |
Running the compiled binary on a vulnerable FreeBSD host sprays /dev/dsp mappings, leaks the kernel buffer KVA, remaps kernel memory containing priv_check_cred as read/write, patches it to a no-op success stub, then calls setuid(0)/setgid(0) before executing /bin/sh as root.
Detection & Indicators of Compromise
- Repeated open()/mmap()/ioctl(SNDCTL_DSP_SETFRAGMENT) calls against /dev/dsp from an unprivileged process,
especially large numbers of concurrent open file descriptors on the same audio device (fd spraying).
- mmap() calls against a device fd using unusual/negative file offsets.
- sysctl KERN_PROC_VMMAP queries by a non-privileged process immediately followed by writes to a device mapping.
- Unexpected setuid(0)/execve("/bin/sh") transitions originating from a process that was previously unprivileged
and had /dev/dsp open.
Signs of compromise:
- Unprivileged process unexpectedly running as root (
uid/euid0) shortly after interacting with/dev/dsp. - Kernel panics, instability, or unexplained integrity failures in audio/OSS subsystem code pages.
- Root shells spawned from processes with no prior privileged parent, correlating with audio device access.
Remediation
| Action | Detail |
|---|---|
| Primary fix | Apply the FreeBSD kernel/OSS driver patch that validates and clamps mmap offsets on /dev/dsp (and related audio device nodes) so negative or out-of-range offsets cannot map kernel memory outside the intended device buffer. |
| Interim mitigation | Restrict access to /dev/dsp (and other OSS device nodes) to trusted users/groups only, or disable/unload the OSS sound driver on systems where it is not required, until the kernel is patched. |
References
Notes
Mirrored from https://github.com/Yayoi-cs/CVE-2026-45258_1day_LPE_exploit on 2026-07-05.
| |