NFS UID Spoofing – Reading Files Without Root
NFS does not authenticate users — it trusts the UID and GID sent by the client. If a file on an NFS share is owned by UID 1001 and has mode 600, only a client presenting UID 1001 will be able to read it. Creating a local user on your attack box with UID 1001 makes you that user from NFS's perspective, bypassing Unix permission checks on the share.
This requires you to have already mounted the share. It does not require root on the NFS server. You do need root on your attack box to create users and reassign UIDs — which is trivially available on your own Kali machine.
For shares where you have no read access at all, see https://hackindex.io/services/nfs/exploitation/world-readable-share-exploitation. For shares with no_root_squash, see https://hackindex.io/services/nfs/exploitation/no-root-squash-abuse.
Step 1 – Identify the Target UID
Mount the share and list the files you cannot read:
Use -n to show numeric UIDs and GIDs instead of names — the local /etc/passwd will not have the remote user names, so numeric output is what you need:
-rw------- 1 1001 1001 2590 Jan 10 09:14 id_rsa
-rw-r--r-- 1 1001 1001 563 Jan 10 09:14 id_rsa.pub
drwx------ 2 1001 1001 4096 Jan 10 09:12 .ssh
The UID you need to impersonate here is 1001.
Step 2 – Create a Local User with the Matching UID
Create a new user on your attack box with the exact UID from the file listing:
If UID 1001 is already assigned on your attack box, reassign your existing user or use usermod to create a conflict-free mapping:
-o allows duplicate UIDs if 1001 is already taken. Alternatively, find a free UID and temporarily reassign the existing one:
Step 3 – Access the Files as the Spoofed UID
Switch to the new user and read the restricted files:
NFS now sees your client presenting UID 1001 and grants read access. The files are yours.
Spoofing Multiple UIDs
If the share contains files owned by several different UIDs, create users for each:
drwx------ 2 1001 1001 4096 jan 10 . # user1 drwx------ 2 1002 1002 4096 jan 10 . # user2 drwx------ 2 1003 1003 4096 jan 10 . # user3
Switch between them as needed to access each home directory.
Spoofing Root (UID 0) When root_squash Is Disabled
If the share is exported with no_root_squash, you do not need UID spoofing — your attack box root is already trusted as root on the server. If root_squash is enabled (the default), UID 0 from the client is remapped to nfsnobody and spoofing root does not work. The UID spoofing technique is specifically for non-root UIDs — files owned by regular users that are not world-readable.
Cleanup
Remove the spoofed user after the engagement:
References
-
www.errno.frwww.errno.fr/nfs_privesc.html (opens in new tab)
A tale of a lesser known NFS privesc Covers NFSv3 UID trust mechanics and the ld_nfs.so technique for local-only share access scenarios.
Was this helpful?
Your feedback helps improve this page.