Exploitable Linux Kernel Vulnerabilities: Privilege Escalation via nf_tables and ksmbd

In Netfilter, a subsystem of the Linux kernel used to filter and modify network packets, a vulnerability (CVE-2024-1086), allowing a local user to execute code at the kernel level and elevate their privileges on the system. The problem is caused by double-free memory in the nf_tables module, which provides the nftables packet filter. The security researcher who discovered the vulnerability developed and published working prototype of the exploit, applicable to Linux kernels from release 3.15 to 6.8-rc1.

The exploit has been demonstrated in current releases of Debian and Ubuntu with Linux kernels 5.14 – 6.6, as well as in an environment with the KernelCTF (Capture the Flag) kernel, which includes additional patches to block typical exploit methods and is used by Google in its program for paying rewards for finding vulnerabilities. The exploit's success rate is estimated at 99.4%. IN accompanying article The process of creating a complex multi-level exploit and bypassing the mechanisms present in the kernel to protect and counteract the operation of exploits are analyzed in detail.

The problem is related to a bug in the nft_verdict_init() function, which allows the use of positive values ​​as a DROP error code in hooks, which can be used to call the nf_hook_slow() function to re-release memory for a buffer that has already The free() function was called. The problem occurs when the NF_DROP operation fails and the kernel first interprets NF_DROP, but then frees the buffer and returns NF_ACCEPT status. This situation leads to the fact that despite the release of the buffer associated with the packet, its processing does not stop, but is transferred to another handler, which in turn calls the memory release function a second time.

The vulnerability appears starting from Linux kernel version 3.15, but the exploit works with kernels starting from 5.14. A fix for the vulnerability was proposed in the Linux kernel 6.8-rc1 release and was moved to stable branches 5.15.149, 6.1.76 and 6.6.15 at the end of February. In distributions, you can track the correction of the vulnerability on the following pages: Debian, Ubuntu, Gentoo, RHEL, SUSE, Fedora, Arch.

Additionally, you can note series of vulnerabilities in the ksmbd module, which offers a file server implementation built into the Linux kernel based on the SMB protocol: Vulnerability CVE-2024-26592 allows you to remotely execute your code with kernel rights on systems with the activated ksmbd module without authentication. The problem is caused by a race condition in the TCP connection processing code, which occurs due to the lack of proper locking when working with the object.

Vulnerability CVE-2023-52440 also allows you to remotely execute your code with kernel rights, but is caused by a buffer overflow when processing incorrect session keys due to the lack of proper verification of the size of data received from the user before copying it to a fixed-size buffer.

Vulnerabilities (1, 2, 3) CVE-2024-26594, CVE-2023-52442 And CVE-2023-52441 ksmbd makes it possible to remotely determine the contents of kernel memory without authentication. The vulnerability CVE-2024-26594 is caused by incorrect data validation when processing incoming SMB2 Mech tokens, which results in data being returned from an area outside the buffer boundary. The vulnerability CVE-2023-52442 is caused by a lack of proper input validation when processing chained requests. The vulnerability CVE-2023-52441 is caused by a lack of required input validation when processing SMB2 connection negotiation requests.

Vulnerabilities CVE-2024-26594 and CVE-2024-26592 eliminated in kernel 6.8 and corrective updates of previous stable branches 6.1.75, 6.6.14, 6.7.2. The remaining vulnerabilities were fixed in kernel 6.5 and updates 5.15.145, 6.1.53, 6.4.16.

Finally, we can mention the activation of a new team to analyze the presence of vulnerabilities and assess the connection of the corrections being made with security problems. In February, the kernel developers were created own CNA (CVE Numbering Authority) service, which received powers self-appropriation CVE identifiers for vulnerabilities. Previously, the assignment of CVEs and the analysis of the connection between fixes and possible vulnerabilities fell on the shoulders of distribution developers, and in the kernel potential vulnerabilities did not remain highlighted and appeared on a par with regular fixes. The results of the new service exceeded all expectations – every day in the core
marked up to several dozen new vulnerabilities that were not previously flagged as security issues. For example, on March 26, CVE identifiers were assigned to 14 vulnerabilities, and on March 25, 41 vulnerabilities were assigned.

Thanks for reading: