# NFS no_root_squash Detection

> Identifies misconfigured NFS exports with no_root_squash enabled, allowing remote root privilege escalation via mounted shares.

- **URL:** https://hackindex.io/services/nfs/vulnerability-discovery/nfs-no-root-squash-detection
- **Path:** NFS > Vulnerability Discovery
- **Up:** [Vulnerability Discovery](https://hackindex.io/services/nfs/vulnerability-discovery.md)
- **Published:** 2026-05-15
- **Updated:** 2026-05-15

By default, NFS maps root (UID 0) from clients to the anonymous user `nfsnobody` on the server: this is root squashing. When `no_root_squash` is set on an export, root on any permitted client retains root privileges on the mounted share. Writing a SUID binary or injecting an SSH key from a client with local root gives full access to the server account that owns the share.

Detection methods for no_root_squash:

- Read `/etc/exports` from a local shell on the target
- Mount the share as root and test file creation with UID 0
- Check Nmap `nfs-showmount` output for export options

## **Read Export Options via showmount**

`showmount -e` lists exports but does not show options. Options are visible in the server's `/etc/exports` if you have read access, or via the NFS mount response:

```bash
showmount -e $TARGET_IP
# Export list for 10.10.10.50:
# /home/backup *
# /data        10.10.10.0/24
```

showmount shows paths and client access lists but not mount options. Use nmap to retrieve options:

```bash
nmap -p 111,2049 --script nfs-showmount $TARGET_IP
# | nfs-showmount:
# |   /home/backup (everyone)
# |_  /data (10.10.10.0/24)
```

## **Check Export Options with nmap**

The `nfs-ls` script retrieves export options including squash settings:

```bash
nmap -p 111,2049 --script nfs-ls $TARGET_IP
# | nfs-ls: Volume /home/backup
# |   access: Read Lookup NoModify NoExtend NoDelete NoExecute
# | nfs-ls: Volume /data
# |   access: Read Lookup Modify Extend Delete Execute
# |   NFS: (rw,no_root_squash,no_subtree_check)
```

`no_root_squash` in the options field is a confirmed misconfiguration. `rw` combined with `no_root_squash` is exploitable: write a SUID binary or inject SSH keys as a client with local root.

## **Mount and Check Effective Permissions**

Mount the export and verify effective UID mapping:

```bash
mkdir /mnt/nfs_check
mount -t nfs $TARGET_IP:/data /mnt/nfs_check
```

Check how root maps on the server side:

```bash
ls -la /mnt/nfs_check/
```

If files are owned by root and writable, root squashing is off. Create a test file as root on the client:

```bash
touch /mnt/nfs_check/root_test
ls -la /mnt/nfs_check/root_test
# -rw-r--r-- 1 root root 0 May 15 14:22 root_test
#
```

File owned by `root` (not `nfsnobody` or `65534`) confirms `no_root_squash`. Clean up:

```bash
rm /mnt/nfs_check/root_test
umount /mnt/nfs_check
```

## **Read /etc/exports Directly**

If the share exposes the filesystem root or `/etc`:

```bash
cat /mnt/nfs_check/etc/exports
# /data           *(rw,no_root_squash,no_subtree_check)
# /home/backup    *(ro,root_squash)
```

Direct read of `/etc/exports` shows all exports and their options in one step. Also check `/etc/exports.d/` for split config files.

## **Impact Classification**

| Export options | Impact |
| --- | --- |
| `rw,no_root_squash` | Full root write: SUID shell, SSH key injection, direct file overwrite |
| `ro,no_root_squash` | Root read: access to all files regardless of permissions, readable shadow/passwd |
| `rw,root_squash` | UID spoofing only: see [NFS UID Spoofing](https://hackindex.io/services/nfs/enumeration/nfs-export-discovery/exploitation/uid-spoofing) |
| `ro,root_squash` | Read access limited to world-readable files |

`no_root_squash` on a read-write export is the highest-severity NFS misconfiguration. For the full exploitation workflow see [NFS no_root_squash Abuse](https://hackindex.io/services/nfs/enumeration/nfs-export-discovery/privilege-escalation/no-root-squash-abuse).

## References

- [Linux man: exports(5)](https://linux.die.net/man/5/exports) - NFS export options including root_squash, no_root_squash, all_squash
- [nfs-ls NSE script](https://nmap.org/nsedoc/scripts/nfs-ls.html) - Export listing with mount options and access flags
