Skip to content
Memory corruption Write-up Advanced

ksmbd - Exploiting CVE-2025-37947 (3/3)

A heap out-of-bounds write in the ksmbd SMB server's stream_xattr handling allows an authenticated user to write up to 8 bytes past a kernel buffer by setting a large file offset. This could lead to local privilege escalation, though the provided proof of concept only triggers the bug.

blog.doyensec.com

Published on blog.doyensec.com

This is the last of our posts about ksmbd. For the previous posts, see part1 and part2.

Norbert Szetei, on blog.doyensec.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 truncates the total size to a maximum but fails to adjust the copy length, so a large offset causes a write beyond the allocated buffer.

Impact

An authenticated user could corrupt kernel heap memory, potentially leading to local privilege escalation, though the provided PoC only demonstrates the bug without escalating privileges.

What the attacker needed

Authenticated SMB user; writable share with streams_xattr enabled

How it was found

  1. Enable the streams_xattr module and add a writable share in the ksmbd configuration.
  2. Authenticate to the SMB share as a valid user.
  3. Send a write request with a large file offset (e.g., 0x10000) and a small count (e.g., 8).
  4. Observe the out-of-bounds write in the kernel buffer via debugging.

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.

The SMB file-sharing server in the Linux kernel has a bug when writing extended attributes (extra file metadata). By choosing a very large starting position, an attacker can make the server write a few bytes past the end of a memory buffer. This memory corruption could let a logged-in user gain higher privileges on the machine.

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.