ksmbd - Exploiting CVE-2025-37947 (3/3) #1496
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
Title: ksmbd - Exploiting CVE-2025-37947 (3/3) — Doyensec
Scope/goal: Show a reliable local Linux kernel privilege escalation (LPE) against ksmbd by abusing a deterministic out-of-bounds (OOB) write in the streams_xattr path. Exploit demonstrated on Ubuntu 22.04.5 LTS with kernel 5.15.0-153-generic, bypassing KASLR, SMEP, SMAP, and hardened usercopy.
Preconditions to reach the bug:
- ksmbd service enabled and a writable SMB share exposed.
- Samba VF...
🔧 Technical Details
Deterministic OOB via streams_xattr position truncation: In ksmbd, if
*pos + count > XATTR_SIZE_MAX (0x10000), the allocation is clamped to 0x10000 butcountis recomputed as(*pos + count) - 0x10000andmemcpy(&stream_buf[*pos], buf, count)proceeds. Set*pos ≥ 0x10000(e.g.,0x10018) to write beyond the 16‑page buffer; shifting*possteers offset, withcountgrowing accordingly.Buddy-allocator page shaping for page-overflow targets: Pre-exhaust order‑3/4 freelists (zone Normal, migrate type Unmovable) to force order‑5 splits, then place an order‑3 slab (e.g.,
kmalloc‑cg‑4k) immediately after the order‑4 stream buffer. Spray 4096‑bytemsg_msgobjects, create holes by receiving some messages, and iterate until adjacency is achieved.Generic msg_msg exploitation chain: Overflow a primary
msg_msgn...🤖 Agent ActionsI analyzed the Doyensec blog post and updated HackTricks with a new Linux kernel exploitation technique based on ksmbd streams_xattr OOB write (CVE-2025-37947), including the exploitation chain with msg_msg and pipe_buffer primitives.
What I added/changed:
Created two new technical pages (to keep parity with existing structure that mirrors kernel exploitation in both sections):
These pages include:
Added “See also” cross-links in the existing POSIX CPU timers kernel exploitation pages to help discoverability:
Inserted a “See also” section above the References that links to the new ksmbd page in the same folder via:
{{#ref}}
ksmbd-streams_xattr-oob-write-cve-2025-37947.md
{{#endref}}
Why this is the right place:
References added:
No redundant content was found in existing pages; this technique was not present yet, so new pages were warranted.
This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.