18.12.2012 Views

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

[Chapter 20] 20.4 Improving NFS <strong>Sec</strong>urity<br />

only to the hosts named in the union of the two lists. There is no -access option in SVR4.<br />

20.4.2 Export Read-only<br />

Many filesystems contain information that is only read, never (or rarely) written. These filesystems can be exported read-only.<br />

Exporting the filesystems read-only adds to both security and reliability: it prevents the filesystems from being modified by NFS<br />

clients, limiting the damage that can be done by attackers, ignorant users, and buggy software.<br />

Many kinds of filesystems are candidates for read-only export:<br />

●<br />

●<br />

●<br />

Filesystems containing applications<br />

Organizational reference matter, such as policies and documents<br />

Netnews (if you do not read news with NNTP)<br />

If you have programs or other files that must be exported read-write, you can improve your system's overall performance, reliability,<br />

and security by placing these items on their own filesystem that is separately exported.<br />

To export a filesystem read-only, specify the ro=clients option in either your exports file or your dfstab file (depending on which<br />

version of <strong>UNIX</strong> you are using). In the following example, the /LocalLibrary directory is exported read-only:<br />

share -F nfs -o ro=clients /LocalLibrary<br />

20.4.3 Use Root Ownership<br />

Because the NFS server maps root to nobody, you can protect files and directories on your server by setting their owner to root and<br />

their protection mode to 755 (in the case of programs and directories) or 644 (in the case of data files). This setup will prevent the<br />

contents of the files from being modified by a client machine.<br />

If you have information on an NFS server that should not be accessible to NFS clients, you can use the file protection mode 700 (in<br />

the case of programs and directories) or 600 (in the case of data files). However, a better strategy is not to place the files on the NFS<br />

server in the first place.<br />

Remember, this system protects only files on the server that are owned by root. Also, this technique does not work if you have<br />

patched your kernel to set the value of nobody to 0, or if you export the filesystems to a particular host with the -root= option.<br />

NOTE: Protecting an executable file to be execute-only will not work as you expect in an NFS environment. Because<br />

you must read a file into memory before it can be executed, any file marked executable can also be read from a server<br />

using NFS commands (although it may not be possible to do so using standard calls through a client). The server has no<br />

way of knowing if the requests to be read are a prelude to execution or not. Thus, putting execute-only files on an<br />

exported partition may allow them to be examined or copied from a client machine.<br />

20.4.4 Remove Group-write Permission for Files and Directories<br />

If you are using standard AUTH_<strong>UNIX</strong> authentication with NFS, then users can effectively place themselves in any group. Thus, to<br />

protect files and directories that are owned by root, they must not be group-writable.<br />

20.4.5 Do Not Export Server Executables<br />

If your server is running the same operating system on the same CPU architecture as your client computers, then you might be<br />

tempted to have the server export its own executables (such as the programs stored in /bin, /usr/bin, /etc.) for use by the clients. Don't<br />

do so without careful thought about the consequences.<br />

At first, exporting a server's own executables seems like a good way to save disk space: this way, you only need to have one copy of<br />

each program, which is then shared between the clients and the servers, rather than two copies.<br />

But exporting your server's executables poses several security problems:<br />

●<br />

●<br />

It allows an attacker to easily determine which version of each executable your server is running, which enables the attacker to<br />

probe for weak spots with greater ease.<br />

If there is an error in your system's configuration, you may be exporting the binaries on a writable filesystem. An attacker<br />

file:///C|/Oreilly Unix etc/<strong>O'Reilly</strong> Reference Library/networking/puis/ch20_04.htm (3 of 6) [2002-04-12 10:45:41]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!