If the Client Side Root User access an NFS Share, it will be changed to the unprivilege nfsnobody user So any file created and uploaded by the Root user will be owned by nfsnobody, which prevents an attacker to upload binaries with the SUID bit enabled
no_root_squash
Grant authority to the Client Side Root User to access, read and write resources as the Root User of the NFS Server
no_all_squash
Same as above but applies to non-root users
Important
By default, NFS uses root squash, so the Client’s Root User access is downgraded to the user nobody of the NFS Server
Enumeration
From the Attacker ⚔️
showmount -e <TARGET>
Abuse
Therefore, if no_root_squash is configured for an NFS Share and the attacker has SSH access to the target as an unprivileged user, proceed as follows →
Local Directory Creation
Create a local directory where the NFS Share is to be mounted
mkdir <LOCAL_FOLDER>
Mounting NFS Share
Mount the remote shared folder/filesystem in the created directory
mount --types nfs --options vers=2,nolock <TARGET>:<REMOTE_RESOURCE_PATH> <LOCAL_FOLDER> # Or --options vers={3,4}
Payload Creation as Local Root User inside NFS Share
As Root
Access the remote resource through the local folder and create a payload