Skip to main content
Vulnerability Database/CVE-2024-41059

CVE-2024-41059: Linux Kernel Use-After-Free Vulnerability

CVE-2024-41059 is a use-after-free flaw in the Linux Kernel hfsplus filesystem that causes uninitialized memory access. This post explains the technical details, affected versions, impact, and mitigation steps.

Published:

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

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-41059 Overview

CVE-2024-41059 is an uninitialized memory use vulnerability [CWE-908] in the Linux kernel's HFS+ filesystem driver (fs/hfsplus/xattr.c). The flaw was identified by the syzbot kernel fuzzer through KMSAN instrumentation, which reported an uninit-value in sized_strscpy called from copy_name. The issue occurs when hfsplus_listxattr allocates a strbuf without initializing its contents to zero. A local, low-privileged attacker interacting with a mounted HFS+ volume can trigger the condition via the listxattr syscall, resulting in information disclosure or kernel instability.

Critical Impact

A local attacker can trigger uninitialized kernel memory reads through extended attribute listing on HFS+ filesystems, leading to information disclosure and potential denial of service.

Affected Products

  • Linux Kernel (multiple stable branches, see kernel.org commits for exact ranges)
  • Debian LTS distributions shipping affected kernels
  • Any Linux distribution with HFS+ (hfsplus) filesystem support enabled

Discovery Timeline

  • 2024-07-29 - CVE-2024-41059 published to NVD
  • 2025-01 - Debian LTS advisory issued for affected kernel packages
  • 2026-08-04 - Last updated in NVD database

Technical Details for CVE-2024-41059

Vulnerability Analysis

The vulnerability resides in the HFS+ extended attribute (xattr) handling code at fs/hfsplus/xattr.c. When a userspace process invokes the listxattr syscall against a file on an HFS+ volume, the kernel allocates a strbuf buffer using kmalloc inside hfsplus_listxattr at line 699. The allocated memory is not zeroed before use.

The uninitialized buffer is later passed to copy_name at line 411, which calls sized_strscpy. Because the backing memory may contain stale kernel heap data, the subsequent string copy operation reads uninitialized bytes. KMSAN detected this through the syscall path __x64_sys_listxattr → vfs_listxattr → hfsplus_listxattr → copy_name → sized_strscpy.

The fix initializes the strbuf allocation to zero, ensuring deterministic contents before any downstream string operations.

Root Cause

The root cause is a classic uninitialized memory use pattern [CWE-908]. The hfsplus_listxattr function used kmalloc instead of kzalloc for the attribute name buffer. When copy_name processed attribute names shorter than the allocated buffer, the trailing bytes retained whatever data previously occupied that slab allocation.

Attack Vector

Exploitation requires local access and the ability to interact with a mounted HFS+ filesystem. An attacker with low privileges mounts or accesses an HFS+ volume, then calls listxattr, llistxattr, or flistxattr against a file. Repeated invocations can disclose fragments of kernel heap memory to userspace, potentially leaking sensitive data such as pointers, credentials, or cryptographic material. Malformed HFS+ images can increase the likelihood of reaching the vulnerable code path.

No verified public exploit code is available for CVE-2024-41059. The syzbot reproducer is referenced in the upstream commit messages. See the Kernel Git Commit 22999936b for the patch and KMSAN trace details.

Detection Methods for CVE-2024-41059

Indicators of Compromise

  • Unexpected mounts of HFS+ filesystems on servers that do not normally handle Apple-formatted media
  • Kernel log entries referencing KMSAN warnings in hfsplus_listxattr, copy_name, or sized_strscpy
  • Unusual volumes of listxattr, llistxattr, or flistxattr syscalls originating from non-administrative users

Detection Strategies

  • Audit loaded kernel modules for hfsplus on hosts that have no business reason to mount Apple filesystems
  • Enable kernel address sanitizers (KASAN, KMSAN) in test environments to validate patched builds
  • Correlate mount events with subsequent extended attribute syscalls using Linux auditd rules

Monitoring Recommendations

  • Monitor auditd for syscall=listxattr events combined with HFS+ filesystem paths
  • Alert on userspace processes loading the hfsplus kernel module via modprobe or insmod
  • Track kernel version and patch level across the fleet to confirm remediation coverage

How to Mitigate CVE-2024-41059

Immediate Actions Required

  • Apply the upstream kernel patch or vendor-backported update to all affected stable branches
  • Blacklist the hfsplus module on systems that do not require HFS+ support
  • Restrict mount privileges so that only trusted administrators can mount removable media or disk images

Patch Information

The fix was committed across multiple stable branches. The relevant commits include Kernel Git Commit 0570730c, Kernel Git Commit 22999936b, Kernel Git Commit 34f8efd2, Kernel Git Commit 72805deb, Kernel Git Commit ad57dc2c, Kernel Git Commit c733e24a, Kernel Git Commit d02d8c1d, and Kernel Git Commit f08956d8. Debian LTS users should consult the Debian LTS Announcement for distribution-specific packages.

Workarounds

  • Disable automount for removable media and disk images on multi-user systems
  • Add hfsplus to /etc/modprobe.d/blacklist.conf to prevent on-demand loading
  • Enforce mount namespace restrictions to prevent unprivileged users from mounting arbitrary filesystems
bash
# Blacklist the hfsplus module to prevent on-demand loading
echo "blacklist hfsplus" | sudo tee /etc/modprobe.d/blacklist-hfsplus.conf
sudo depmod -a

# Verify the module is not currently loaded
lsmod | grep hfsplus

# Confirm running kernel version after patching
uname -r

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

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

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.