NFS / RPC-Service Exploitation
Attacking hosts exposing NFS + rpcbind: common on operator/dev boxes, cloud ECS instances, NAS, and internal networks. Highest-value outcomes: a world-exported share with no_root_squash (files you write land on the server as uid 0), and/or an unpatched NFSv4.0 n-day.
Detection & sweep
Scan every host you already hold (family siblings, looted boxes, internal ranges) for 2049 (nfs) and 111 (rpcbind) before concluding a box has no more doors — one NFS hit can outweigh a week of web fuzzing:
nmap -Pn -p 2049,111 --open -T4 <targets...>
# fast multicore connectivity sweep over a /24
ok = socket.socket().connect_ex((ip, 2049)) == 0
Procedure
- RPC service map — do NOT trust
showmount/rpcinfoalone. They hang for minutes when mountd sits on a nonstandard port or UDP is filtered. Call the portmapper directly:scripts/portmap_dump.py <host> [port=111](UDP + TCP; TCP requires ONC RPC record marking = 4-byte header0x80000000|len— a bare call just times out). It prints the program→port map: mountd(100005), nfs(100003), statd(100024), nlockmgr(100021). Expect mountd on a random high port. - List exports. If showmount works, use it; otherwise raw MOUNT v2 EXPORT (proc 5) against the mountd port:
scripts/mnt_export.py <host> <mountd_port>. Parse for export paths and the client spec — group*= open to everyone. - Mount — version/path gotchas (time sink):
with vers=3→requested NFS version or transport protocol is not supported⇒ server is NFSv4-only.- NFSv4: mount the pseudo-root
:/, NOT the export path —host:/srv/nfs/sharereturnsNo such file or directoryeven when the export exists.
mount -t nfs -o vers=4.0,soft,timeo=30 <host>:/ /mnt/nfsx - Write + identity-mapping test (the jackpot):
Probe dir showing uid 0/gid 0 ⇒ no_root_squash: your files live as root on the server.mkdir /mnt/nfsx/probe_$$ && ls -ln /mnt/nfsxsec=sys(default) means the server trusts the client-claimed uid — squashing is the operator's choice, so always test it, never assume. - Escalate or park:
- A writable-as-root share is only host-root if something on the box executes/consumes from it — check what the share is for (deploy dir, backup, queue) before claiming escalation. NFSv4's pseudo-root isolates the share; there is no traversal to
/etcor/root. - No exec vector ⇒ keep the mount (exfil channel + box-relation signal), and pivot to the same host's other ports (SSH, HTTPS panels).
- The box's own looted SSH keys/passwords frequently do NOT log back into the same box (hardened sshd) — try ≤3, then move on.
- A writable-as-root share is only host-root if something on the box executes/consumes from it — check what the share is for (deploy dir, backup, queue) before claiming escalation. NFSv4's pseudo-root isolates the share; there is no traversal to
- n-day check: NFSv4.0 code is live exploit territory — see
references/cve-2026-31402-nfsv4-rce.md(crash PoC is pure-network; full RCE needs a local foothold). Weigh keep-alive value before crashing anything.
Pitfalls
showmount -ehanging ≠ no NFS — it is a thin UI over the same RPC calls; go raw (steps 1–2).- Forgetting ONC RPC TCP record marking looks exactly like a filtered/closed port.
- NFSv4
No such file or directoryon mount = wrong path form (use:/), not a dead export. - Same box, two surfaces pair up: an open HTTP directory listing (python
http.serveretc.) gives file READ while NFS gives root-identity WRITE — check both and verify a file created over NFS through the box's own HTTP layer. - A writable share does not equal root. State impact precisely: "share writable as uid 0" until an execution/consumption path is proven.
- An empty share listing is not a dead export — operators clean shares between runs; only the write test (mkdir +
ls -ln) decides.
References
references/cve-2026-31402-nfsv4-rce.md— NFSv4.0 LOCK-replay heap overflow → RCE: mechanics, preconditions, exploit status.scripts/portmap_dump.py— raw portmapper DUMP (UDP+TCP, record marking handled).scripts/mnt_export.py— raw MOUNT v2 EXPORT listing for nonstandard mountd ports.