home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NETKIT-A.06 / NETKIT-A / NetKit-A-0.06 / tcp_wrapper-6.3 / README < prev    next >
Encoding:
Text File  |  1994-03-27  |  38.4 KB  |  862 lines

  1. @(#) README 1.21 94/03/23 17:47:16
  2.  
  3. This is the 6.3 version of the TCP/IP daemon wrapper package.
  4.  
  5. Table of contents
  6. -----------------
  7.  
  8.     1 - Introduction
  9.     2 - Disclaimer
  10.     3 - Tutorials
  11.         3.1 - How it works
  12.         3.2 - Where the logging information goes
  13.     4 - Features
  14.         4.1 - Access control
  15.         4.2 - Host name spoofing
  16.         4.3 - Host address spoofing
  17.         4.4 - Remote username lookups
  18.         4.5 - Language extensions
  19.     5 - Other works
  20.         5.1 - Related documents
  21.         5.2 - Related software
  22.     6 - Limitations
  23.         6.1 - Known wrapper limitations
  24.         6.2 - Known system software bugs
  25.     7 - Configuration and installation
  26.         7.1 - Easy configuration and installation
  27.         7.2 - Advanced configuration and installation
  28.         7.3 - Daemons with arbitrary path names
  29.         7.4 - Building and testing the access control rules
  30.         7.5 - Other applications
  31.     8 - Acknowledgements
  32.  
  33. 1 - Introduction
  34. ----------------
  35.  
  36. With this package you can monitor and filter incoming requests for the
  37. SYSTAT, FINGER, FTP, TELNET, RLOGIN, RSH, EXEC, TFTP, TALK, and other
  38. network services.
  39.  
  40. It supports both 4.3BSD-style sockets and System V.4-style TLI. Praise
  41. yourself lucky if you don't know what that means.
  42.  
  43. The package provides tiny daemon wrapper programs that can be installed
  44. without any changes to existing software or to existing configuration
  45. files.  The wrappers report the name of the remote host and of the
  46. requested service; the wrappers do not exchange information with the
  47. remote client process, and impose no overhead on the actual
  48. communication between the client and server applications.
  49.  
  50. Optional features are: access control to restrict what systems can
  51. connect to your network daemons; remote user name lookups with the RFC
  52. 931 protocol; additional protection against hosts that pretend to have
  53. someone elses host name; additional protection against hosts that
  54. pretend to have someone elses host address.
  55.  
  56. Early versions of the programs were tested with Ultrix >= 2.2, with
  57. SunOS >= 3.4 and ISC 2.2. Later versions have been installed on a wide
  58. variety of platforms such as SunOS 4.x and 5.x, Ultrix 3.x and 4.x, DEC
  59. OSF/1 T1.2-2, HP-UX 8.x, AIX 3.1.5 up to 3.2.4, Apollo SR10.3.5, Sony,
  60. NeXT, SCO UNIX, DG/UX, Cray, Dynix, and an unknown number of other ones.
  61.  
  62. Requirements are that the network daemons are spawned by a super server
  63. such as the inetd; a 4.3BSD-style socket programming interface and/or
  64. System V.4-style TLI programming interface; and the availability of a
  65. syslog(3) library and of a syslogd(8) daemon.  The wrappers should run
  66. without modification on any system that satisfies these requirements.
  67. Workarounds have been implemented for several common bugs in systems
  68. software.
  69.  
  70. What to do if this is your first encounter with the wrapper programs:
  71. 1) read the tutorial sections for an introduction to the relevant
  72. concepts and terminology; 2) glance over the security feature sections
  73. in this document; 3) follow the installation instructions (easy or
  74. advanced). I recommend that you first use the default security feature
  75. settings.  Run the wrappers for a few days to become familiar with
  76. their logs, before doing anything drastic such as cutting off access or
  77. installing booby traps.
  78.  
  79. 2 - Disclaimer
  80. --------------
  81.  
  82. The wrapper programs rely on source address information obtained from
  83. network packets. Such information is not 100 percent reliable, although
  84. the wrappers do their best to expose forgeries.
  85.  
  86. In the absence of cryptographic protection of message contents, and of
  87. cryptographic authentication of message originators, all data from the
  88. network should be treated with sound scepticism.
  89.  
  90. THIS RESTRICTION IS BY NO MEANS SPECIFIC TO THE TCP/IP PROTOCOLS.
  91.  
  92. 3 - Tutorials
  93. -------------
  94.  
  95. The tutorial sections give a gentle introduction to the operation of
  96. the wrapper programs, and introduce some of the terminology that is
  97. used in the remainder of the document: client, server, the inetd and
  98. syslogd daemons, and their configuration files.
  99.  
  100. 3.1 - How it works
  101. ------------------
  102.  
  103. Almost every application of the TCP/IP protocols is based on a client-
  104. server model. For example, when a user invokes the telnet command to
  105. connect to one of your systems, a telnet server process is executed on
  106. the target host. The telnet server process connects the user to a login
  107. process. A few examples of client and server programs are shown in the
  108. table below:
  109.  
  110.               client   server    application
  111.               --------------------------------
  112.               telnet   telnetd   remote login
  113.               ftp      ftpd      file transfer
  114.               finger   fingerd   show users
  115.  
  116. The usual approach is to run one single daemon process that waits for
  117. all kinds of incoming network connections. Whenever a connection is
  118. established, this daemon (usually called inetd) runs the appropriate
  119. server program and goes back to sleep, waiting for other connections.
  120.  
  121. The wrapper programs rely on a simple, but powerful mechanism.  Instead
  122. of directly running the desired server program, the inetd is tricked
  123. into running a small wrapper program. The wrapper logs the remote host
  124. name or address and performs some additional checks.  When all is well,
  125. the wrapper executes the desired server program and goes away.
  126.  
  127. The wrapper programs have no interaction with the remote user (or
  128. client process).  This has two major advantages: 1) the wrappers are
  129. application-independent, so that the same program can protect many
  130. kinds of network services; 2) no interaction also means that the
  131. wrappers are invisible from outside (at least for authorized users).
  132.  
  133. Another important property is that the wrapper programs are active only
  134. when the initial contact between client and server is established. Once
  135. a wrapper has done its work there is no overhead on the client-server
  136. communication.
  137.  
  138. The simple mechanism has one major drawback: since the wrappers go away
  139. after the initial contact between client and server processes, the
  140. wrappers are of little use with network daemons that service more than
  141. one client.  The wrappers would only see the first client attempt to
  142. contact such a server. The NFS mount daemon is a typical example of a
  143. daemon that services requests from multiple clients. See the section on
  144. related software for ways to deal with such programs.
  145.  
  146. There are two ways to use the wrapper programs:
  147.  
  148. 1) The easy way: move network daemons to some other directory and fill
  149.    the resulting holes with copies of the wrapper programs.  This
  150.    approach involves no changes to system configuration files, so there
  151.    is very little risk of breaking things.
  152.  
  153. 2) The advanced way: leave the network daemons alone and modify the
  154.    inetd configuration file.  For example, an entry such as:
  155.  
  156.      tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  157.  
  158.    When a tftp request arrives, inetd will run the wrapper program
  159.    (tcpd) with a process name `in.tftpd'.  This is the name that the
  160.    wrapper will use when logging the request and when scanning the
  161.    optional access control tables.  `in.tftpd' is also the name of the
  162.    server program that the wrapper will attempt to run when all is
  163.    well.  Any arguments (`-s /tftpboot' in this particular example) are
  164.    transparently passed on to the server program.
  165.  
  166. For an account of the history of the wrapper programs, with real-life
  167. examples, see the section below on related documents.
  168.  
  169. 3.2 - Where the logging information goes
  170. ----------------------------------------
  171.  
  172. The wrapper programs send their logging information to the syslog
  173. daemon (syslogd). The disposition of the wrapper logs is determined by
  174. the syslog configuration file (usually /etc/syslog.conf). Messages are
  175. written to files, to the console, or are forwarded to a @loghost.
  176.  
  177. Older syslog implementations (still found on Ultrix systems) only
  178. support priority levels ranging from 9 (debug-level messages) to 0
  179. (alerts). All logging information of the same priority level (or more
  180. urgent) is written to the same destination.  In the syslog.conf file,
  181. priority levels are specified in numerical form.  For example,
  182.  
  183.     8/usr/spool/mqueue/syslog
  184.  
  185. causes all messages with priority 8 (informational messages), and
  186. anything that is more urgent, to be appended to the file
  187. /usr/spool/mqueue/syslog.
  188.  
  189. Newer syslog implementations support message classes in addition to
  190. priority levels.  Examples of message classes are: mail, daemon, auth
  191. and news. In the syslog.conf file, priority levels are specified with
  192. symbolic names: debug, info, notice, ..., emerg. For example,
  193.  
  194.     mail.debug            /var/log/syslog
  195.  
  196. causes all messages of class mail with priority debug (or more urgent)
  197. to be appended to the /var/log/syslog file.
  198.  
  199. By default, the wrapper logs go to the same place as the transaction
  200. logs of the sendmail daemon. The disposition can be changed by editing
  201. the Makefile and/or the syslog.conf file. Send a `kill -HUP' to the
  202. syslogd after changing its configuration file. Remember that syslogd,
  203. just like sendmail, insists on one or more TABs between the left-hand
  204. side and the right-hand side expressions in its configuration file.
  205.  
  206. 4 - Features
  207. ------------
  208.  
  209. 4.1 - Access control
  210. --------------------
  211.  
  212. When compiled with -DHOSTS_ACCESS, the wrapper programs support a
  213. simple form of access control.  Access can be controlled per host, per
  214. service, or combinations thereof. The software provides hooks for the
  215. execution of shell commands when an access control rule fires; this
  216. feature may be used to install "booby traps".  For details, see the
  217. hosts_access.5 manual page, which is in `nroff -man' format. A later
  218. section describes how you can test your access control rules. The
  219. hosts_options.5 manual page describes additional features that
  220. are turned off by default.
  221.  
  222. Access control is enabled by default. It can be turned off by editing
  223. the Makefile, or by providing no access control tables. The install
  224. instructions below describe the Makefile editing process.
  225.  
  226. On System V when TCP/IP or UDP/IP is used underneath TLI, the wrapper
  227. programs provide the same functions as with socket-based applications.
  228. When some other protocol is used underneath TLI, the host address will
  229. be some universal magic cookie that may not be usable for access
  230. control purposes.
  231.  
  232. 4.2 - Host name spoofing
  233. ------------------------
  234.  
  235. With some network applications, such as RSH or RLOGIN, the remote host
  236. name plays an important role in the authentication process. Host name
  237. information can be reliable when lookups are done from a _local_ hosts
  238. table, provided that the client IP address can be trusted.
  239.  
  240. With _distributed_ name services, authentication schemes that rely on
  241. host names become more problematic. The security of your system now may
  242. depend on some far-away DNS (domain name server) outside your own
  243. control. 
  244.  
  245. The wrapper programs verify the remote host name that is returned by
  246. the address->name DNS server, by asking for a second opinion.  To this
  247. end, the programs look at the name and addresses that are returned by
  248. the name->address DNS server. 
  249.  
  250. If any name or address discrepancies are found, or if the second DNS
  251. opinion is not available, the wrappers assume that one of the two name
  252. servers is lying, and assume that the client host pretends to have
  253. someone elses host name.
  254.  
  255. When the sources are compiled with -DPARANOID, the wrappers will drop
  256. the connection in case of a host name/address discrepancy. 
  257.  
  258. When the sources are not compiled with -DPARANOID, the wrappers just
  259. pretend that an offending host name is unknown.
  260.  
  261. Paranoid mode is enabled by default. It can be turned off by editing
  262. the Makefile. The configuration and installation below describes the
  263. Makefile editing process.
  264.  
  265. 4.3 - Host address spoofing
  266. ---------------------------
  267.  
  268. While host name spoofing can be found out by asking a second opinion,
  269. it is much harder to find out that a host claims to have someone elses
  270. network address. And since host names are deduced from network
  271. addresses, address spoofing is at least as effective as name spoofing.
  272.  
  273. The wrapper programs can give additional protection against hosts that
  274. claim to have an address that lies outside their own network.  For
  275. example, some far-away host that claims to be a trusted host within
  276. your own network. Such things are possible even while the impersonated
  277. system is up and running.
  278.  
  279. This additional protection is not an invention of my own; it has been
  280. present for at least five years in the BSD rsh and rlogin daemons.
  281. Unfortunately, that feature was added *after* 4.3 BSD came out, so that
  282. very few, if any, UNIX vendors have adopted it.  Our site, and many
  283. other ones, has been running these enhanced daemons for several years,
  284. and without any ill effects.
  285.  
  286. When the programs are compiled with -DKILL_IP_OPTIONS, source routing
  287. will be disabled for all TCP connections that are handled by the
  288. wrapper programs.
  289.  
  290. If you are going to use this feature on SunOS 4.1.x you should apply
  291. patch 100804-03 or later. Otherwise you may experience "BAD TRAP" and
  292. "Data fault" panics when the getsockopt() system call is executed after
  293. a TCP RESET has been received.
  294.  
  295. The feature is disabled by default. It can be turned on by editing the
  296. Makefile.  The configuration and installation section below describes
  297. the Makefile editing process.
  298.  
  299. UDP services do not benefit from this additional protection. With UDP,
  300. all you can be certain of is the network packet's destination address.
  301.  
  302. 4.4 - Remote username lookups
  303. -----------------------------
  304.  
  305. The protocol proposed in RFC 931 provides a means to get the remote
  306. user name from the client host.  The requirement is that the client
  307. host runs an RFC 931-compliant daemon. The information provided by such
  308. a daemon is not intended to be used for authentication purposes, but it
  309. can provide additional information about the owner of a TCP connection.
  310.  
  311. There are some limitations: the number of hosts that run an RFC 931 (or
  312. compatible) daemon is small (but growing); remote user name lookups do
  313. not work for datagram (UDP) connections. More seriously, remote user
  314. name lookups can cause noticeable delays with connections from non-UNIX
  315. PCs. The wrappers use a 10-second timeout for RFC931 lookups, to
  316. accommodate slow networks and slow hosts.
  317.  
  318. By default, the wrappers will do username lookup only when the access
  319. control rules require them to do so.  The wrappers can be configured to
  320. always perform remote username lookups by editing the Makefile.  The
  321. remote username lookup timeout period (10 seconds default) can also be
  322. changed by editing the Makefile. The installation sections below
  323. describe the Makefile editing process.
  324.  
  325. The RFC 931 protocol has diverged into different directions (IDENT and
  326. TAP). To add to the confusion, both protocols use the same network
  327. port.  The daemon wrappers implement a common subset of the protocols.
  328.  
  329. On System V with TLI-based network services, remote username lookups
  330. will be possible only when the underlying network protocol is TCP/IP.
  331.  
  332. 4.5 - Language extensions
  333. -------------------------
  334.  
  335. The wrappers sport only a limited number of features. This is for a
  336. good reason: programs that run at high privilege levels must be easy to
  337. verify. And the smaller a program, the easier to verify. There is,
  338. however, a provision to add features.
  339.  
  340. The options.c module provides a framework for language extensions.
  341. Quite a few extensions have already been implemented; they are
  342. documented in the hosts_options.5 document, which is in `nroff -man'
  343. format. Examples: changing the severity level at which a request for
  344. service is logged; "allow" and "deny" keywords; running a customized
  345. server instead of the standard one; many others.
  346.  
  347. The language extensions are not enabled by default because they
  348. introduce an incompatible change to the access control language
  349. syntax.  Instructions to enable the extensions are given in the
  350. Makefile.
  351.  
  352. 5 - Other works
  353. ---------------
  354.  
  355. 5.1 - Related documents
  356. -----------------------
  357.  
  358. The war story behind the wrapper tools is described in:
  359.  
  360.     W.Z. Venema, "TCP WRAPPER, network monitoring, access control and
  361.     booby traps", UNIX Security Symposium III Proceedings (Baltimore),
  362.     September 1992. 
  363.  
  364.     ftp.win.tue.nl:/pub/security/tcp_wrapper.ps.Z (postscript)
  365.     ftp.win.tue.nl:/pub/security/tcp_wrapper.txt.Z (flat text)
  366.  
  367. The same cracker is also described in:
  368.  
  369.     W.R. Cheswick, "An Evening with Berferd, In Which a Cracker is
  370.     Lured, Endured, and Studied", Proceedings of the Winter USENIX
  371.     Conference (San Francisco), January 1992.
  372.  
  373.     research.att.com:/dist/internet_security/berferd.ps
  374.  
  375. Discussions on internet firewalls are archived on ftp.greatcircle.com.
  376. Subscribe to the mailing list by sending a message to 
  377.  
  378.     majordomo@greatcircle.com
  379.  
  380. With in the body (not subject): subscribe firewalls.
  381.  
  382. 5.2 - Related software
  383. ----------------------
  384.  
  385. Network daemons etc. with enhanced logging capabilities can generate
  386. massive amounts of information: our 100+ workstations generate several
  387. hundred kbytes each day. egrep-based filters can help to suppress some
  388. of the noise.  A more powerful tool is the Swatch monitoring system by
  389. Stephen E. Hansen and E. Todd Atkins. Swatch can process log files in
  390. real time and can associate arbitrary actions with patterns; its
  391. applications are by no means restricted to security.  Swatch is
  392. available from sierra.stanford.edu, directory /pub/sources.
  393.  
  394. Socks, described in the UNIX Security III proceedings, can be used to
  395. control network traffic from hosts on an internal network, through a
  396. firewall host, to the outer world. Socks consists of a daemon that is
  397. run on the firewall host, and of a library with routines that redirect
  398. application socket calls through the firewall daemon.  Socks is
  399. available from s1.gov in /pub/firewalls/socks.tar.Z.
  400.  
  401. For a modified Socks version by Ying-Da Lee (ylee@syl.dl.nec.com) try
  402. ftp.nec.com, directory /pub/security/socks.cstc.
  403.  
  404. Tcpr is a set of perl scripts by Paul Ziemba that enable you to run ftp
  405. and telnet commands across a firewall. Unlike socks it can be used with
  406. unmodified client software. Available from ftp.alantec.com, /pub/tcpr.
  407.  
  408. Versions of rshd and rlogind, modified to report the remote user name
  409. in addition to the remote host name, are available for anonymous ftp
  410. (ftp.win.tue.nl:/pub/security/logdaemon-XX.tar.Z).  These programs are
  411. drop-in replacements for SunOS 4.x, Ultrix 4.x, and SunOS 5.x. This
  412. archive also contains ftpd/rexecd/login versions that support S/Key
  413. one-time passwords (tested with SunOS [45] and 44BSD).
  414.  
  415. The securelib shared library by William LeFebvre can be used to control
  416. access to network daemons that are not run under control of the inetd
  417. or that serve more than one client, such as the NFS mount daemon that
  418. runs until the machine goes down.  Available from eecs.nwu.edu, file
  419. /pub/securelib.tar.
  420.  
  421. xinetd (posted to comp.sources.unix) is an inetd replacement that
  422. provides, among others, logging, username lookup and access control.
  423. However, it does not support the System V TLI services, and it is only
  424. six times as much source code as the daemon wrapper programs.
  425.  
  426. netlog from Texas A&M relies on the SunOS 4.x /dev/nit interface to
  427. passively watch all TCP and UDP network traffic on a network.  The
  428. current version is net.tamu.edu:/pub/security/TAMU/netlog-1.2.tar.gz.
  429.  
  430. Where shared libraries or router-based packet filtering are not an
  431. option, an alternative portmap daemon can help to improve RPC security,
  432. in particular that of NFS and of the NIS (YP) information service.
  433. ftp.win.tue.nl:/pub/security/portmap.shar.Z was tested with SunOS 4.1.1
  434. ... 4.1.3, Ultrix 3.0 and Ultrix 4.x, HP-UX 8.x and AIX. The protection
  435. is less effective than that of the securelib library because portmap is
  436. mostly a dictionary service.  SunOS 4.x users should install the latest
  437. revision of the portmap and NIS daemons instead (patch 100482) or adopt
  438. NIS+ which has access control built in.
  439.  
  440. Source for a portable RFC 931 (TAP, IDENT)-compatible daemon by Peter
  441. Eriksson is available from ftp.lysator.liu.se:/pub/ident/servers.
  442.  
  443. Some TCP/IP implementations come without syslog library. Some come with
  444. the library but have no syslog daemon. A replacement can be found in
  445. ftp.win.tue.nl:/pub/security/surrogate-syslog.tar.Z.  The fakesyslog
  446. library that comes with the nntp sources reportedly works well, too.
  447.  
  448. 6 - Limitations
  449. ---------------
  450.  
  451. 6.1 - Known wrapper limitations
  452. -------------------------------
  453.  
  454. Some UDP (and rpc/udp) daemons linger around for a while after they
  455. have serviced a request, just in case another request comes in.  In the
  456. inetd configuration file these daemons are registered with the `wait'
  457. option. Only the request that started such a daemon will be seen by the
  458. wrappers.  Such daemons are better protected with the securelib shared
  459. library (see: Related software).
  460.  
  461. The wrappers do not work with RPC services over TCP. These services are
  462. registered as rpc/tcp in the inetd configuration file. The only non-
  463. trivial service that is affected by this limitation is rexd, which is
  464. used by the on(1) command. This is no great loss.  On most systems,
  465. rexd is less secure than a wildcard in /etc/hosts.equiv.
  466.  
  467. Some RPC requests (for example: rwall, rup, rusers) appear to come from
  468. the responding host. What happens is that the client sends its request
  469. to all portmap daemons on its network; each portmap daemon forwards the
  470. request to its own system. As far as the rwall etc.  daemons know, the
  471. request comes from the local host.
  472.  
  473. Portmap and RPC (e.g. NIS and NFS) (in)security is a topic in itself.
  474. See the section in this document on related software.
  475.  
  476. 6.2 - Known system software bugs
  477. --------------------------------
  478.  
  479. Workarounds have been implemented for several bugs in system software.
  480. They are described in the Makefile. Unfortunately, some system software
  481. bugs cannot be worked around. The result is loss of functionality.
  482.  
  483. Older ConvexOS versions come with a broken recvfrom(2) implementation.
  484. This makes it impossible for the daemon wrappers to look up the
  485. remote host address (and hence, the name) in case of UDP requests.
  486. A patch is available for ConvexOS 10.1; later releases should be OK.
  487.  
  488. With early Solaris (SunOS 5) versions, the syslog daemon will leave
  489. behind zombie process when writing to logged-in users.  Workaround:
  490. increase the syslogd threshold for logging to users, or reduce the
  491. wrapper's logging severity.
  492.  
  493. On some systems, the optional RFC 931 remote username lookups may
  494. trigger a kernel bug.  When a client host connects to your system, and
  495. the RFC 931 connection from your system to that client is rejected by a
  496. router, your kernel may drop all connections with that client.  This is
  497. not a bug in the wrapper programs: complain to your vendor, and don't
  498. enable remote user name lookups until the bug has been fixed.
  499.  
  500. Reportedly, SunOS 4.1.1, Next 2.0a, ISC 3.0 with TCP 1.3, and AIX 3.2.2
  501. and later are OK.
  502.  
  503. Sony News/OS 4.51, HP-UX 8-something and Ultrix 4.3 still have the bug.
  504. Reportedly, a fix for Ultrix is available ((CXO-8919).
  505.  
  506. The following procedure can be used (from outside the tue.nl domain) to
  507. find out if your kernel has the bug. From the system under test, do:
  508.  
  509.     % ftp 131.155.70.100
  510.  
  511. This command attempts to make an ftp connection to our anonymous ftp
  512. server (ftp.win.tue.nl).  When the connection has been established, run
  513. the following command from the same system under test, while keeping
  514. the ftp connection open:
  515.  
  516.     % telnet 131.155.70.100 111
  517.  
  518. Do not forget the `111' at the end of the command. This telnet command
  519. attempts to connect to our portmap process.  The telnet command should
  520. fail with:  "host not reachable", or something like that. If your ftp
  521. connection gets messed up, you have the bug. If the telnet command does
  522. not fail, please let me know a.s.a.p.!
  523.  
  524. For those who care, the bug is that the BSD kernel code was not careful
  525. enough with incoming ICMP UNREACHABLE control messages (it ignored the
  526. local and remote port numbers, and therefore zapped *all* connections
  527. with the remote system). The bug is still present in the BSD NET/1
  528. source release (1989) but apparently has been fixed in BSD NET/2 (1991). 
  529.  
  530. 7 - Configuration and installation
  531. ----------------------------------
  532.  
  533. 7.1 - Easy configuration and installation
  534. -----------------------------------------
  535.  
  536. The "easy" recipe requires no changes to existing software or
  537. configuration files.  Basically, you move the daemons that you want to
  538. protect to a different directory and plug the resulting holes with
  539. copies of the wrapper programs.
  540.  
  541. If you don't run Ultrix, you won't need the miscd wrapper program.  The
  542. miscd daemon implements among others the SYSTAT service, which produces
  543. the same output as the the WHO command.
  544.  
  545. Type `make' and follow the instructions.  The Makefile comes with
  546. ready-to-use templates for many common UNIX implementations (sun,
  547. ultrix, hp-ux, irix, ...).
  548.  
  549. When the `make' succeeds the result is four executables (five in
  550. case of Ultrix).
  551.  
  552. The `try' program can be used to play with host access control tables
  553. and is described in a later section.
  554.  
  555. The `safe_finger' command should be used when you implement booby
  556. traps:  it gives better protection against nasty stuff that hosts may
  557. send in response to finger probes.
  558.  
  559. The `try-from' program tests the host and username lookup code.  Run it
  560. from a remote shell command (`rsh host /some/where/try-from') and it
  561. should be able to figure out from what system it is being called.
  562.  
  563. The tcpd program can be used to monitor the telnet, finger, ftp, exec,
  564. rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  565. a one-to-one mapping onto executable files.
  566.  
  567. The tcpd program can also be used for services that are marked as
  568. rpc/udp in the inetd configuration file, but not for rpc/tcp services
  569. such as rexd.  You probably do not want to run rexd anyway. On most
  570. systems it is even less secure than a wildcard in /etc/hosts.equiv.
  571.  
  572. With System V.4-style systems, the tcpd program can also handle TLI
  573. services. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  574. provide the same functions as with socket-based applications. When some
  575. other protocol is used underneath TLI, functionality will be limited
  576. (no remote username lookups, weird network address formats).
  577.  
  578. Decide which services you want to monitor. Move the corresponding
  579. vendor-provided daemon programs to the location specified by the
  580. REAL_DAEMON_DIR constant in the Makefile, and fill the holes with
  581. copies of the tcpd wrapper. That is, one copy of (or link to) the tcpd
  582. program for each service that you want to monitor. For example, to
  583. monitor the use of your finger service:
  584.  
  585.     # mkdir REAL_DAEMON_DIR
  586.     # mv /usr/etc/in.fingerd REAL_DAEMON_DIR
  587.     # cp tcpd /usr/etc/in.fingerd
  588.  
  589. The example applies to SunOS 4. With other UNIX implementations the
  590. network daemons live in /usr/libexec, /usr/sbin or in /etc, or have no
  591. "in." prefix to their names, but you get the idea.
  592.  
  593. File protections: the wrapper, all files used by the wrapper, and all
  594. directories in the path leading to those files, should be accessible
  595. but not writable for unprivileged users (mode 755 or mode 555). Do not
  596. install the wrapper set-uid.
  597.  
  598. Ultrix only:  If you want to monitor the SYSTAT service, move the
  599. vendor-provided miscd daemon to the location specified by the
  600. REAL_DAEMON_DIR macro in the Makefile, and install the miscd wrapper
  601. at the original miscd location.
  602.  
  603. In the absence of any access-control tables, the daemon wrappers
  604. will just maintain a record of network connections made to your system.
  605.  
  606. 7.2 - Advanced configuration and installation
  607. ---------------------------------------------
  608.  
  609. The advanced recipe leaves your daemon executables alone, but involves
  610. simple modifications to the inetd configuration file.
  611.  
  612. Type `make' and follow the instructions.  The Makefile comes with
  613. ready-to-use templates for many common UNIX implementations (sun,
  614. ultrix, hp-ux, irix, ...).
  615.  
  616. When the `make' succeeds the result is four executables (five in
  617. case of Ultrix).
  618.  
  619. The `try' program can be used to play with host access control tables
  620. and is described in a later section.
  621.  
  622. The `try-from' program tests the host and username lookup code.  Run it
  623. from a remote shell command (`rsh host /some/where/try-from') and it
  624. should be able to figure out from what system it is being called.
  625.  
  626. The `safe_finger' command should be used when you implement a booby
  627. trap:  it gives better protection against nasty stuff that hosts may
  628. send in response to finger probes.
  629.  
  630. The tcpd program can be used to monitor the telnet, finger, ftp, exec,
  631. rsh, rlogin, tftp, talk, comsat and other tcp or udp services that have
  632. a one-to-one mapping onto executable files.
  633.  
  634. With System V.4-style systems, the tcpd program can also handle TLI
  635. services. When TCP/IP or UDP/IP is used underneath TLI, the wrappers
  636. provide the same functions as with socket-based applications. When some
  637. other protocol is used underneath TLI, functionality will be limited
  638. (no remote username lookups, weird network address formats).
  639.  
  640. The tcpd program can also be used for services that are marked as
  641. rpc/udp in the inetd configuration file, but not for rpc/tcp services
  642. such as rexd.  You probably do not want to run rexd anyway. On most
  643. systems it is even less secure than a wildcard in /etc/hosts.equiv.
  644.  
  645. Install the tcpd command in a suitable place. Apollo UNIX users will
  646. want to install it under a different name because the name "tcpd" is
  647. already taken; a suitable name would be "frontd".  
  648.  
  649. File protections: the wrapper, all files used by the wrapper, and all
  650. directories in the path leading to those files, should be accessible
  651. but not writable for unprivileged users (mode 755 or mode 555). Do not
  652. install the wrapper set-uid.
  653.  
  654. Then perform the following edits on the inetd configuration file
  655. (usually /etc/inetd.conf or /etc/inet/inetd.conf):
  656.  
  657.     finger  stream  tcp     nowait  nobody  /usr/etc/in.fingerd     in.fingerd
  658.                                             ^^^^^^^^^^^^^^^^^^^
  659. becomes:
  660.  
  661.     finger  stream  tcp     nowait  nobody  /usr/etc/tcpd in.fingerd
  662.                         ^^^^^^^^^^^^^
  663. Send a `kill -HUP' to the inetd process to make the change effective.
  664. Some inetd implementations require that you first disable the finger
  665. service (comment out the finger service and `kill -HUP' the inetd)
  666. before you can turn on the modified version.
  667.  
  668. The example applies to SunOS 4. With other UNIX implementations the
  669. network daemons live in /usr/libexec, /usr/sbin, or /etc, the network
  670. daemons have no "in." prefix to their names, or the username field in
  671. the inetd configuration file may be missing.
  672.  
  673. When the finger service works as expected you can perform similar
  674. changes for other network services. Do not forget the `kill -HUP'.
  675.  
  676. The miscd daemon that comes with Ultrix implements several network
  677. services. It decides what to do by looking at its process name. One of
  678. the services is systat, which is a kind of limited finger service.  If
  679. you want to monitor the systat service, install the miscd wrapper in a
  680. suitable place and update the inetd configuration file:
  681.  
  682.     systat  stream  tcp     nowait  /suitable/place/miscd      systatd
  683.  
  684. Ultrix 4.3 allows you to specify a user id under which the daemon will
  685. be executed. This feature is not documented in the manual pages.  Thus,
  686. the example would become:
  687.  
  688.     systat  stream  tcp     nowait  nobody /suitable/place/miscd    systatd
  689.  
  690. Older Ultrix systems still run all their network daemons as root.
  691.  
  692. In the absence of any access-control tables, the daemon wrappers
  693. will just maintain a record of network connections made to your system.
  694.  
  695. 7.3 - Daemons with arbitrary path names
  696. ---------------------------------------
  697.  
  698. The above tcpd examples work fine with network daemons that live in a
  699. common directory, but sometimes that is not practical. Having soft
  700. links all over your file system is not a clean solution, either.
  701.  
  702. Instead you can specify, in the inetd configuration file, an absolute
  703. path name for the daemon process name.  For example,
  704.  
  705.     ntalk   dgram   udp     wait    root    /usr/etc/tcpd /usr/local/lib/ntalkd
  706.  
  707. When the daemon process name is an absolute path name, tcpd ignores the
  708. value of the REAL_DAEMON_DIR constant, and uses the last path component
  709. of the daemon process name for logging and for access control.
  710.  
  711. 7.4 - Building and testing the access control rules
  712. ---------------------------------------------------
  713.  
  714. In order to support access control the wrappers must be compiled with
  715. the -DHOSTS_ACCESS option. The access control policy is given in the
  716. form of two tables (default: /etc/hosts.allow and /etc/hosts.deny).
  717. Access control is disabled when there are no access control tables, or
  718. when the tables are empty.
  719.  
  720. If you haven't used the wrappers before I recommend that you first run
  721. them a couple of days without any access control restrictions. The
  722. logfile records should give you an idea of the process names and of the
  723. host names that you will have to build into your access control rules.
  724.  
  725. The syntax of the access control rules is documented in the file
  726. hosts_access.5, which is in `nroff -man' format. This is a lengthy
  727. document, and no-one expects you to read it right away from beginning
  728. to end.  Instead, after reading the introductory section, skip to the
  729. examples at the end so that you get a general idea of the language.
  730. Then you can appreciate the detailed reference sections near the
  731. beginning of the document.
  732.  
  733. The examples in the hosts_access.5 document (`nroff -man' format) show
  734. two specific types of access control policy:  1) mostly closed (only
  735. permitting access from a limited number of systems) and 2) mostly open
  736. (permitting access from everyone except a limited number of trouble
  737. makers). You will have to choose what model suits your situation best.
  738. Implementing a mixed policy should not be overly difficult either.
  739.  
  740. Optional extensions to the access control language are described in the
  741. hosts_options.5 document (`nroff -man' format).
  742.  
  743. The `try' command can be used to try out your local access control
  744. files.  The command syntax is:
  745.  
  746.     ./try process_name hostname    (e.g.: ./try in.tftpd localhost)
  747.  
  748.     ./try process_name address    (e.g.: ./try in.tftpd 127.0.0.1)
  749.  
  750. This way you can simulate what decisions will be made, and what actions
  751. will be taken, when hosts connect to your own system.
  752.  
  753. Note 1: `try -d' will look for hosts.{allow,deny} tables in the
  754. current working directory. This is useful for testing new rules
  755. without bothering your users.
  756.  
  757. Note 2: you cannot use the `try' command to simulate what happens when
  758. the local system connects to other hosts.
  759.  
  760. In order to find out what process name to use, just use the service and
  761. watch the process name that shows up in the logfile.  Alternatively,
  762. you can look up the name from the inetd configuration file. Coming back
  763. to the tftp example in the tutorial section above:
  764.  
  765.     tftp  dgram  udp  wait  root  /usr/etc/tcpd  in.tftpd -s /tftpboot
  766.  
  767. This entry causes the inetd to run the wrapper program (tcpd) with a
  768. process name `in.tftpd'.  This is the name that the wrapper will use
  769. when scanning the access control tables. Therefore, `in.tftpd' is the
  770. process name that should be given to the `try' command. On your system
  771. the actual inetd.conf entry may differ (tftpd instead of in.tftpd, and
  772. no `root' field), but you get the idea.
  773.  
  774. When you specify a host name, the `try' program will use both the host
  775. name and address. This way you can simulate the most common case where
  776. the wrappers know both the host address and the host name.  The `try'
  777. program will iterate over all addresses that it can find for the given
  778. host name.
  779.  
  780. When you specify a host address instead of a host name, the `try'
  781. program will pretend that the host name is unknown, so that you can
  782. simulate what happens when the wrapper is unable to look up the remote
  783. host name.
  784.  
  785. The `try' command will report serious errors to the standard error
  786. stream (no need to tail the syslog file anymore).
  787.  
  788. 7.5 - Other applications
  789. ------------------------
  790.  
  791. The access control routines can easily be integrated with other
  792. programs.  The hosts_access.3 manual page (`nroff -man' format)
  793. describes the external interface of the libwrap.a library.
  794.  
  795. The tcpd wrapper can even be used to control access to the smtp port.
  796. This can be useful when you suspect that someone is trying out some
  797. obscure sendmail bug, or when a remote site is misconfigured and keeps
  798. hammering your mail daemon.
  799.  
  800. In that case, sendmail should not be run as a stand-alone daemon, but
  801. it should be registered in the inetd configuration file. For example:
  802.  
  803.     smtp    stream  tcp     nowait  root    /usr/etc/tcpd /usr/lib/sendmail -bs
  804.  
  805. You will periodically want to run sendmail to process queued-up
  806. messages. A crontab entry like:
  807.  
  808.     0,15,30,45 * * * * /usr/lib/sendmail -q
  809.  
  810. should take care of that. You cannot really prevent people from posting
  811. forged mail this way, because there are many unprotected smtp daemons
  812. on the network.
  813.  
  814. 8 - Acknowledgements
  815. --------------------
  816.  
  817. Many people contributed to the evolution of the programs, by asking
  818. inspiring questions, by suggesting features or bugfixes, or by
  819. submitting source code.  Nevertheless, all mistakes and bugs in the
  820. wrappers are my own.
  821.  
  822. Thanks to Brendan Kehoe (brendan@cs.widener.edu), Heimir Sverrisson
  823. (heimir@hafro.is) and Dan Bernstein (brnstnd@kramden.acf.nyu.edu) for
  824. feedback on an early release of this product.  The host name/address
  825. check was suggested by John Kimball (jkimball@src.honeywell.com).
  826. Apollo's UNIX environment has some peculiar quirks: Willem-Jan Withagen
  827. (wjw@eb.ele.tue.nl), Pieter Schoenmakers (tiggr@es.ele.tue.nl) and
  828. Charles S. Fuller (fuller@wccs.psc.edu) provided assistance.  Hal R.
  829. Brand (BRAND@addvax.llnl.gov) told me how to get the remote IP address
  830. in case of datagram-oriented services, and suggested the optional shell
  831. command feature.  Shabbir Safdar (shabby@mentor.cc.purdue.edu) provided
  832. a first version of a much-needed manual page.  Granville Boman Goza, IV
  833. (gbg@sei.cmu.edu) suggested to use the remote IP address even when the
  834. host name is available.  Casper H.S. Dik (casper@fwi.uva.nl) provided
  835. additional insight into DNS spoofing techniques.  The bogus daemon
  836. feature was inspired by code from Andrew Macpherson (BNR Europe Ltd).
  837. Steve Bellovin (smb@research.att.com) confirmed some of my suspicions
  838. about the darker sides of TCP/IP insecurity. Risks of automated fingers
  839. were pointed out by Borja Marcos (borjam@we.lc.ehu.es). Brad Plecs
  840. (mbp@jhuspo.ca.jhu.edu) was kind enough to try my early TLI code and
  841. to work out how DG/UX differs from Solaris.
  842.  
  843. John P.  Rouillard (rouilj@cs.umb.edu) deserves special mention for his
  844. persistent, but constructive, nagging about wrong or missing things,
  845. and for trying out and discussing embryonic code or ideas.
  846.  
  847. Lat but not least, Howard Chu (hyc@hanauma.jpl.nasa.gov), Darren Reed
  848. (avalon@coombs.anu.edu.au), Icarus Sparry (I.Sparry@gdr.bath.ac.uk),
  849. Scott Schwartz (schwartz@ cs.psu.edu), John A. Kunze
  850. (jak@violet.berkeley.edu), Daniel Len Schales (dan@engr.latech.edu),
  851. Chris Turbeville <turbo@cse.uta.edu>, Paul Kranenburg
  852. <pk@cs.few.eur.nl>, Marc Boucher <marc@cam.org>, Dave Mitchell
  853. <D.Mitchell@dcs.shef.ac.uk>, and many, many others provided fixes, code
  854. fragments, or other improvements to the wrappers.
  855.  
  856.     Wietse Venema (wietse@wzv.win.tue.nl)
  857.     Department of Mathematics and Computing Science
  858.     Eindhoven University of Technology
  859.     P.O. Box 513
  860.     5600 MB Eindhoven
  861.     The Netherlands
  862.