xref: /freebsd/contrib/tcp_wrappers/README (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1@(#) README 1.30 97/03/21 19:27:21
2
3This is the 7.6 version of the TCP/IP daemon wrapper package.
4
5Thank you for using this program. If you like it, send me a postcard.
6My postal address is at the bottom of this file.
7
8Read the BLURB file for a brief summary of what is new. The CHANGES
9file gives a complete account of differences with respect to previous
10releases.
11
12Announcements of new releases of this software are posted to Usenet
13(comp.security.unix, comp.unix.admin), to the cert-tools mailing list,
14and to a dedicated mailing list.  You can subscribe to the dedicated
15mailing list by sending an email message to majordomo@wzv.win.tue.nl
16with in the body (not subject):  subscribe tcp-wrappers-announce.
17
18Table of contents
19-----------------
20
21    1 - Introduction
22    2 - Disclaimer
23    3 - Tutorials
24                3.1 - How it works
25                3.2 - Where the logging information goes
26    4 - Features
27                4.1 - Access control
28                4.2 - Host name spoofing
29                4.3 - Host address spoofing
30                4.4 - Client username lookups
31                4.5 - Language extensions
32		4.6 - Multiple ftp/gopher/www archives on one host
33		4.7 - Banner messages
34		4.8 - Sequence number guessing
35    5 - Other works
36                5.1 - Related documents
37                5.2 - Related software
38    6 - Limitations
39                6.1 - Known wrapper limitations
40                6.2 - Known system software bugs
41    7 - Configuration and installation
42                7.1 - Easy configuration and installation
43                7.2 - Advanced configuration and installation
44                7.3 - Daemons with arbitrary path names
45                7.4 - Building and testing the access control rules
46                7.5 - Other applications
47    8 - Acknowledgements
48
491 - Introduction
50----------------
51
52With this package you can monitor and filter incoming requests for the
53SYSTAT, FINGER, FTP, TELNET, RLOGIN, RSH, EXEC, TFTP, TALK, and other
54network services.
55
56It supports both 4.3BSD-style sockets and System V.4-style TLI. Praise
57yourself lucky if you don't know what that means.
58
59The package provides tiny daemon wrapper programs that can be installed
60without any changes to existing software or to existing configuration
61files.  The wrappers report the name of the client host and of the
62requested service; the wrappers do not exchange information with the
63client or server applications, and impose no overhead on the actual
64conversation between the client and server applications.
65
66Optional features are: access control to restrict what systems can
67connect to what network daemons; client user name lookups with the RFC
68931 etc. protocol; additional protection against hosts that pretend to
69have someone elses host name; additional protection against hosts that
70pretend to have someone elses host address.
71
72The programs are very portable. Build procedures are provided for many
73common (and not so common) environments, and guidelines are provided in
74case your environment is not among them.
75
76Requirements are that network daemons are spawned by a super server
77such as the inetd; a 4.3BSD-style socket programming interface and/or
78System V.4-style TLI programming interface; and the availability of a
79syslog(3) library and of a syslogd(8) daemon.  The wrappers should run
80without modification on any system that satisfies these requirements.
81Workarounds have been implemented for several common bugs in systems
82software.
83
84What to do if this is your first encounter with the wrapper programs:
851) read the tutorial sections for an introduction to the relevant
86concepts and terminology; 2) glance over the security feature sections
87in this document; 3) follow the installation instructions (easy or
88advanced). I recommend that you first use the default security feature
89settings.  Run the wrappers for a few days to become familiar with
90their logs, before doing anything drastic such as cutting off access or
91installing booby traps.
92
932 - Disclaimer
94--------------
95
96The wrapper programs rely on source address information obtained from
97network packets. This information is provided by the client host. It is
98not 100 percent reliable, although the wrappers do their best to expose
99forgeries.
100
101In the absence of cryptographic protection of message contents, and of
102cryptographic authentication of message originators, all data from the
103network should be treated with sound scepticism.
104
105THIS RESTRICTION IS BY NO MEANS SPECIFIC TO THE TCP/IP PROTOCOLS.
106
1073 - Tutorials
108-------------
109
110The tutorial sections give a gentle introduction to the operation of
111the wrapper programs, and introduce some of the terminology that is
112used in the remainder of the document: client, server, the inetd and
113syslogd daemons, and their configuration files.
114
1153.1 - How it works
116------------------
117
118Almost every application of the TCP/IP protocols is based on a client-
119server model. For example, when a user invokes the telnet command to
120connect to one of your systems, a telnet server process is executed on
121the target host. The telnet server process connects the user to a login
122process. A few examples of client and server programs are shown in the
123table below:
124
125              client   server    application
126              --------------------------------
127              telnet   telnetd   remote login
128              ftp      ftpd      file transfer
129              finger   fingerd   show users
130
131The usual approach is to run one single daemon process that waits for
132all kinds of incoming network connections. Whenever a connection is
133established, this daemon (usually called inetd) runs the appropriate
134server program and goes back to sleep, waiting for other connections.
135
136The wrapper programs rely on a simple, but powerful mechanism.  Instead
137of directly running the desired server program, the inetd is tricked
138into running a small wrapper program. The wrapper logs the client host
139name or address and performs some additional checks.  When all is well,
140the wrapper executes the desired server program and goes away.
141
142The wrapper programs have no interaction with the client user (or with
143the client process).  Nor do the wrappers interact with the server
144application. This has two major advantages: 1) the wrappers are
145application-independent, so that the same program can protect many
146kinds of network services; 2) no interaction also means that the
147wrappers are invisible from outside (at least for authorized users).
148
149Another important property is that the wrapper programs are active only
150when the initial contact between client and server is established. Once
151a wrapper has done its work there is no overhead on the client-server
152conversation.
153
154The simple mechanism has one major drawback: the wrappers go away after
155the initial contact between client and server processes, so the
156wrappers are of little use with network daemons that service more than
157one client.  The wrappers would only see the first client attempt to
158contact such a server. The NFS mount daemon is a typical example of a
159daemon that services requests from multiple clients. See the section on
160related software for ways to deal with such server programs.
161
162There are two ways to use the wrapper programs:
163
1641) The easy way: move network daemons to some other directory and fill
165   the resulting holes with copies of the wrapper programs.  This
166   approach involves no changes to system configuration files, so there
167   is very little risk of breaking things.
168
1692) The advanced way: leave the network daemons alone and modify the
170   inetd configuration file.  For example, an entry such as:
171
172     tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
173
174   When a tftp request arrives, inetd will run the wrapper program
175   (tcpd) with a process name `in.tftpd'.  This is the name that the
176   wrapper will use when logging the request and when scanning the
177   optional access control tables.  `in.tftpd' is also the name of the
178   server program that the wrapper will attempt to run when all is
179   well.  Any arguments (`-s /tftpboot' in this particular example) are
180   transparently passed on to the server program.
181
182For an account of the history of the wrapper programs, with real-life
183examples, see the section below on related documents.
184
1853.2 - Where the logging information goes
186----------------------------------------
187
188The wrapper programs send their logging information to the syslog
189daemon (syslogd). The disposition of the wrapper logs is determined by
190the syslog configuration file (usually /etc/syslog.conf). Messages are
191written to files, to the console, or are forwarded to a @loghost. Some
192syslogd versions can even forward messages down a |pipeline.
193
194Older syslog implementations (still found on Ultrix systems) only
195support priority levels ranging from 9 (debug-level messages) to 0
196(alerts). All logging information of the specified priority level or
197more urgent is written to the same destination.  In the syslog.conf
198file, priority levels are specified in numerical form.  For example,
199
200    8/usr/spool/mqueue/syslog
201
202causes all messages with priority 8 (informational messages), and
203anything that is more urgent, to be appended to the file
204/usr/spool/mqueue/syslog.
205
206Newer syslog implementations support message classes in addition to
207priority levels.  Examples of message classes are: mail, daemon, auth
208and news. In the syslog.conf file, priority levels are specified with
209symbolic names: debug, info, notice, ..., emerg. For example,
210
211    mail.debug                  /var/log/syslog
212
213causes all messages of class mail with priority debug (or more urgent)
214to be appended to the /var/log/syslog file.
215
216By default, the wrapper logs go to the same place as the transaction
217logs of the sendmail daemon. The disposition can be changed by editing
218the Makefile and/or the syslog.conf file. Send a `kill -HUP' to the
219syslogd after changing its configuration file. Remember that syslogd,
220just like sendmail, insists on one or more TABs between the left-hand
221side and the right-hand side expressions in its configuration file.
222
223Solaris 2.x note: the syslog daemon depends on the m4 macro processor.
224The m4 program is installed as part of the software developer packages.
225
226Trouble shooting note: when the syslogging does not work as expected,
227run the program by hand (`syslogd -d') and see what really happens.
228
2294 - Features
230------------
231
2324.1 - Access control
233--------------------
234
235When compiled with -DHOSTS_ACCESS, the wrapper programs support a
236simple form of access control.  Access can be controlled per host, per
237service, or combinations thereof. The software provides hooks for the
238execution of shell commands when an access control rule fires; this
239feature may be used to install "booby traps".  For details, see the
240hosts_access.5 manual page, which is in `nroff -man' format. A later
241section describes how you can test your access control rules.
242
243Access control can also be used to connect clients to the "right"
244service. What is right may depend on the requested service, the origin
245of the request, and what host address the client connects to. Examples:
246
247(1) A gopher or www database speaks native language when contacted from
248    within the country, otherwise it speaks English.
249
250(2) A service provider offers different ftp, gopher or www services
251    with different internet hostnames from one host (section 4.6).
252
253Access control is enabled by default. It can be turned off by editing
254the Makefile, or by providing no access control tables. The install
255instructions below describe the Makefile editing process.
256
257The hosts_options.5 manual page (`nroff -man' format) documents an
258extended version of the access control language. The extensions are
259disabled by default. See the section below on language extensions.
260
261Later System V implementations provide the Transport Level Interface
262(TLI), a network programming interface that performs functions similar
263to the Berkeley socket programming interface.  Like Berkeley sockets,
264TLI was designed to cover multiple protocols, not just Internet.
265
266When the wrapper discovers that the TLI interface sits on top of a
267TCP/IP or UDP/IP conversation it uses this knowledge to provide the
268same functions as with traditional socket-based applications.  When
269some other protocol is used underneath TLI, the host address will be
270some universal magic cookie that may not even be usable for access
271control purposes.
272
2734.2 - Host name spoofing
274------------------------
275
276With some network applications, such as RSH or RLOGIN, the client host
277name plays an important role in the authentication process. Host name
278information can be reliable when lookups are done from a _local_ hosts
279table, provided that the client IP address can be trusted.
280
281With _distributed_ name services, authentication schemes that rely on
282host names become more problematic. The security of your system now may
283depend on some far-away DNS (domain name server) outside your own
284control.
285
286The wrapper programs verify the client host name that is returned by
287the address->name DNS server, by asking for a second opinion.  To this
288end, the programs look at the name and addresses that are returned by
289the name->address DNS server, which may be an entirely different host.
290
291If any name or address discrepancies are found, or if the second DNS
292opinion is not available, the wrappers assume that one of the two name
293servers is lying, and assume that the client host pretends to have
294someone elses host name.
295
296When compiled with -DPARANOID, the wrappers will always attempt to look
297up and double check the client host name, and will always refuse
298service in case of a host name/address discrepancy.  This is a
299reasonable policy for most systems.
300
301When compiled without -DPARANOID, the wrappers by default still perform
302hostname lookup. You can match hosts with a name/address discrepancy
303with the PARANOID wildcard and decide whether or not to grant service.
304
305Automatic hostname verification is enabled by default. Automatic
306hostname lookups and verification can be turned off by editing the
307Makefile. The configuration and installation section below describes
308the Makefile editing process.
309
3104.3 - Host address spoofing
311---------------------------
312
313While host name spoofing can be found out by asking a second opinion,
314it is much harder to find out that a host claims to have someone elses
315network address. And since host names are deduced from network
316addresses, address spoofing is at least as effective as name spoofing.
317
318The wrapper programs can give additional protection against hosts that
319claim to have an address that lies outside their own network.  For
320example, some far-away host that claims to be a trusted host within
321your own network. Such things are possible even while the impersonated
322system is up and running.
323
324This additional protection is not an invention of my own; it has been
325present for at least five years in the BSD rsh and rlogin daemons.
326Unfortunately, that feature was added *after* 4.3 BSD came out, so that
327very few, if any, UNIX vendors have adopted it.  Our site, and many
328other ones, has been running these enhanced daemons for several years,
329and without any ill effects.
330
331When the wrapper programs are compiled with -DKILL_IP_OPTIONS, the
332programs refuse to service TCP connections with IP source routing
333options. -DKILL_IP_OPTIONS is not needed on modern UNIX systems
334that can stop source-routed traffic in the kernel. Examples are
3354.4BSD derivatives, Solaris 2.x, and Linux. See your system manuals
336for details.
337
338If you are going to use this feature on SunOS 4.1.x you should apply
339patch 100804-03+ or 101790-something depending on your SunOS version.
340Otherwise you may experience "BAD TRAP" and "Data fault" panics when
341the getsockopt() system call is executed after a TCP RESET has been
342received. This is a kernel bug, it is not the fault of the wrappers.
343
344The feature is disabled by default. It can be turned on by editing the
345Makefile.  The configuration and installation section below describes
346the Makefile editing process.
347
348UDP services do not benefit from this additional protection. With UDP,
349all you can be certain of is the network packet's destination address.
350
3514.4 - Client username lookups
352-----------------------------
353
354The protocol proposed in RFC 931 provides a means to obtain the client
355user name from the client host.  The requirement is that the client
356host runs an RFC 931-compliant daemon. The information provided by such
357a daemon is not intended to be used for authentication purposes, but it
358can provide additional information about the owner of a TCP connection.
359
360The RFC 931 protocol has diverged into different directions (IDENT,
361TAP, RFC 1413). To add to the confusion, they all use the same network
362port.  The daemon wrappers implement a common subset of the protocols.
363
364There are some limitations: the number of hosts that run an RFC 931 (or
365compatible) daemon is limited (but growing); client user name lookups
366do not work for datagram (UDP) services. More seriously, client user
367name lookups can cause noticeable delays with connections from non-UNIX
368PCs. Recent PC software seem to have fixed this (for example NCSA
369telnet). The wrappers use a 10-second timeout for RFC931 lookups, to
370accommodate slow networks and slow hosts.
371
372By default, the wrappers will do username lookup only when the access
373control rules require them to do so (via user@host client patterns, see
374the hosts_access.5 manual page) or when the username is needed for
375%<letter> expansions.
376
377You can configure the wrappers to always perform client username
378lookups, by editing the Makefile.  The client username lookup timeout
379period (10 seconds default) can be changed by editing the Makefile. The
380installation sections below describe the Makefile editing process.
381
382On System V with TLI-based network services, client username lookups
383will be possible only when the underlying network protocol is TCP/IP.
384
3854.5 - Language extensions
386-------------------------
387
388The wrappers sport only a limited number of features. This is for a
389good reason: programs that run at high privilege levels must be easy to
390verify. And the smaller a program, the easier to verify. There is,
391however, a provision to add features.
392
393The options.c module provides a framework for language extensions.
394Quite a few extensions have already been implemented; they are
395documented in the hosts_options.5 document, which is in `nroff -man'
396format. Examples: changing the severity level at which a request for
397service is logged; "allow" and "deny" keywords; running a customized
398server instead of the standard one; many others.
399
400The language extensions are not enabled by default because they
401introduce an incompatible change to the access control language
402syntax.  Instructions to enable the extensions are given in the
403Makefile.
404
4054.6 - Multiple ftp/gopher/www archives on one host
406--------------------------------------------------
407
408Imagine one host with multiple internet addresses. These addresses do
409not need to have the same internet hostname. Thus, it is possible to
410offer services with different internet hostnames from just one host.
411
412Service providers can use this to offer organizations a presence on the
413"net" with their own internet hostname, even when those organizations
414aren't connected to the Internet at all.  To the end user it makes no
415difference, because applications use internet hostnames.
416
417There are several ways to assign multiple addresses to one machine.
418The nice way is to take an existing network interface and to assign
419additional internet addresses with the `ifconfig' command. Examples:
420
421    Solaris 2:	ifconfig le0:1 <address> netmask <mask> up
422    4.4 BSD:	ifconfig en0 alias <address> netmask <mask>
423
424On other systems one has to increase the number of network interfaces:
425either with hardware interfaces, or with pseudo interfaces like SLIP or
426PPP.  The interfaces do not need to be attached to anything. They just
427need to be up and to be assigned a suitable internet address and mask.
428
429With the wrapper software, `daemon@host' access control patterns can be
430used to distinguish requests by the network address that they are aimed
431at.  Judicious use of the `twist' option (see the hosts_options.5 file,
432`nroff -man' format) can guide the requests to the right server.  These
433can be servers that live in separate chroot areas, or servers modified
434to take additional context from the command line, or a combination.
435
436Another way is to modify gopher or www listeners so that they bind to
437only one specific network address. Multiple gopher or www servers can
438then be run side by side, each taking requests sent to its respective
439network address.
440
4414.7 - Banner messages
442---------------------
443
444Some sites are required to present an informational message to users
445before they attempt to login.  Banner messages can also be useful when
446denying service:  instead of simply dropping the connection a polite
447explanation is given first. Finally, banners can be used to give your
448system a more personal touch.
449
450The wrapper software provides easy-to-use tools to generate pre-login
451banners for ftp, telnet, rlogin etc. from a single prototype banner
452textfile.  Details on banners and on-the-fly %<letter> expansions are
453given in the hosts_options.5 manual page (`nroff -man' format). An
454example is given in the file Banners.Makefile.
455
456In order to support banner messages the wrappers have to be built with
457language extensions enabled. See the section on language extensions.
458
4594.8 - Sequence number guessing
460------------------------------
461
462Recently, systems came under attack from intruders that exploited a
463well-known weakness in TCP/IP sequence number generators.  This
464weakness allows intruders to impersonate trusted hosts. Break-ins have
465been reported via the rsh service. In fact, any network service can be
466exploited that trusts the client host name or address.
467
468A long-term solution is to stop using network services that trust the
469client host name or address, and to use data encryption instead.
470
471A short-term solution, as outlined in in CERT advisory CA-95:01, is to
472configure network routers so that they discard datagrams from "outside"
473with an "inside" source address. This approach is most fruitful when
474you do not trust any hosts outside your local network.
475
476The IDENT (RFC931 etc.) client username lookup protocol can help to
477detect host impersonation attacks.  Before accepting a client request,
478the wrappers can query the client's IDENT server and find out that the
479client never sent that request.
480
481When the client host provides IDENT service, a negative IDENT lookup
482result (the client matches `UNKNOWN@host') is strong evidence of a host
483impersonation attack.
484
485A positive IDENT lookup result (the client matches `KNOWN@host') is
486less trustworthy.  It is possible for an attacker to spoof both the
487client request and the IDENT lookup connection, although doing so
488should be much harder than spoofing just a client request. Another
489possibility is that the client's IDENT server is lying.
490
491Client username lookups are described in more detail in a previous
492section. Pointers to IDENT daemon software are described in the section
493on related software.
494
4955 - Other works
496---------------
497
4985.1 - Related documents
499-----------------------
500
501The war story behind the tcp wrapper tools is described in:
502
503    W.Z. Venema, "TCP WRAPPER, network monitoring, access control and
504    booby traps", UNIX Security Symposium III Proceedings (Baltimore),
505    September 1992.
506
507    ftp.win.tue.nl:/pub/security/tcp_wrapper.ps.Z (postscript)
508    ftp.win.tue.nl:/pub/security/tcp_wrapper.txt.Z (flat text)
509
510The same cracker is also described in:
511
512    W.R. Cheswick, "An Evening with Berferd, In Which a Cracker is
513    Lured, Endured, and Studied", Proceedings of the Winter USENIX
514    Conference (San Francisco), January 1992.
515
516    research.att.com:/dist/internet_security/berferd.ps
517
518An updated version of the latter paper appeared in:
519
520    W.R. Cheswick, S.M. Bellovin, "Firewalls and Internet Security",
521    Addison-Wesley, 1994.
522
523Discussions on internet firewalls are archived on ftp.greatcircle.com.
524Subscribe to the mailing list by sending a message to
525
526    majordomo@greatcircle.com
527
528With in the body (not subject): subscribe firewalls.
529
5305.2 - Related software
531----------------------
532
533Network daemons etc. with enhanced logging capabilities can generate
534massive amounts of information: our 150+ workstations generate several
535hundred kbytes each day. egrep-based filters can help to suppress some
536of the noise.  A more powerful tool is the Swatch monitoring system by
537Stephen E. Hansen and E. Todd Atkins. Swatch can process log files in
538real time and can associate arbitrary actions with patterns; its
539applications are by no means restricted to security.  Swatch is
540available ftp.stanford.edu, directory /general/security-tools/swatch.
541
542Socks, described in the UNIX Security III proceedings, can be used to
543control network traffic from hosts on an internal network, through a
544firewall host, to the outer world. Socks consists of a daemon that is
545run on the firewall host, and of a library with routines that redirect
546application socket calls through the firewall daemon.  Socks is
547available from s1.gov in /pub/firewalls/socks.tar.Z.
548
549For a modified Socks version by Ying-Da Lee (ylee@syl.dl.nec.com) try
550ftp.nec.com, directory /pub/security/socks.cstc.
551
552Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
553and telnet commands across a firewall. Unlike socks it can be used with
554unmodified client software. Available from ftp.alantec.com, /pub/tcpr.
555
556The TIS firewall toolkit provides a multitude of tools to build your
557own internet firewall system. ftp.tis.com, directory /pub/firewalls.
558
559Versions of rshd and rlogind, modified to report the client user name
560in addition to the client host name, are available for anonymous ftp
561(ftp.win.tue.nl:/pub/security/logdaemon-XX.tar.Z).  These programs are
562drop-in replacements for SunOS 4.x, Ultrix 4.x, SunOS 5.x and HP-UX
5639.x. This archive also contains ftpd/rexecd/login versions that support
564S/Key or SecureNet one-time passwords in addition to traditional UNIX
565reusable passwords.
566
567The securelib shared library by William LeFebvre can be used to control
568access to network daemons that are not run under control of the inetd
569or that serve more than one client, such as the NFS mount daemon that
570runs until the machine goes down.  Available from eecs.nwu.edu, file
571/pub/securelib.tar.
572
573xinetd (posted to comp.sources.unix) is an inetd replacement that
574provides, among others, logging, username lookup and access control.
575However, it does not support the System V TLI services, and involves
576much more source code than the daemon wrapper programs. Available
577from ftp.uu.net, directory /usenet/comp.sources.unix.
578
579netlog from Texas A&M relies on the SunOS 4.x /dev/nit interface to
580passively watch all TCP and UDP network traffic on a network.  The
581current version is on net.tamu.edu in /pub/security/TAMU.
582
583Where shared libraries or router-based packet filtering are not an
584option, an alternative portmap daemon can help to prevent hackers
585from mounting your NFS file systems using the proxy RPC facility.
586ftp.win.tue.nl:/pub/security/portmap-X.shar.Z was tested with SunOS
5874.1.X Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and some version of AIX. The
588protection is less effective than that of the securelib library because
589portmap is mostly a dictionary service.
590
591An rpcbind replacement (the Solaris 2.x moral equivalent of portmap)
592can be found on ftp.win.tue.nl in /pub/security. It prevents hackers
593from mounting your NFS file systems by using the proxy RPC facility.
594
595Source for a portable RFC 931 (TAP, IDENT, RFC 1413) daemon by Peter
596Eriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
597
598Some TCP/IP implementations come without syslog library. Some come with
599the library but have no syslog daemon. A replacement can be found in
600ftp.win.tue.nl:/pub/security/surrogate-syslog.tar.Z.  The fakesyslog
601library that comes with the nntp sources reportedly works well, too.
602
6036 - Limitations
604---------------
605
6066.1 - Known wrapper limitations
607-------------------------------
608
609Many UDP (and rpc/udp) daemons linger around for a while after they
610have serviced a request, just in case another request comes in.  In the
611inetd configuration file these daemons are registered with the `wait'
612option. Only the request that started such a daemon will be seen by the
613wrappers.  Such daemons are better protected with the securelib shared
614library (see: Related software).
615
616The wrappers do not work with RPC services over TCP. These services are
617registered as rpc/tcp in the inetd configuration file. The only non-
618trivial service that is affected by this limitation is rexd, which is
619used by the on(1) command. This is no great loss.  On most systems,
620rexd is less secure than a wildcard in /etc/hosts.equiv.
621
622Some RPC requests (for example: rwall, rup, rusers) appear to come from
623the server host. What happens is that the client broadcasts its request
624to all portmap daemons on its network; each portmap daemon forwards the
625request to a daemon on its own system. As far as the rwall etc.  daemons
626know, the request comes from the local host.
627
628Portmap and RPC (e.g. NIS and NFS) (in)security is a topic in itself.
629See the section in this document on related software.
630
6316.2 - Known system software bugs
632--------------------------------
633
634Workarounds have been implemented for several bugs in system software.
635They are described in the Makefile. Unfortunately, some system software
636bugs cannot be worked around. The result is loss of functionality.
637
638IRIX has so many bugs that it has its own README.IRIX file.
639
640Older ConvexOS versions come with a broken recvfrom(2) implementation.
641This makes it impossible for the daemon wrappers to look up the
642client host address (and hence, the name) in case of UDP requests.
643A patch is available for ConvexOS 10.1; later releases should be OK.
644
645With early Solaris (SunOS 5) versions, the syslog daemon will leave
646behind zombie processes when writing to logged-in users.  Workaround:
647increase the syslogd threshold for logging to users, or reduce the
648wrapper's logging severity.
649
650On some systems, the optional RFC 931 etc. client username lookups may
651trigger a kernel bug.  When a client host connects to your system, and
652the RFC 931 connection from your system to that client is rejected by a
653router, your kernel may drop all connections with that client.  This is
654not a bug in the wrapper programs: complain to your vendor, and don't
655enable client user name lookups until the bug has been fixed.
656
657Reportedly, SunOS 4.1.1, Next 2.0a, ISC 3.0 with TCP 1.3, and AIX 3.2.2
658and later are OK.
659
660Sony News/OS 4.51, HP-UX 8-something and Ultrix 4.3 still have the bug.
661Reportedly, a fix for Ultrix is available (CXO-8919).
662
663The following procedure can be used (from outside the tue.nl domain) to
664find out if your kernel has the bug. From the system under test, do:
665
666        % ftp 131.155.70.19
667
668This command attempts to make an ftp connection to our anonymous ftp
669server (ftp.win.tue.nl).  When the connection has been established, run
670the following command from the same system under test, while keeping
671the ftp connection open:
672
673        % telnet 131.155.70.19 111
674
675Do not forget the `111' at the end of the command. This telnet command
676attempts to connect to our portmap process.  The telnet command should
677fail with:  "host not reachable", or with a timeout error. If your ftp
678connection gets messed up, you have the bug. If the telnet command does
679not fail, please let me know a.s.a.p.!
680
681For those who care, the bug is that the BSD kernel code was not careful
682enough with incoming ICMP UNREACHABLE control messages (it ignored the
683local and remote port numbers, and therefore zapped *all* connections
684with the remote system). The bug is still present in the BSD NET/1
685source release (1989) but apparently has been fixed in BSD NET/2 (1991).
686
6877 - Configuration and installation
688----------------------------------
689
6907.1 - Easy configuration and installation
691-----------------------------------------
692
693The "easy" recipe requires no changes to existing software or
694configuration files.  Basically, you move the daemons that you want to
695protect to a different directory and plug the resulting holes with
696copies of the wrapper programs.
697
698If you don't run Ultrix, you won't need the miscd wrapper program.  The
699miscd daemon implements among others the SYSTAT service, which produces
700the same output as the WHO command.
701
702Type `make' and follow the instructions.  The Makefile comes with
703ready-to-use templates for many common UNIX implementations (sun,
704ultrix, hp-ux, aix, irix,...).
705
706IRIX has so many bugs that it has its own README.IRIX file.
707
708When the `make' succeeds the result is five executables (six in case of
709Ultrix).
710
711You can use the `tcpdchk' program to identify the most common problems
712in your wrapper and inetd configuration files.
713
714With the `tcpdmatch' program you can examine how the wrapper would
715react to specific requests for service.
716
717The `safe_finger' command should be used when you implement booby
718traps:  it gives better protection against nasty stuff that remote
719hosts may do in response to your finger probes.
720
721The `try-from' program tests the host and username lookup code.  Run it
722from a remote shell command (`rsh host /some/where/try-from') and it
723should be able to figure out from what system it is being called.
724
725The tcpd program can be used to monitor the telnet, finger, ftp, exec,
726rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
727a one-to-one mapping onto executable files.
728
729The tcpd program can also be used for services that are marked as
730rpc/udp in the inetd configuration file, but not for rpc/tcp services
731such as rexd.  You probably do not want to run rexd anyway. On most
732systems it is even less secure than a wildcard in /etc/hosts.equiv.
733
734With System V.4-style systems, the tcpd program can also handle TLI
735services. When TCP/IP or UDP/IP is used underneath TLI, tcpd provides
736the same functions as with socket-based applications. When some other
737protocol is used underneath TLI, functionality will be limited (no
738client username lookups, weird network address formats).
739
740Decide which services you want to monitor. Move the corresponding
741vendor-provided daemon programs to the location specified by the
742REAL_DAEMON_DIR constant in the Makefile, and fill the holes with
743copies of the tcpd program. That is, one copy of (or link to) the tcpd
744program for each service that you want to monitor. For example, to
745monitor the use of your finger service:
746
747    # mkdir REAL_DAEMON_DIR
748    # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
749    # cp tcpd /usr/etc/in.fingerd
750
751The example applies to SunOS 4. With other UNIX implementations the
752network daemons live in /usr/libexec, /usr/sbin or in /etc, or have no
753"in." prefix to their names, but you get the idea.
754
755File protections: the wrapper, all files used by the wrapper, and all
756directories in the path leading to those files, should be accessible
757but not writable for unprivileged users (mode 755 or mode 555). Do not
758install the wrapper set-uid.
759
760Ultrix only:  If you want to monitor the SYSTAT service, move the
761vendor-provided miscd daemon to the location specified by the
762REAL_DAEMON_DIR macro in the Makefile, and install the miscd wrapper
763at the original miscd location.
764
765In the absence of any access-control tables, the daemon wrappers
766will just maintain a record of network connections made to your system.
767
7687.2 - Advanced configuration and installation
769---------------------------------------------
770
771The advanced recipe leaves your daemon executables alone, but involves
772simple modifications to the inetd configuration file.
773
774Type `make' and follow the instructions.  The Makefile comes with
775ready-to-use templates for many common UNIX implementations (sun,
776ultrix, hp-ux, aix, irix, ...).
777
778IRIX users should read the warnings in the README.IRIX file first.
779
780When the `make' succeeds the result is five executables (six in case of
781Ultrix).
782
783You can use the `tcpdchk' program to identify the most common problems
784in your wrapper and inetd configuration files.
785
786With the `tcpdmatch' program you can examine how the wrapper would
787react to specific requests for service.
788
789The `try-from' program tests the host and username lookup code.  Run it
790from a remote shell command (`rsh host /some/where/try-from') and it
791should be able to figure out from what system it is being called.
792
793The `safe_finger' command should be used when you implement a booby
794trap:  it gives better protection against nasty stuff that remote hosts
795may do in response to your finger probes.
796
797The tcpd program can be used to monitor the telnet, finger, ftp, exec,
798rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
799a one-to-one mapping onto executable files.
800
801With System V.4-style systems, the tcpd program can also handle TLI
802services. When TCP/IP or UDP/IP is used underneath TLI, tcpd provides
803the same functions as with socket-based applications. When some other
804protocol is used underneath TLI, functionality will be limited (no
805client username lookups, weird network address formats).
806
807The tcpd program can also be used for services that are marked as
808rpc/udp in the inetd configuration file, but not for rpc/tcp services
809such as rexd.  You probably do not want to run rexd anyway. On most
810systems it is even less secure than a wildcard in /etc/hosts.equiv.
811
812Install the tcpd command in a suitable place. Apollo UNIX users will
813want to install it under a different name because the name "tcpd" is
814already taken; a suitable name would be "frontd".
815
816File protections: the wrapper, all files used by the wrapper, and all
817directories in the path leading to those files, should be accessible
818but not writable for unprivileged users (mode 755 or mode 555). Do not
819install the wrapper set-uid.
820
821Then perform the following edits on the inetd configuration file
822(usually /etc/inetd.conf or /etc/inet/inetd.conf):
823
824    finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd
825                                            ^^^^^^^^^^^^^^^^^^^
826becomes:
827
828    finger  stream  tcp     nowait  nobody  /usr/etc/tcpd           in.fingerd
829                                            ^^^^^^^^^^^^^
830Send a `kill -HUP' to the inetd process to make the change effective.
831Some IRIX inetd implementations require that you first disable the
832finger service (comment out the finger service and `kill -HUP' the
833inetd) before you can turn on the modified version. Sending a HUP
834twice seems to work just as well for IRIX 5.3, 6.0, 6.0.1 and 6.1.
835
836AIX note: you may have to execute the `inetimp' command after changing
837the inetd configuration file.
838
839The example applies to SunOS 4. With other UNIX implementations the
840network daemons live in /usr/libexec, /usr/sbin, or /etc, the network
841daemons have no "in." prefix to their names, or the username field in
842the inetd configuration file may be missing.
843
844When the finger service works as expected you can perform similar
845changes for other network services. Do not forget the `kill -HUP'.
846
847The miscd daemon that comes with Ultrix implements several network
848services. It decides what to do by looking at its process name. One of
849the services is systat, which is a kind of limited finger service.  If
850you want to monitor the systat service, install the miscd wrapper in a
851suitable place and update the inetd configuration file:
852
853    systat  stream  tcp     nowait  /suitable/place/miscd      systatd
854
855Ultrix 4.3 allows you to specify a user id under which the daemon will
856be executed. This feature is not documented in the manual pages.  Thus,
857the example would become:
858
859    systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatd
860
861Older Ultrix systems still run all their network daemons as root.
862
863In the absence of any access-control tables, the daemon wrappers
864will just maintain a record of network connections made to your system.
865
8667.3 - Daemons with arbitrary path names
867---------------------------------------
868
869The above tcpd examples work fine with network daemons that live in a
870common directory, but sometimes that is not practical. Having soft
871links all over your file system is not a clean solution, either.
872
873Instead you can specify, in the inetd configuration file, an absolute
874path name for the daemon process name.  For example,
875
876    ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkd
877
878When the daemon process name is an absolute path name, tcpd ignores the
879value of the REAL_DAEMON_DIR constant, and uses the last path component
880of the daemon process name for logging and for access control.
881
8827.4 - Building and testing the access control rules
883---------------------------------------------------
884
885In order to support access control the wrappers must be compiled with
886the -DHOSTS_ACCESS option. The access control policy is given in the
887form of two tables (default: /etc/hosts.allow and /etc/hosts.deny).
888Access control is disabled when there are no access control tables, or
889when the tables are empty.
890
891If you haven't used the wrappers before I recommend that you first run
892them a couple of days without any access control restrictions. The
893logfile records should give you an idea of the process names and of the
894host names that you will have to build into your access control rules.
895
896The syntax of the access control rules is documented in the file
897hosts_access.5, which is in `nroff -man' format. This is a lengthy
898document, and no-one expects you to read it right away from beginning
899to end.  Instead, after reading the introductory section, skip to the
900examples at the end so that you get a general idea of the language.
901Then you can appreciate the detailed reference sections near the
902beginning of the document.
903
904The examples in the hosts_access.5 document (`nroff -man' format) show
905two specific types of access control policy:  1) mostly closed (only
906permitting access from a limited number of systems) and 2) mostly open
907(permitting access from everyone except a limited number of trouble
908makers). You will have to choose what model suits your situation best.
909Implementing a mixed policy should not be overly difficult either.
910
911Optional extensions to the access control language are described in the
912hosts_options.5 document (`nroff -man' format).
913
914The `tcpdchk' program examines all rules in your access control files
915and reports any problems it can find. `tcpdchk -v' writes to standard
916output a pretty-printed list of all rules. `tcpdchk -d' examines the
917hosts.access and hosts.allow files in the current directory. This
918program is described in the tcpdchk.8 document (`nroff -man' format).
919
920The `tcpdmatch' command can be used to try out your local access
921control files.  The command syntax is:
922
923    tcpdmatch process_name hostname (e.g.: tcpdmatch in.tftpd localhost)
924
925    tcpdmatch process_name address  (e.g.: tcpdmatch in.tftpd 127.0.0.1)
926
927This way you can simulate what decisions will be made, and what actions
928will be taken, when hosts connect to your own system. The program is
929described in the tcpdmatch.8 document (`nroff -man' format).
930
931Note 1: `tcpdmatch -d' will look for hosts.{allow,deny} tables in the
932current working directory. This is useful for testing new rules without
933bothering your users.
934
935Note 2: you cannot use the `tcpdmatch' command to simulate what happens
936when the local system connects to other hosts.
937
938In order to find out what process name to use, just use the service and
939watch the process name that shows up in the logfile.  Alternatively,
940you can look up the name from the inetd configuration file. Coming back
941to the tftp example in the tutorial section above:
942
943    tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
944
945This entry causes the inetd to run the wrapper program (tcpd) with a
946process name `in.tftpd'.  This is the name that the wrapper will use
947when scanning the access control tables. Therefore, `in.tftpd' is the
948process name that should be given to the `tcpdmatch' command. On your
949system the actual inetd.conf entry may differ (tftpd instead of
950in.tftpd, and no `root' field), but you get the idea.
951
952When you specify a host name, the `tcpdmatch' program will use both the
953host name and address. This way you can simulate the most common case
954where the wrappers know both the host address and the host name.  The
955`tcpdmatch' program will iterate over all addresses that it can find
956for the given host name.
957
958When you specify a host address instead of a host name, the `tcpdmatch'
959program will pretend that the host name is unknown, so that you can
960simulate what happens when the wrapper is unable to look up the client
961host name.
962
9637.5 - Other applications
964------------------------
965
966The access control routines can easily be integrated with other
967programs.  The hosts_access.3 manual page (`nroff -man' format)
968describes the external interface of the libwrap.a library.
969
970The tcpd program can even be used to control access to the mail
971service.  This can be useful when you suspect that someone is trying
972out some obscure sendmail bug, or when a remote site is misconfigured
973and keeps hammering your mail daemon.
974
975In that case, sendmail should not be run as a stand-alone network
976listener, but it should be registered in the inetd configuration file.
977For example:
978
979    smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bs
980
981You will still need to run one sendmail background process to handle
982queued-up outgoing mail. A command like:
983
984    /usr/lib/sendmail -q15m
985
986(no `-bd' flag) should take care of that. You cannot really prevent
987people from posting forged mail this way, because there are many
988unprotected smtp daemons on the network.
989
9908 - Acknowledgements
991--------------------
992
993Many people contributed to the evolution of the programs, by asking
994inspiring questions, by suggesting features or bugfixes, or by
995submitting source code.  Nevertheless, all mistakes and bugs in the
996wrappers are my own.
997
998Thanks to Brendan Kehoe (cs.widener.edu), Heimir Sverrisson (hafro.is)
999and Dan Bernstein (kramden.acf.nyu.edu) for feedback on an early
1000release of this product.  The host name/address check was suggested by
1001John Kimball (src.honeywell.com).  Apollo's UNIX environment has some
1002peculiar quirks: Willem-Jan Withagen (eb.ele.tue.nl), Pieter
1003Schoenmakers (es.ele.tue.nl) and Charles S. Fuller (wccs.psc.edu)
1004provided assistance.  Hal R.  Brand (addvax.llnl.gov) told me how to
1005get the client IP address in case of datagram-oriented services, and
1006suggested the optional shell command feature.  Shabbir Safdar
1007(mentor.cc.purdue.edu) provided a first version of a much-needed manual
1008page.  Granville Boman Goza, IV (sei.cmu.edu) suggested to use the
1009client IP address even when the host name is available.  Casper H.S.
1010Dik (fwi.uva.nl) provided additional insight into DNS spoofing
1011techniques.  The bogus daemon feature was inspired by code from Andrew
1012Macpherson (BNR Europe Ltd).  Steve Bellovin (research.att.com)
1013confirmed some of my suspicions about the darker sides of TCP/IP
1014insecurity. Risks of automated fingers were pointed out by Borja Marcos
1015(we.lc.ehu.es). Brad Plecs (jhuspo.ca.jhu.edu) was kind enough to try
1016my early TLI code and to work out how DG/UX differs from Solaris.
1017
1018John P.  Rouillard (cs.umb.edu) deserves special mention for his
1019persistent, but constructive, nagging about wrong or missing things,
1020and for trying out and discussing embryonic code or ideas.
1021
1022Last but not least, Howard Chu (hanauma.jpl.nasa.gov), Darren Reed
1023(coombs.anu.edu.au), Icarus Sparry (gdr.bath.ac.uk), Scott Schwartz
1024(cs.psu.edu), John A. Kunze (violet.berkeley.edu), Daniel Len Schales
1025(engr.latech.edu), Chris Turbeville (cse.uta.edu), Paul Kranenburg
1026(cs.few.eur.nl), Marc Boucher (cam.org), Dave Mitchell
1027(dcs.shef.ac.uk), Andrew Maffei, Adrian van Bloois, Rop Gonggrijp, John
1028C. Wingenbach, Everett F. Batey  and many, many others provided fixes,
1029code fragments, or ideas for improvements.
1030
1031        Wietse Venema (wietse@wzv.win.tue.nl)
1032        Department of Mathematics and Computing Science
1033        Eindhoven University of Technology
1034        P.O. Box 513
1035        5600 MB Eindhoven
1036        The Netherlands
1037
1038	Currently visiting IBM T.J. Watson Research, Hawthorne NY, USA.
1039