Skip to content
Memory corruption Write-up Advanced

CVE-2022-23088: Exploiting A Heap Overflow In The Freebsd Wi-fi Stack

A heap overflow in the FreeBSD Wi-Fi stack occurs because the MeshId option length is not validated before a memcpy into a fixed-size buffer. An attacker within Wi-Fi range can send a crafted beacon frame to overwrite kernel memory and potentially execute arbitrary code.

m00nbsd Follow

Published on zerodayinitiative.com

Our goal is to achieve kernel remote code execution on a target FreeBSD system using a heap overflow vulnerability in the Wi-Fi stack of the FreeBSD kernel. This vulnerability has been assigned CVE-2022-23088 and affects all FreeBSD versions since 2009, along with many FreeBSD derivatives such as pfSense and OPNsense.

m00nbsd (@m00nbsd), on zerodayinitiative.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 code fails to check that the length of the MeshId option in a beacon frame fits within the destination buffer before copying it.

Impact

A network-adjacent attacker could execute arbitrary code in the kernel, gaining full control of the target system.

What the attacker needed

Attacker within Wi-Fi range; target scanning for Wi-Fi networks; no authentication required

The fix

The vulnerability was fixed by adding a sanity check on the MeshId option length before the memcpy.

How it was found

  1. Send a beacon frame with an oversized MeshId option to trigger the heap overflow.
  2. Use the overflow to overwrite the se_ies data and len fields, creating a write-what-where primitive.
  3. Send a second corrective beacon frame to set ies->data to NULL and ies->len to 0, preventing a crash.
  4. Use the primitive to write an implant at physical address 0x1000 via the direct map.
  5. Overwrite an L3 page table entry to map kernel text as writable and the implant as executable.
  6. Patch the beginning of sta_input() to jump to the implant, then send a final corrective frame.

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.

When your computer scans for Wi-Fi networks, it listens to small broadcast messages called beacon frames. This bug is like a mail slot that accepts a letter of any size, so a very long letter can spill out and overwrite other important papers on the desk. An attacker nearby can send such a long message to take control of the computer.

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.

More from FreeBSD Security Team

View all

The newest disclosed reports for this program.

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.