After the recent Linux NFS server kernel fix, I went back and looked at the exports themselves. Patching the kernel is step one. Step two is making sure your shares aren’t handing out root to anyone who asks. Here’s the quick read-only check I use.
1. See what’s actually exported right now
sudo exportfs -v
This shows each live export, which clients can mount it and every option in effect, including defaults you didn’t type.
2. Read the config files
grep -v '^#' /etc/exports /etc/exports.d/*.exports 2>/dev/null
3. Look for the risky options
no_root_squash: root on the client is root on your files. Only use it for a trusted box that truly needs it.*or a huge subnet as the client: anyone who can reach the port can mount it.insecure: allows connections from unprivileged ports.rwwhererowould do.
sudo exportfs -v | grep -E 'no_root_squash|insecure|\*'
4. Check who can reach it
ss -tlnp | grep -E ':2049|:111'
If NFS is listening on every interface, make sure your firewall only lets your LAN or VPN subnet in.
5. Fix and reload
Edit /etc/exports to use root_squash (the default), narrow the client list to the real subnet, then reload without a restart:
sudo exportfs -ra
sudo exportfs -v
Ten minutes of checking, and an old share stops being somebody else’s root shell.
God Bless, and Happy hacking!