Skip to content
Memory corruption Write-up Advanced

Exploiting a No-Name FreeBSD Kernel Vulnerability

A FreeBSD kernel vulnerability in the cdrom device driver allowed a local attacker in the operator group to write to arbitrary kernel memory. This could be exploited to escalate privileges to root, either by redirecting a system call to userland code when SMEP is disabled, or by corrupting user credentials when SMEP is enabled.

synacktiv.com

Published on synacktiv.com

Written by Mehdi Talbi - 24/07/2019 - in Exploit - Download

The author, on synacktiv.com

The full write-up lives on its author's site

It belongs to its author, 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

The driver used bcopy instead of copyout to copy data to user-supplied address, allowing arbitrary kernel memory write.

Impact

A local attacker in the operator group could escalate privileges to root, though the SMEP-enabled exploit is unreliable and may cause kernel panics.

What the attacker needed

Local access to FreeBSD system; user in operator group; cdrom device present

The fix

The vulnerability was fixed by replacing bcopy with copyout in the driver.

How it was found

  1. Open the cdrom device /dev/cd0.
  2. Prepare an ioc_read_subchannel structure with data pointing to the target kernel address.
  3. Invoke the CDIOCREADSUBCHANNEL_SYSSPACE ioctl to write to that address.
  4. Trigger the corrupted syscall or check for altered uid to gain root.

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 bug in the FreeBSD operating system's CD-ROM driver let someone with limited access write to protected memory. This could let them take full control of the computer. The problem was that the driver copied data to the wrong place, bypassing safety checks.

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.