# OpenBSD Privilege Escalation Chains 37-Year-Old Bug With Kernel Flaw

Researchers demonstrate a local root exploit bypassing core hardware protections without information disclosure.

- **Source:** [Security Affairs](https://brifing.si/source/e6c4f5ec-3e1b-4152-a932-056243bd56eb)
- **Published:** 2026-10-19
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://securityaffairs.com/201285/hacking/big-fish-openbsd-root-exploit-chains-a-37-year-old-bsd-bug-with-a-kernel-flaw.html>
- **On Brifing:** https://brifing.si/s/5a8ccdd5-c319-4175-bb18-d3552baff75d

## Historical Bug Discovery

The exploit chain leverages a 37-year-old integer overflow vulnerability inherited from original BSD sources. The shm_nattch counter was defined as a signed 16-bit integer in 1988, limiting it to 32,767. By mapping 127 shared memory segments and forking 259 processes, attackers can force this counter to wrap around to a negative value.

## Exploiting Kernel Memory

The integer overflow triggers a use-after-free condition via a race-condition mechanism. This allows the kernel to free memory still in use by active processes. A secondary out-of-bounds write then modifies multicast membership counters, enabling the attacker to overwrite page table entries and gain supervisor-level privileges within the system memory space.

## Bypassing Hardware Protections

This exploit successfully bypasses SMAP, SMEP, and KARL protections without requiring any information disclosure vulnerabilities. By targeting kernel memory accounting errors rather than hardware directly, the attack circumvents standard security hardening. The researchers utilized kernel memory allocation metrics via sysctl to perform heap layout analysis from userland, ensuring precise memory targeting.

## Predictability in KARL

While OpenBSD uses KARL to randomize function and data addresses at boot, the kernel's memory allocators remain deterministic. Early boot allocations, including network interface handlers, land at predictable locations on the same hardware. The exploit targets lo0 and enc0 interface ioctl handlers, which the kernel consistently places at known, static memory addresses.

## Execution and Restoration

Attackers achieve code execution by overwriting specific structures in the kernel. To maintain stability, they use a second structure to restore the overwritten pointer after the exploit completes. The researchers aligned IP socket allocations and set non-default multicast TTL values to ensure a persistent 16-byte structure was placed exactly where needed.

## Patching and Mitigation

OpenBSD addressed these vulnerabilities in September 2024 through errata 018 and 026. These patches are currently available via syspatch for all supported architectures. Users are advised to apply these updates immediately, as the exploit chain provides a reliable path to root access for local attackers on unpatched OpenBSD 7.9 systems.

## Proposed Security Enhancements

Calif researchers suggest four specific improvements to harden the kernel against similar attacks. These include implementing safe-unlinking for linked lists, randomizing page table self-referential mappings, and randomizing the kernel allocator base address at boot. Additionally, enabling array bounds checks in release builds could detect out-of-bounds writes before they lead to privilege escalation.

## Broader System Implications

The research highlights that similar protections could have mitigated 21 issues previously reported to FreeBSD. By focusing on kernel memory accounting rather than just hardware-level defenses, developers can significantly increase the difficulty of local privilege escalation. This incident underscores the persistent risk posed by legacy codebases and the necessity of modern memory safety.

## Sources covering this story

- https://securityaffairs.com/201285/hacking/big-fish-openbsd-root-exploit-chains-a-37-year-old-bsd-bug-with-a-kernel-flaw.html — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
