Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-37947

CVE-2025-37947: Linux Kernel Buffer Overflow Vulnerability

CVE-2025-37947 is a buffer overflow flaw in Linux Kernel's ksmbd that allows out-of-bounds memory writes during stream operations. This article covers technical details, affected versions, security impact, and mitigation.

Published:

CVE-2025-37947 Overview

CVE-2025-37947 is an out-of-bounds write vulnerability in the Linux kernel's ksmbd in-kernel SMB3 server. The flaw resides in ksmbd_vfs_stream_write(), which fails to validate that the write offset *pos falls within the bounds of the existing stream data length v_len. When *pos is greater than or equal to v_len, the function performs an out-of-bounds memory write. The issue is classified under [CWE-787]. A proof-of-concept exploit is publicly available on GitHub, increasing the urgency of remediation for systems exposing ksmbd shares.

Critical Impact

A local authenticated attacker with access to an SMB share served by ksmbd can trigger an out-of-bounds kernel write, leading to memory corruption, denial of service, or potential local privilege escalation.

Affected Products

  • Linux kernel versions up to and including 6.15-rc5 (multiple stable branches)
  • Debian Linux 11.0
  • Any distribution shipping the in-kernel ksmbd SMB server module

Discovery Timeline

  • 2025-05-20 - CVE-2025-37947 published to NVD
  • 2026-03-17 - Last updated in NVD database

Technical Details for CVE-2025-37947

Vulnerability Analysis

The vulnerability exists in the ksmbd_vfs_stream_write() function within the kernel's ksmbd SMB3 server implementation. This function handles writes to NTFS-style alternate data streams over SMB. The function accepts a write offset pointer *pos and a stream buffer length v_len from the caller without verifying their relationship before performing memory operations.

When a client submits a write request with *pos greater than or equal to v_len, the function proceeds with the write into the stream buffer. This results in writing attacker-controlled data beyond the allocated stream length, corrupting adjacent kernel memory. The bug falls under [CWE-787] (Out-of-Bounds Write).

Root Cause

The root cause is missing input validation on the offset parameter passed from the SMB client request. The original code assumed that callers would supply a valid in-range offset, but the parameter is derived from untrusted client input. The upstream patch introduces an explicit check that returns -EINVAL when *pos >= v_len, preventing the unsafe write path from executing.

Attack Vector

Exploitation requires local network access to a system exposing an SMB share served by ksmbd, along with valid authentication credentials to mount or open a writable share. The attacker crafts an SMB2 write request targeting a named stream with a manipulated file offset that exceeds the current stream data length. Successful exploitation corrupts kernel heap memory, which can be shaped to achieve denial of service or escalate privileges within the kernel context. A working proof of concept is published in the doyensec KSMBD-CVE-2025-37947 repository.

The vulnerability is described in detail in the Debian LTS Announcement. No synthetic exploitation code is reproduced here.

Detection Methods for CVE-2025-37947

Indicators of Compromise

  • Kernel oops or panic messages referencing ksmbd_vfs_stream_write or ksmbd modules in dmesg and /var/log/kern.log
  • Unexpected ksmbd.mountd service crashes or restarts under normal client load
  • SMB2 write requests targeting alternate data streams with abnormally large offset values relative to file size
  • Authenticated SMB sessions originating from unexpected internal hosts followed by kernel instability

Detection Strategies

  • Monitor kernel logs for KASAN, slab corruption, or general protection fault entries tied to ksmbd call stacks
  • Capture and inspect SMB2 WRITE packets for offset values that exceed reported file or stream sizes
  • Audit running kernel versions across the fleet and flag any host serving SMB on an unpatched kernel
  • Track unexpected loading of the ksmbd kernel module on systems that should not export SMB shares

Monitoring Recommendations

  • Enable kernel auditing for module load events and SMB service start/stop transitions
  • Forward kern.log, auth.log, and ksmbd service logs to a centralized log analytics platform for correlation
  • Alert on repeated short-lived SMB authentication followed by kernel error events from the same client IP
  • Baseline normal SMB write offset distributions and alert on statistical outliers indicative of probing

How to Mitigate CVE-2025-37947

Immediate Actions Required

  • Apply the upstream Linux kernel patches referenced by commit hashes 04c8a38c, 0ca6df4f, 7f61da79, d62ba165, and e6356499 from git.kernel.org
  • Update Debian 11 systems using the fix delivered in the August 2025 Debian LTS advisory
  • Restrict SMB share access to authenticated, trusted users and segment ksmbd hosts on isolated network zones
  • Audit which hosts expose SMB via the in-kernel ksmbd module versus the userspace Samba server

Patch Information

The fix adds a bounds check inside ksmbd_vfs_stream_write() that returns -EINVAL when *pos is greater than or equal to v_len, blocking the out-of-bounds write before it occurs. Patches are available across multiple stable branches via the kernel.org commit 7f61da79df86 and four additional backports. Distribution-level fixes are documented in the Debian LTS Announcement.

Workarounds

  • Unload the ksmbd kernel module on systems that do not require in-kernel SMB serving using modprobe -r ksmbd
  • Blacklist the ksmbd module to prevent automatic load by adding it to /etc/modprobe.d/blacklist.conf
  • Migrate SMB workloads to the userspace Samba implementation, which is not affected by this specific flaw
  • Restrict SMB share write permissions to a minimal set of trusted accounts until patches are deployed
bash
# Disable ksmbd until the kernel is patched
sudo systemctl stop ksmbd.service
sudo systemctl disable ksmbd.service
sudo modprobe -r ksmbd
echo "blacklist ksmbd" | sudo tee /etc/modprobe.d/blacklist-ksmbd.conf

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.