How Can I Secure My NFS Shares from Anonymous Access?

June 10, 2025 5 answers
Asked by latitude without longitude
Hey everyone, I could use some help here. After a recent penetration test, it appears that two of our NFS shares on a Debian 11 server are accessible without any authentication. Here's what my `/etc/exports` file currently looks like: 1. `/images 172.16.0.0/12 (ro,sync,no_wdelay,no_subtree_check,insecure_locks,no_root_squash,insecure,fsid=0)` 2. `/images/dev 172.16.0.0/12 (rw,async,no_wdelay,no_subtree_check,no_root_squash,insecure,fsid=1)` I thought I had addressed this issue after the last pen test a couple of years back. What am I missing to restrict access properly?

Answers

+QuietCheckout
Thanks for the feedback! I plan to change `no_root_squash` to `root_squash` and remove `insecure`. I'll also narrow down the IP range since we have about 350 clients split over five ranges. Appreciate the advice!
Reply to this answer
4 voices humming
It looks like there might be an error in your `/etc/exports`. There's a space between the IP range and the options, which isn't allowed. The right format should not include any whitespace there.
Reply to this answer
vowel shift 5
Have you checked your network setup? It's crucial to manage your network and firewalls properly. If someone malicious already has access to your subnets, you might have bigger concerns than just NFS shares.
Reply to this answer
_speak_clearly_
The biggest security issue I see is the `no_root_squash` option. This setting lets clients retain root permissions on your NFS server, which is a major security flaw. Also, using `insecure` allows unsecured connections that break NFS security expectations. Consider tightening your IP range too, as `/12` allows possibly thousands of clients. How many do you actually need?
Reply to this answer
jigsaw exchange
To tackle the anonymous access risk, think about making the filesystem read-only. Since you're probably just serving OS images, any necessary file access afterward should be authenticated. Make sure to document how you mitigated this risk, like having a read-only setting and highlighting that no sensitive data is there. Just remember, it might not pass every security check, but if it's designed that way without public info, it should be okay.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions