20.2 Server-Side NFS SecurityBecause NFS allows users on a network to access files stored on the server, NFS has significant security implications for the server. These implications fall into three broad categories:
20.2.1 Limiting Client Access: /etc/exports and /etc/dfs/dfstabThe NFS server can be configured so that only certain hosts are allowed to mount filesystems on the server. This is a very important step in maintaining server security: if an unauthorized host is denied the ability to mount a filesystem, then the unauthorized users on that host will not be able to access the server's files. 20.2.1.1 /etc/exportsMany versions of UNIX , including Sun's SunOS, HP's HP-UX, and SGI 's IRIX operating systems use the /etc/exports file to designate which clients can mount the server's filesystem and what access those clients are to be given. Each line in the /etc/exports file generally has the form: directory -options [,more options] For example, a sample /etc/exports file might look like this: / -access=math,root=prose.domain.edu /usr -ro /usr/spool/mail -access=math The directory may be any directory or filesystem on your server. In the example, exported directories are / , /usr, and /usr/spool/mail. The options allow you to specify a variety of security-related options for each directory. These include:
You should understand that NFS maintains options on a per-filesystem basis, not per-directory, basis. If you put two directories in the /etc/exports file that actually reside on the same filesystem, they will use the same options (usually the options used in the last export listed). Sun's documentation of anon states that, "If a request comes from an unknown user, use the given UID as the effective user ID." This statement is very misleading; in fact, NFS by default honors "unknown" user IDs - that is, UIDS that are not in the server's /etc/passwd file - in the same way that it honors "known" UIDS , because the NFS server does not ever read the contents of the /etc/passwd file. The anon option actually specifies which UID to use for NFS requests that are not accompanied by authentication credentials. Let's look at the example /etc/exports file again: / -access=math,root=prose.domain.edu /usr -ro /usr/spool/mail -access=math This example allows anybody in the group math or on the machine math to mount the root directory of the server, but only the root user on machine prose.domain.edu has superuser access to these files. The /usr filesystem is exported read-only to every machine that can get RPC packets to and from this server (usually a bad idea - this may be a wider audience than the local network). And the /usr/spool/mail directory is exported to any host in the math netgroup. 20.2.1.2 /usr/etc/exportfsThe /usr/etc/exportfs program reads the /etc/exports file and configures the NFS server, which runs inside the kernel's address space. After you make a change to /etc/exports, be sure to type this on the server: # exportfs -a You can also use the exportfs command to temporarily change the options on a filesystem. Because different versions of the command have slightly different syntax, you should consult your documentation. 20.2.1.3 Exporting NFS directories under System V: share and dfstabVersions of NFS that are present on System V systems (including Solaris 2.x) have dispensed with the /etc/exports file and have instead adopted a more general mechanism for dealing with many kinds of distributed filesystems in a uniform manner. These systems use a command called share to extend access for a filesystem to a remote machine, and the command unshare to revoke access. The share command has the syntax: share [ -F FSType ] [ -o specific_options ] [ -d description ] [ pathname] where FSType should be nfs for NFS filesystems, and specific_options are the same as those documented with the /etc/exportfs file earlier. The optional argument description is meant to be a human-readable description of the filesystem that is being shared. When a system using this mechanism boots, its network initialization scripts execute the shell script /etc/dfs/dfstab . This file contains a list of share commands. For example: Example 20.1: An /etc/dfs/dfstab file With Some Problems# place share(1M) commands here for automatic execution # on entering init state 3. # # This configuration is not secure. # share -F nfs -o rw=red:blue:green /cpg share -F nfs -o rw=clients -d "spool" /var/spool share -F nfs /tftpboot share -F nfs -o ro /usr/lib/X11/ncd share -F nfs -o ro /usr/openwin This file gives the computers red , blue , and green access to the /cpg filesystem; it also gives all of the computers in the clients netgroup access to /var/spool. All computers on the network are given read-write access to the /tftpboot directory; and all computers on the network are given read-only access to the directories /usr/lib/X11/ncd and /usr/openwin. Do you see the security hole in the above configuration? It's explained in detail in Section 20.4, "Improving NFS Security " later in this chapter.
20.2.2 The showmount CommandYou can use the UNIX command /usr/etc/showmount to list all of the clients that have probably mounted directories from your server. This command has the form: /usr/etc/showmount [ options ] [host] The options are:
|
|