NFS (Network File System) shares can be a goldmine for privilege escalation. When NFS is misconfigured with "no_root_squash", you can create SUID binaries as root from your attack machine that execute on the target. It's like leaving a master key maker unguarded.
Think of NFS like a shared folder between computers. Normally, even if you mount it as root, the server "squashes" your root privileges (root_squash). But with no_root_squash, root on your machine = root on the share. Create a SUID binary, and boom - root on the target.
Requires Network Access
NFS exploitation requires network access to the target. You typically need a shell on the system to discover NFS misconfigurations, then use your attack machine to exploit them.
Enumerating NFS
Understanding NFS Options
Exploiting no_root_squash
Must Be Root on Attacker
To create SUID binaries on NFS with no_root_squash, you must be root on your attack machine. The whole point is that root on your machine = root on the share.
Alternative Exploitation Methods
Troubleshooting NFS Mounts
Check Mount Options
Some mounts may be made with "nosuid" option even if the export allows it. Check both /etc/exports AND the actual mount options on the target.
Exploitation Without Root on Attacker
Finding Mounted NFS on Target
NFS Exploitation Methodology
NFS Privilege Escalation Flow
1
Find Exportscat /etc/exports on target
2
Identify VulnLook for no_root_squash + rw
3
MountMount share as root from attack machine
4
Create SUIDCopy bash or compile SUID binary
5
Set Permissionschmod +s on the binary
6
ExecuteRun SUID binary on target as root
Knowledge Check
Challenges
Key Takeaways
- Check /etc/exports for no_root_squash + rw shares
- no_root_squash means root on client = root on share
- Mount share on attack machine, create SUID binary as root
- Execute SUID binary on target for root access
- Must have root on attack machine to exploit
- Find mount point on target with mount | grep nfs