Skip to content
Memory corruption Write-up Advanced

FreeBSoD: Leveraging Language Models to Find and Exploit Kernel Bugs (Part 1 of 2)

A stack-based buffer overflow in FreeBSD's routing socket subsystem allowed an unprivileged local user to overwrite kernel stack memory with attacker-controlled data. In its default configuration this caused a reliable denial of service, but privilege escalation required an additional stack canary leak.

Michelle Rhodes Follow

Published on praetorian.com

Earlier this year, a team at Praetorian was building Constantine, our automated 0-day discovery engine. I wanted to find techniques worth folding into it, so on the side I started poking at the FreeBSD kernel with Claude Code, running on Opus 4.6, which was the latest Opus model at the time.

Michelle Rhodes, on praetorian.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 copied user-controlled sockaddr data into a fixed 128-byte stack buffer using a length field that could be up to 255, and the only size check was a KASSERT that is compiled out in production kernels.

What the attacker needed

Local unprivileged access to FreeBSD; ability to send routing socket messages

The fix

It was fixed by the FreeBSD security team in an advisory the day after reporting.

How it was found

  1. Send a routing socket message containing an oversized RTAX_AUTHOR sockaddr.
  2. The oversized author sockaddr passes validation because cleanup_xaddrs only checks destination, gateway, and netmask.
  3. The message reaches rtsock_msg_buffer(), where the oversized sockaddr is copied into a 128-byte stack buffer.
  4. The overflow corrupts the stack canary and triggers a panic via __stack_chk_fail.

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 buffer overflow happens when a program copies more data into a fixed-size memory area than it can hold, so the extra data spills over into nearby memory. Here, a user-supplied length field was trusted without a real check, letting a local user write past a small kernel buffer. The result was a crash (denial of service), and with more work it could potentially be used to take over the system.

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 by Michelle Rhodes

View all

4 more disclosed reports, best first.

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.