The flaw, named NFS2ROOT by cybersecurity firm OpenSec, was discovered by ANSSI's Jérémy Jean, who submitted a fix in August. OpenSec shared a full remote-root exploit and a patch with NFSD maintainers in late September.
The vulnerability stems from a heap buffer overflow in the Linux NFS server (nfsd) and has existed since kernel version 3.16, released in March 2014. It affects systems running a Linux kernel older than 6.12.117, 6.18.61, 7.3.2, or 7.4-rc1, if nfsd (v4.1 or 4.2) is loaded and TCP port 2049 is reachable over the Internet.
Successful exploitation lets threat actors corrupt kernel memory and gain root access to vulnerable Linux servers exposed online. In an NFS2ROOT attack, attackers send maliciously crafted requests that cause the NFS server to write data beyond an allocated memory buffer, allowing them to read kernel memory, bypass KASLR, and place a callback to execute a command in a released memory area. When the attacker closes the NFS connection, the kernel executes the embedded command with root privileges.
Although there are no reports of exploitation in the wild, security teams are urged to apply the latest kernel security updates from their Linux distribution vendor immediately, then reboot the system. Those unable to patch should restrict access to the NFS server over TCP port 2049 to trusted clients or networks. If NFS sharing is not required, admins can stop and disable the nfs-server service.
"Port 2049 sits open on file servers, NAS appliances, build farms and Kubernetes storage nodes. Since 2014, the Linux kernel listening on it has let anyone who can reach it write into kernel memory before logging in," OpenSec said. "Kernel hardening does not remove the overflow. Patch every host."
NFS2ROOT attacks have no network signatures, but security teams can monitor for potential exploitation attempts by checking for kernel warnings from nfsd4_check_resp_size, shells spawned by kernel workers on a file server, bursts of short NFSv4.1 sessions from one source, and kernel oopses with nfsd4_*, svc_* or call_usermodehelper* frames, according to OpenSec.
