Version: 4.0

To get the newest updates of Security files check the following services:

mail info@iss.net with "send index" in message
http://www.iss.net/
ftp iss.net /pub/


This FAQ contains suggestions for securing your UNIX machine after it has been compromised. Even if your machines have not been compromised, there are many helpful tips on securing a machine in this FAQ.

1.
Try to trace/follow the intruder back to his/her origin by looking at:

Note: who, w, last, and lastcomm are commands that rely on /var/adm/pacct, /usr/adm/wtmp, and /etc/utmp to report the information to you. Some intrusion techniques will keep the intruder from being shown in these logs. With applications that are available on the Internet, it is trivial to remove any detection in these logs.

Suggestion: Install xinetd or tcp_wrapper, which can log all TCP connections to your machine, as defined by the administrator, that will allow the administrator to detect potential intrusions. Forward syslogs to another machine so intruder will not easily detect the logs and modify. Other available applications: netlog from net.tamu.edu:/pub/security.

It might be wise to monitor the intruder via an Ethernet sniffer (hardware or software implementation) to observe and review the execution of the exploit before taking corrective measures.

2.
Close the machine from outside access. Remove it from network to stop further access by the intruder. If the intruder finds out that the administrator is privy to his presence, he may perform an rm -rf / in an attempt to destroy any evidence of his presence or as an act of vengeance.
3.
Check the binaries against the originals. Especially check the following binaries as they can be replaced and subsequently gain access or regain access:

Other potentials for being replaced:

4.
To be thorough you may need to reload the entire operating system to restore the machine into a known or trusted configuration. Tripwire helps prevent someone from modifying binaries and system files (such as inetd.conf) on the system, without the administrator knowing.
5.
Implement some password scheme for your users to verify that they change their passwords often. Install anlpasswd, npasswd, or passwd+ in place of passwd (or yppasswd) so that your users are forced to set reasonable passwords. Then run crack, which is available on ftp.cert.org:/pub/tools/crack which will ensure that the users choose non-trivial passwords. On any given network, clear text passwords can be a problem. Hence, a solution could be one-time password technology or point-to-point session encryption.
6.
Check all file structures for .rhosts and .forward and inspect their contents. If .rhosts file contains '+ +', the account can be accessed anywhere by anyone without a password. The .forward file, when possible, can be installed into root's directory in an effort to modify critical files that could be used to gain access. COPS has a scripts for checking .rhosts. Use: find / -name .rhosts -ls -o -name .forward -ls
7.
Look also for all the files created/modified in the timeframe you suspect the break-in took place. For example, use: find / -ctime -2 -ctime +1 -ls to find all the files modified not less than one day ago, but not more than 2 as the magnitude of information can become confusing and unwieldy.
8.
All .login, .logout, .profile, .cshrc files are also worth looking at (at least for the modification date/time). Make sure there are no .rhosts for the locked or special accounts (like news, sundiag, sync, etc.) The shell for such accounts should be something like /bin/false anyway (and not /bin/sh) to make them more secure. Also search for directories that have values like ". ", ".. " as names. They are usually found in /tmp, /var/tmp, /usr/spool/* and any other publicly writeable directory.
9.
Check to make sure your NFS exports are not world writable to everyone. NFSwatch available on harbor.ecn.purdue.edu:/pub/davy, a program by David Curry, will log any NFS transactions that are taking place. Try showmount -e to see whether system agrees with your opinion of what are you exporting and where. There are bugs in some nfsd implementations which ignore the access lists when they exceed some limit (such as 256 bytes). Check also what are you IMPORTING!!! Use the nosuid flag whenever possible. You do not want to be cracked by a sysadm from another host (or a cracker there) running suid programs mounted via NFS.
10.
Make sure you have implemented the newest sendmail. Old sendmail daemons allowed remote execution of commands on any Unix machine. See the computer-security/security-patch FAQ.
11.
Try to install all the security patches available from the vendor on your machine. See the computer-security/security-patch FAQ.
12.
Here is a check list of common ways that a machine is vulnerable:

Remember, there are so many ways that somebody could have modified your system, that you really have to have your eyes and ears wide open for a long time. Above, are the pointers just to the most obvious things to check.

13.
Mail all the sites that you were able to find out that the intruder was going through and warn them. Also, CC: cert@cert.org. Check all the sites in your domain, institution, etc. It's usually trivial for a hacker to get to another system by a simple rlogin if the two systems have a common subset of users (and using .rhosts to make the access easier).
14.
A preventive measure for stopping many intruders from even trying your network is to install a firewall.

Side effects: Firewalls may be expensive; filtering may slow down the network. If you use a firewall, consider blocking nfs (port 2049/udp) and portmap(111/udp) on your router. The authentication and access controls of these protocols is often minimal. Also you should consider blocking all udp ports except DNS and NTP ports, killing all source routing packets, and killing all IP-forwarding packets.


Acknowledgements

Thanks to the following people for adding and shaping this FAQ:

Tomasz Surmacz <tsurmacz@asic.ict.pwr.wroc.pl>
Wes Morgan (morgan@engr.uky.edu)
Alan Hannan (alan@noc1.mid.net)
Peter Van Epp <vanepp@sfu.ca>
Richard Jones <electron@suburbia.apana.org.au>
Wieste Venema <wietse@wzv.win.tue.nl>
Adrian Rodriguez <adrian@caip.rutgers.edu>
Jill Bowyer <jbowyer@selma.hq.af.mil>
Andy Mell <amell@cup.cam.ac.uk>


Copyright

This paper is Copyright (c) 1994, 1995, 1996
by Christopher Klaus of Internet Security Systems, Inc.

Permission is hereby granted to give away free copies electronically. Electronic dissemination of this information is permitted. All use of the information contained within this document must be referenced. This copyright notice must be maintained in any copy made. If you wish to reprint the whole or any part of this paper in any other medium excluding electronic medium, please ask the author for permission.

Disclaimer

The information within this paper may change without notice. Use of this information constitutes acceptance for use in an AS IS condition. There are NO warranties with regard to this information. In no event shall the author be liable for any damages whatsoever arising out of or in connection with the use or spread of this information. Any use of this information is at the user's own risk.

Address of Author

Please send suggestions, updates, and comments to:

Christopher Klaus <cklaus@iss.net> of Internet Security Systems, Inc. <iss@iss.net>

Back to the Security-Page