Skip to content
Memory corruption Write-up Advanced

OpenBSD has a use-after-free allowing local privilege escalation to root

A use-after-free in the OpenBSD kernel's System V semaphore code (sys_semget) can be triggered by a local user, allowing privilege escalation to root. The flaw is a context-switch use-after-free after a sleep call.

nvd.nist.gov

Published on nvd.nist.gov

The original lives on nvd.nist.gov

We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a race where the kernel sleeps (tsleep) in sys_semget and the semaphore structure is freed before the sleeping thread resumes, leaving a dangling pointer.

Impact

A local attacker could escalate privileges to root, giving full control of the system.

What the attacker needed

Local access to the system; OpenBSD up to and including 7.9

The fix

The text references a patch commit, so it was fixed upstream.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A use-after-free is a memory bug where a program keeps using a piece of memory after it has been freed, so an attacker can make it hold something else. Here the OpenBSD kernel does this in code that manages semaphores (a system feature for coordinating processes), and a local user can exploit it to become the root administrator.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.