NFS
NFS is the Unix world’s file sharing — and because it pushes authentication onto RPC and trusts the client’s UID, a misconfigured export lets you mount a share, impersonate whatever user owns the files, and read or modify them at will. The no_root_squash option turns that into a clean privilege escalation.
Protocol: TCP/UDP · Ports: 2049 (NFS) · 111 (RPC portmapper)
What Is NFS?
Network File System (NFS), developed by Sun Microsystems, serves the same purpose as SMB — accessing file systems over a network as if they were local — but it’s used between Linux and Unix systems. A big advantage of NFSv4 over older versions is that it uses just a single port (TCP or UDP 2049), which makes it much easier to run across firewalls. Older versions also rely on the ONC-RPC/SUN-RPC protocol on port 111, using XDR (External Data Representation) for system-independent data exchange. The critical security fact: NFS has no authentication or authorization mechanism of its own. Authentication is shifted entirely onto RPC’s options — which is exactly the gap you exploit.Default Configuration
NFS is simpler to configure than FTP or SMB. The/etc/exports file holds a table of the physical filesystems the server makes available, which hosts/subnets can reach them, and with what rights:
/mnt/nfs to the entire 10.129.14.0/24 subnet — meaning any host on that network can mount the share and inspect its contents. Each export is the folder, then the host or subnet allowed, then the options in parentheses.
Dangerous Settings
Several export options are risky:| Option | Risk |
|---|---|
rw | Read-write access — clients can modify files |
insecure | Allows ports above 1024. Normally only root can use ports below 1024, which keeps unprivileged local users from interacting with NFS. insecure removes that barrier |
nohide | Exposes nested/child filesystems |
no_root_squash | The big one — a client connecting as root is treated as root on the share, instead of being “squashed” to the unprivileged nobody user |
Footprinting the Service
RPC Enumeration with Nmap
Ports 111 and 2049 are the ones that matter. Therpcinfo NSE script lists all running RPC services, their names, and ports — confirming the share is reachable on the ports it needs:
Show Available Shares
List the exports withshowmount:
Mount the Share
Create an empty local folder and mount the share to it, then browse it like any local directory:List with Owners — and Why It Matters
List contents showing usernames/groups, then UIDs/GIDs:Escalation via SUID
NFS also enables local privilege escalation. If you already have SSH access and want to read files only a specific user can access, upload a shell to the NFS share with that user’s SUID set (from your machine, where you control ownership), then run it through your SSH session — it executes with the SUID user’s rights. When you’re finished, unmount cleanly:Quick Reference
| Command | Purpose |
|---|---|
nmap -sV -sC -p111,2049 <ip> | RPC + NFS enumeration |
nmap --script nfs-ls,nfs-showmount,nfs-statfs <ip> | Share contents and stats |
showmount -e <ip> | List available exports |
mount -t nfs <ip>:/share ./local -o nolock | Mount the share |
ls -l / ls -n | List with owner names / numeric UIDs |
umount ./local | Unmount when done |
no_root_squash/SUID to escalate).
Next: RSYNC — enumerating and pulling files from rsync modules.