NFS Shares Exported to Any Host

An NFS server exports file systems to any host, so anyone on the network can mount them and, by claiming another user's ID, read or change that user's files.

SeverityHigh
CVSS 3.18.2 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N Open in the calculator
CVSS 4.08.8 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-552: Files or Directories Accessible to External Parties
OWASP Top 10A01:2025 Broken Access Control
MITRE ATT&CKT1039 Data from Network Shared Drive, T1135 Network Share Discovery
CategoryBroken Access Control

Description

The NFS server exports one or more directories to every host, through a wildcard (*), an over-broad network range or a malformed export line, instead of to the specific clients that need them. With the default sec=sys (AUTH_SYS) security flavour, the server does not authenticate users: it trusts the numeric user and group IDs that the client presents. An attacker who mounts the export from a system they control can therefore create a local account with any user ID and act as that user on the share.

In this way an attacker on any network that can reach the server can read the exported files by assuming the user IDs that own them, which commonly exposes home directories, application data, backups, SSH keys and configuration files containing credentials. Where an export is writable, they can also change or plant files as any non-root user, for example adding an SSH key to a user's home directory or altering scripts that other systems run, which can lead to code execution elsewhere. The impact depends on what is exported and whether it is writable. Only the root user is mapped to an unprivileged identity by default, through root_squash, and the impact is greater still where root squashing has also been disabled.

The issue is identified by listing exports with showmount -e or the Nmap nfs-showmount script, which also show the clients each export is offered to, then mounting the export from the testing system and reviewing its contents. Scanners report it as NFS shares exported to everyone or as world-readable NFS exports.

Remediation

Limit each export to its clients and stop trusting client-asserted identities:

  • Export each directory only to the specific hosts or the smallest network range that needs it, and remove exports that are no longer required. In /etc/exports, make sure no space separates a client from its option list, because an option list on its own applies to every host.
  • Use Kerberos security, preferably sec=krb5p (or krb5i where encryption is not possible), so that users are authenticated rather than trusted by user ID, and do not offer sys on sensitive exports.
  • Export read-only (ro) wherever clients do not need to write, keep root_squash in place, and use all_squash for exports that should only ever be accessed anonymously.
  • Restrict TCP 2049 and the RPC services NFS relies on with host and network firewall rules.

Apply changes with exportfs -ra. Confirm the fix by listing the exports from an unauthorised host and checking that mounting is refused, and that the remaining exports require Kerberos where it has been configured.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Network Services Findings

Every Network Services finding