Shift Profile picture
Mar 28 16 tweets 4 min read Read on X
I don't often tweet about patched bugs, but here's one that looks interesting - let's discuss ZDI-24-195 or kernel commit 38d20c62903d669693a1869aa68c4dd5674e2544, in a short 🧵
A researcher named fffvr (I couldn't find their Twitter handle), recently burned `ksmbd` vulnerability. If you manage to find an infoleak in the ksmbd path you could reach a full RCE with it.
Fortunately, there were a few other commits that fixed out-of-bounds read vulnerabilities in ksmbd. fffvr did not need to find additional vulnerabilities (ZDI-24-194,227,228) to achieve a full RCE.
Although some of these CVEs are in a post-auth scenario, we can assume that anonymous access is enabled and at least one share is available, therefore allowing a full remote code execution on any ksmbd instance.
To clarify, ksmbd is a relatively new attack surface. It has only existed for a few years in the Linux kernel, so it is not enabled by default in many places. ksmbd is not the traditional SMB file sharing implementation that Linux has had for years.
Why would anyone use ksmbd instead of the traditional SMB implementation?
One of the main reasons to use ksmbd instead of the traditional kernel SMB implementations is that ksmbd supports concurrency. However, due to improper locking, it also introduces potential vulnerabilities.
Spotting the vuln is pretty easy.
ksmbd_tcp_new_connection is spawned from smbd_kthread_fn, a kernel thread that handles any new tcp connection. Every physical interface gets its own kthread to listen and spawn a new tcp thread whenever a connection occurs. Image
The race occurs when opening and closing a tcp connection fast enough. Image
Once you close a tcp connection in the ksmbd path, the disconnect method will be triggered
Image
Image
Eventually leading to a teardown of the whole structure. Image
tcp_transport is a pretty small structure itself, but it has a few interesting fields that one might think about using when weaponizing this CVE. Image
If you open many tcp connections and manage to close them fast enough, you'd race against the close operation and eventually win. Image
The smart reader will be able to spot a few locations where it is possible to hijack control flow by carefully following the structures that are freed.
While some people dislike spraying, I think this race is pretty tight and requires a few slowdown operations in order to reliably exploit it, the careful reader will be able to spot them when opening a ksmbd connection and hanging it for a while.
The only thing that is needed is a feedback mechanism to leak data back to the user.

ZDI-24-227,195, 228 are out-of-bound reads that might allow that, I did not look into them and verified that.

Thanks to fffvr for reporting such a nice vuln, we don't see such things often.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Shift

Shift Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(