]> git.neil.brown.name Git - portmap.git/blob - README.5
Only fail an 'unregister' attempt if nothing can be unregistered.
[portmap.git] / README.5
1 @(#) README 1.7 96/07/06 23:06:19
2
3 This is the README file for the 5th enhanced portmapper release.
4
5 Description
6 -----------
7
8 This README describes a replacement portmapper that prevents theft of
9 NIS (YP), NFS, and other sensitive information via the portmapper.  As
10 an option, the program supports access control in the style of the tcp
11 wrapper (log_tcp) package.
12
13 Like all portmappers, this one is intended to be started at boot time.
14 Daemons that offer RPC services tell the portmapper on what port they
15 listen. Unlike the well-known services registered with the inetd, RPC
16 network port numbers may change each time the system is booted.
17 Whenever a client wants to use an RPC service it is supposed to first
18 ask the portmapper on what port the corresponding daemon is listening.
19 The rpcinfo command can tell you what RPC services your system offers.
20
21 As described in the features section below, the replacement portmapper
22 can prevent undesirable client-server interactions.  In some cases,
23 better or equivalent alternatives are available:
24
25     The SunOS portmap that is provided with patch id 100482-02 should
26     close the same security holes.  In addition, it provides an YPSERV
27     daemon with its own access control list. This is better than just
28     portmapper access control.
29
30     The "securelib" shared library (eecs.nwu.edu:/pub/securelib.tar)
31     implements access control for all kinds of (RPC) services, not
32     just the portmapper.
33
34 However, vendors still ship portmap implementations that allow anyone
35 to read or modify its tables and that will happily forward any request
36 so that it appears to come from the local system.
37
38 Features
39 --------
40
41 - optional: host access control. The local host is always considered
42 authorized. Access control requires the libwrap.a library that comes
43 with recent tcp wrapper (log_tcp) implementations.
44
45 - requests to change the portmap tables are accepted only when they
46 come from the local system.
47
48 - optional: requests to (un)register services that listen on privileged
49 ports (port < 1024) are accepted only when the requests themselves come
50 from a privileged port. This feature is optional because of older RPC
51 implementations.
52
53 - requests that are forwarded by the portmapper will be forwarded
54 through an unprivileged port.
55
56 - the portmapper refuses to forward requests to rpc daemons that do (or
57 should) verify the origin of each request: when the portmapper forwards
58 a request it appears to come from the local machine. At present, the
59 portmapper refuses to forward all RPC calls to itself, and most RPC
60 calls to the NFS mountd/nfsd daemons, and to the NIS daemons.
61
62 - the really desperate can harden the portmapper even more by requiring
63 that requests to modify its tables arrive via the loopback network
64 interface, instead of via the primary network interface that every host
65 can talk to. The cost is high: besides changes to the portmapper, this
66 requires changes to system libraries, to statically-linked rpc servers,
67 to the kernel to disable IP source routing, and perhaps even to system
68 startup procedures.  Don't do this unless you're desperate.  Details
69 are given in the Makefile.
70
71 Restrictions
72 ------------
73
74 Limiting access to the portmapper does not protect you from direct
75 attacks on the rpc daemons; the main task of portmap is to maintain a
76 table of available RPC services and of the network ports that they are
77 listening on. The securelib can be used to protect individual RPC
78 daemons, and the latest SunOS portmap+NIS fix already protects the NIS
79 daemons and implements limited forwarding.
80
81 On the other hand, even though a portmapper with access control only
82 makes an attack more difficult, it still provides an excellent early
83 warning system.
84
85 Origin and portability
86 ----------------------
87
88 The sources in this distribution are derived from code on the second
89 BSD networking tape, which was derived from Sun's RPCSRC 4.0 code, and
90 from Sun's TIRPC (transport-independent rpc) distribution. 
91
92 The code compiles fine with SunOS 4.1.x, Ultrix 4.x, HP-UX 9.x, AIX 3.x
93 and AIX 4.x, and Digital UNIX (OSF/1). See the notes in the Makefile.
94
95 Solaris 2.x (and other true System V.4 clones) use a different program
96 called rpcbind. I have written a replacement for that program, too.
97 The primary achive is ftp.win.tue.nl:/pub/security/rpcbind_xx.tar.Z.
98
99 Installation
100 ------------
101
102 (1) Follow the instructions in the Makefile, then build the portmap and
103 auxiliary executables.
104
105 (2) Before killing the present portmap process, save the present
106 portmapper tables using the command:
107
108         ./pmap_dump >table
109
110 If you kill the portmap process without saving its tables you will have
111 to reboot the machine.
112
113 Note: the information in the portmap tables is dynamic: For example, it
114 will be different after each reboot. On a Sun, it even changes each
115 time a windowing system is started that uses the selection service.
116
117 (3) Kill the running portmap process and start the new portmap
118 program.  Then (still as root) initialize the portmap tables with:
119
120         ./pmap_set <table
121
122 (4) If you get error messages of the form: "not registered: xxxx",
123 disable the CHECK_PORT feature in the Makefile, remove pmap_check.o and
124 rebuild the portmap program.  Then proceed with step 3.
125
126 If the portmapper complains that it cannot find all machine interfaces
127 you will have to rebuild it with -DHAS_SA_LEN set (see Makefile). You
128 can test this with the "from_local" command (to build: make from_local).
129
130 In order to revert to the original portmap daemon, kill off the running
131 one, restart the original portmapper and reload its tables using the
132 "pmap_set" command as shown above.
133
134 Access control:
135 ---------------
136
137 By default, host access control is enabled. However, the host that runs
138 the portmapper is always considered authorized. The host access control
139 tables are never consulted with requests from the local system itself;
140 they are always consulted with requests from other hosts.
141
142 In order to avoid deadlocks, the portmap program does not attempt to
143 look up the remote host name or user name, nor will it try to match NIS
144 netgroups. The upshot of all this is that only network number patterns
145 will work for portmap access control.
146
147 Sample entries for the host access-control files are:
148
149     /etc/hosts.allow:
150         portmap: your.sub.net.number/your.sub.net.mask
151         portmap: 255.255.255.255 0.0.0.0
152
153     /etc/hosts.deny
154         portmap: ALL: (/some/where/safe_finger -l @%h | mail root) &
155
156 The syntax of the access-control files is described in the
157 hosts_access.5 manual page that comes with the tcp wrapper (log_tcp)
158 sources.  The safe_finger command comes with later wrapper releases.
159
160 The first line in the hosts.allow file permits access from all systems
161 within your own subnet. Some rpc services rely on broadcasts and will
162 contact your portmapper anyway; and once an intruder has access to your
163 local network segment you're already in deep trouble.
164
165 The second line in the hosts.allow file may be needed if there are
166 any PC-NFS systems on your network segment.
167
168 For security reasons, the portmap process drops root privilegs after
169 initialization. The access control files should therefore be readable
170 for group or world.
171
172 Testing:
173 --------
174
175 Normally, only rejected requests will be reported via the syslog
176 daemon.  Logging is done in a child process, in order to avoid
177 possible deadlock in case the logging code needs assistance from
178 the portmapper.
179
180 By default, the portmapper will be utterly silent. In fact, the portmap
181 daemon is not consulted that often. Sending a SIGINT signal to the
182 portmap process will enable the logging of all requests. 
183
184 Another way to enable verbose logging is to start the daemon with the
185 "-v" option. See above, steps (2) and later, on how to stop and restart
186 the portmapper without having to reboot.
187
188 Warning:  with some HP-UX and AIX versions, when verbose logging is on,
189 the system fills up with zombie processes. This can be fixed by
190 compiling with -DIGNORE_SIGCHLD (see instructions in the Makefile).
191
192 With verbose logging turned on, requests such as "ypcat" or "rpcinfo
193 -p" should show up with log file entries such as:
194
195  MMM dd hh:mm:ss hostname portmap[pid]: connect from x.x.x.x to getport(ypserv)
196  MMM dd hh:mm:ss hostname portmap[pid]: connect from y.y.y.y to dump()  
197
198 Send SIGINT to the portmapper to turn the verbose logging off.
199
200 Acknowledgements
201 ----------------
202
203 Casper H.S. Dik (casper@fwi.uva.nl) provided valuable information on
204 RPC security and tested an intermediate version of the portmapper with
205 SunOS 4.1.2.  Lyford D. Rich (rich@ece.nps.navy.mil) was helpful with
206 porting the daemon to Ultrix 3.x. Lionel Cons (cons@dxcern.cern.ch)
207 solved the HP-UX problem. Fabrice Gonton (Fabrice.Gonton@sagem.fr)
208 figured out how to make the program work on AIX 4.1, and Michael
209 Matthews took care of the DEC Alpha platform.
210
211         Wietse Venema (wietse@wzv.win.tue.nl)
212         Mathematics and Computing Science
213         Eindhoven University of Technology
214         The Netherlands