xref: /freebsd/share/man/man7/security.7 (revision 5521ff5a4d1929056e7ffc982fac3341ca54df7c)
13128fa34SMatthew Dillon.\" Copyright (c) 1998, Matthew Dillon.  Terms and conditions are those of
23128fa34SMatthew Dillon.\" the BSD Copyright as specified in the file "/usr/src/COPYRIGHT" in
33128fa34SMatthew Dillon.\" the source tree.
4f063d76aSMatthew Dillon.\"
57f3dea24SPeter Wemm.\" $FreeBSD$
6f063d76aSMatthew Dillon.\"
7d93b26d6SMatthew Dillon.Dd September 18, 1999
8f063d76aSMatthew Dillon.Dt SECURITY 7
9ad27d066SMatthew Dillon.Os FreeBSD
10f063d76aSMatthew Dillon.Sh NAME
11f063d76aSMatthew Dillon.Nm security
12f063d76aSMatthew Dillon.Nd introduction to security under FreeBSD
13f063d76aSMatthew Dillon.Sh DESCRIPTION
14f063d76aSMatthew Dillon.Pp
15f063d76aSMatthew DillonSecurity is a function that begins and ends with the system administrator.
16f063d76aSMatthew DillonWhile all
17f063d76aSMatthew Dillon.Bx
18d93b26d6SMatthew Dillonmulti-user systems have some inherent security, the job of building and
19d93b26d6SMatthew Dillonmaintaining additional security mechanisms to keep those users
20568e4cbbSGuy Helmer.Sq honest
21568e4cbbSGuy Helmeris probably
226ac7e896SDavid E. O'Brienone of the single largest undertakings of the sysadmin.  Machines are
23f063d76aSMatthew Dillononly as secure as you make them, and security concerns are ever competing
24568e4cbbSGuy Helmerwith the human necessity for convenience.
25568e4cbbSGuy Helmer.Ux
26568e4cbbSGuy Helmersystems,
276ac7e896SDavid E. O'Brienin general, are capable of running a huge number of simultaneous processes
28f063d76aSMatthew Dillonand many of these processes operate as servers - meaning that external entities
29f063d76aSMatthew Dilloncan connect and talk to them.  As yesterday's mini-computers and mainframes
30f063d76aSMatthew Dillonbecome today's desktops, and as computers become networked and internetworked,
31f063d76aSMatthew Dillonsecurity becomes an ever bigger issue.
32f063d76aSMatthew Dillon.Pp
33d93b26d6SMatthew DillonSecurity is best implemented through a layered onion approach.  In a nutshell,
34d93b26d6SMatthew Dillonwhat you want to do is to create as many layers of security as are convenient
35d93b26d6SMatthew Dillonand then carefully monitor the system for intrusions.  You do not want to
36d93b26d6SMatthew Dillonoverbuild your security or you will interefere with the detection side, and
37d93b26d6SMatthew Dillondetection is one of the single most important aspects of any security
38d93b26d6SMatthew Dillonmechanism.  For example, it makes little sense to set the
39d93b26d6SMatthew Dillon.Pa schg
40d93b26d6SMatthew Dillonflags
41d93b26d6SMatthew Dillon.Po
42d93b26d6SMatthew Dillonsee
43d93b26d6SMatthew Dillon.Xr chflags 1
44d93b26d6SMatthew Dillon.Pc
45d93b26d6SMatthew Dillonon every system binary because while this may temporarily protect the
46d93b26d6SMatthew Dillonbinaries, it prevents a hacker who has broken in from making an
47d93b26d6SMatthew Dilloneasily detectable change that may result in your security mechanisms not
48d93b26d6SMatthew Dillondetecting the hacker at all.
49d93b26d6SMatthew Dillon.Pp
50d93b26d6SMatthew DillonSystem security also pertains to dealing with various forms of attack,
51d93b26d6SMatthew Dillonincluding attacks that attempt to crash or otherwise make a system unusable
52d93b26d6SMatthew Dillonbut do not attempt to break root.  Security concerns can be split up into
53d93b26d6SMatthew Dillonseveral categories:
54f063d76aSMatthew Dillon.Bl -enum -offset indent
55f063d76aSMatthew Dillon.It
56f063d76aSMatthew DillonDenial of service attacks
57f063d76aSMatthew Dillon.It
58f063d76aSMatthew DillonUser account compromises
59f063d76aSMatthew Dillon.It
606ac7e896SDavid E. O'BrienRoot compromise through accessible servers
61f063d76aSMatthew Dillon.It
626ac7e896SDavid E. O'BrienRoot compromise via user accounts
63d93b26d6SMatthew Dillon.It
64d93b26d6SMatthew DillonBackdoor creation
65f063d76aSMatthew Dillon.El
66f063d76aSMatthew Dillon.Pp
67f063d76aSMatthew DillonA denial of service attack is an action that deprives the machine of needed
68f063d76aSMatthew Dillonresources.  Typically, D.O.S. attacks are brute-force mechanisms that attempt
69f063d76aSMatthew Dillonto crash or otherwise make a machine unusable by overwhelming its servers or
70f063d76aSMatthew Dillonnetwork stack.  Some D.O.S. attacks try to take advantages of bugs in the
71f063d76aSMatthew Dillonnetworking stack to crash a machine with a single packet.  The latter can
72f063d76aSMatthew Dillononly be fixed by applying a bug fix to the kernel.  Attacks on servers can
73d93b26d6SMatthew Dillonoften be fixed by properly specifying options to limit the load the servers
74d93b26d6SMatthew Dillonincur on the system under adverse conditions.  Brute-force network
75f063d76aSMatthew Dillonattacks are harder to deal with.  A spoofed-packet attack, for example, is
76f063d76aSMatthew Dillonnearly impossible to stop short of cutting your system off from the internet.
77d93b26d6SMatthew DillonIt may not be able to take your machine down, but it can fill up internet
78d93b26d6SMatthew Dillonpipe.
79f063d76aSMatthew Dillon.Pp
80f063d76aSMatthew DillonA user account compromise is even more common then a D.O.S. attack.  Many
816ac7e896SDavid E. O'Briensysadmins still run standard telnetd, rlogind, rshd, and ftpd servers on their
82f063d76aSMatthew Dillonmachines.  These servers, by default, do not operate over encrypted
83f063d76aSMatthew Dillonconnections.  The result is that if you have any moderate-sized user base,
84f063d76aSMatthew Dillonone or more of your users logging into your system from a remote location
85568e4cbbSGuy Helmer.Po
86568e4cbbSGuy Helmerwhich is the most common and convenient way to login to a system
87568e4cbbSGuy Helmer.Pc
88568e4cbbSGuy Helmerwill
89f063d76aSMatthew Dillonhave his or her password sniffed.  The attentive system admin will analyze
90d93b26d6SMatthew Dillonhis remote access logs looking for suspicious source addresses
91f063d76aSMatthew Dilloneven for successful logins.
92f063d76aSMatthew Dillon.Pp
93f063d76aSMatthew DillonOne must always assume that once an attacker has access to a user account,
94f063d76aSMatthew Dillonthe attacker can break root.  However, the reality is that in a well secured
95f063d76aSMatthew Dillonand maintained system, access to a user account does not necessarily give the
96f063d76aSMatthew Dillonattacker access to root.  The distinction is important because without access
97f063d76aSMatthew Dillonto root the attacker cannot generally hide his tracks and may, at best, be
98d93b26d6SMatthew Dillonable to do nothing more then mess with the user's files or crash the machine.
99d93b26d6SMatthew DillonUser account compromises are very common because users tend not to take the
100d93b26d6SMatthew Dillonprecautions that sysads take.
101f063d76aSMatthew Dillon.Pp
102d93b26d6SMatthew DillonSystem administrators must keep in mind that there are potentially many ways
103d93b26d6SMatthew Dillonto break root on a machine.  The attacker may know the root password,
104d93b26d6SMatthew Dillonthe attacker
105f063d76aSMatthew Dillonmay find a bug in a root-run server and be able to break root over a network
106f063d76aSMatthew Dillonconnection to that server, or the attacker may know of a bug in an suid-root
107f063d76aSMatthew Dillonprogram that allows the attacker to break root once he has broken into a
108d93b26d6SMatthew Dillonuser's account.  If an attacker has found a way to break root on a machine,
109f167d7fbSSheldon Hearnthe attacker may not have a need to install a backdoor.
110d93b26d6SMatthew DillonMany of the root holes found and closed to date involve a considerable amount
111d93b26d6SMatthew Dillonof work by the hacker to cleanup after himself, so most hackers do install
112d93b26d6SMatthew Dillonbackdoors.  This gives you a convienient way to detect the hacker.  Making
113d93b26d6SMatthew Dillonit impossible for a hacker to install a backdoor may actually be detrimental
114d93b26d6SMatthew Dillonto your security because it will not close off the hole the hacker found to
115a910f192SDima Dorfmanbreak in the first place.
116f063d76aSMatthew Dillon.Pp
117d93b26d6SMatthew DillonSecurity remedies should always be implemented with a multi-layered
118568e4cbbSGuy Helmer.Sq onion peel
119f063d76aSMatthew Dillonapproach and can be categorized as follows:
120f063d76aSMatthew Dillon.Bl -enum -offset indent
121f063d76aSMatthew Dillon.It
122f063d76aSMatthew DillonSecuring root and staff accounts
123f063d76aSMatthew Dillon.It
124f063d76aSMatthew DillonSecuring root - root-run servers and suid/sgid binaries
125f063d76aSMatthew Dillon.It
126f063d76aSMatthew DillonSecuring user accounts
127f063d76aSMatthew Dillon.It
128f063d76aSMatthew DillonSecuring the password file
129f063d76aSMatthew Dillon.It
130f063d76aSMatthew DillonSecuring the kernel core, raw devices, and filesystems
131f063d76aSMatthew Dillon.It
132d93b26d6SMatthew DillonQuick detection of inappropriate changes made to the system
133f063d76aSMatthew Dillon.It
134f063d76aSMatthew DillonParanoia
135f063d76aSMatthew Dillon.El
136f063d76aSMatthew Dillon.Sh SECURING THE ROOT ACCOUNT AND SECURING STAFF ACCOUNTS
137f063d76aSMatthew Dillon.Pp
138f063d76aSMatthew DillonDon't bother securing staff accounts if you haven't secured the root
139f063d76aSMatthew Dillonaccount.  Most systems have a password assigned to the root account.  The
140568e4cbbSGuy Helmerfirst thing you do is assume that the password is
141568e4cbbSGuy Helmer.Sq always
142d93b26d6SMatthew Dilloncompromised.  This does not mean that you should remove the password.  The
143d93b26d6SMatthew Dillonpassword is almost always necessary for console access to the machine.
144d93b26d6SMatthew DillonWhat it does mean is that you should not make it possible to use the password
145d93b26d6SMatthew Dillonoutside of the console or possibly even with a
146d93b26d6SMatthew Dillon.Xr su 1
147d93b26d6SMatthew Dilloncommand.
148d93b26d6SMatthew DillonFor example, make sure that your pty's are specified as being unsecure
149d93b26d6SMatthew Dillonin the
150568e4cbbSGuy Helmer.Sq Pa /etc/ttys
151d93b26d6SMatthew Dillonfile
152d93b26d6SMatthew Dillonso that direct root logins via telnet or rlogin are disallowed.  If using
153d93b26d6SMatthew Dillonother login services such as sshd, make sure that direct root logins are
154d93b26d6SMatthew Dillondisabled there as well.  Consider every access method - services such as
155d93b26d6SMatthew Dillonftp often fall through the cracks.  Direct root logins should only be allowed
156d93b26d6SMatthew Dillonvia the system console.
157f063d76aSMatthew Dillon.Pp
1587626ae52SMatthew DillonOf course, as a sysadmin you have to be able to get to root, so we open up
159f063d76aSMatthew Dillona few holes.  But we make sure these holes require additional password
160f063d76aSMatthew Dillonverification to operate.  One way to make root accessible is to add appropriate
161568e4cbbSGuy Helmerstaff accounts to the wheel group
162568e4cbbSGuy Helmer.Pq in Pa /etc/group .
163568e4cbbSGuy HelmerThe staff members placed
164568e4cbbSGuy Helmerin the wheel group are allowed to
165568e4cbbSGuy Helmer.Sq su
166568e4cbbSGuy Helmerto root.  You should never give staff
167d93b26d6SMatthew Dillonmembers native wheel access by putting the min the wheel group in their
168d93b26d6SMatthew Dillonpassword entry.  Staff accounts should be placed in a
169568e4cbbSGuy Helmer.Sq staff
170d93b26d6SMatthew Dillongroup, and then added to the wheel group via the
171d93b26d6SMatthew Dillon.Sq Pa /etc/group
172d93b26d6SMatthew Dillonfile.  Only those staff members who actually need to have root access
173d93b26d6SMatthew Dillonshould be placed in the wheel group.  It is also possible, when using an
174d93b26d6SMatthew Dillonauthentication method such as kerberos, to use kerberos's
175d93b26d6SMatthew Dillon.Sq Pa .k5login
176d93b26d6SMatthew Dillonfile in the root account to allow a
177d93b26d6SMatthew Dillon.Xr ksu 1
178d93b26d6SMatthew Dillonto root without having to place anyone at all in the wheel group.  This
179d93b26d6SMatthew Dillonmay be the better solution since the wheel mechanism still allows an
180d93b26d6SMatthew Dillonintruder to break root if the intruder has gotten hold of your password
181d93b26d6SMatthew Dillonfile and can break into a staff account.  While having the wheel mechanism
182d93b26d6SMatthew Dillonis better then having nothing at all, it isn't necessarily the safest
183d93b26d6SMatthew Dillonoption.
184f063d76aSMatthew Dillon.Pp
185f063d76aSMatthew DillonAn indirect way to secure the root account is to secure your staff accounts
186f063d76aSMatthew Dillonby using an alternative login access method and *'ing out the crypted password
1876ac7e896SDavid E. O'Brienfor the staff accounts.  This way an intruder may be able to steal the password
188f063d76aSMatthew Dillonfile but will not be able to break into any staff accounts (or, indirectly,
189f063d76aSMatthew Dillonroot, even if root has a crypted password associated with it).  Staff members
190f063d76aSMatthew Dillonget into their staff accounts through a secure login mechanism such as
191568e4cbbSGuy Helmer.Xr kerberos 1
192568e4cbbSGuy Helmeror
193568e4cbbSGuy Helmer.Xr ssh 1
194568e4cbbSGuy Helmerusing a private/public
195f063d76aSMatthew Dillonkey pair.  When you use something like kerberos you generally must secure
196f063d76aSMatthew Dillonthe machines which run the kerberos servers and your desktop workstation.
197f063d76aSMatthew DillonWhen you use a public/private key pair with ssh, you must generally secure
198568e4cbbSGuy Helmerthe machine you are logging in FROM
199568e4cbbSGuy Helmer.Pq typically your workstation ,
200568e4cbbSGuy Helmerbut you can
201f063d76aSMatthew Dillonalso add an additional layer of protection to the key pair by password
202568e4cbbSGuy Helmerprotecting the keypair when you create it with
203568e4cbbSGuy Helmer.Xr ssh-keygen 1 .
204568e4cbbSGuy HelmerBeing able
2056ac7e896SDavid E. O'Briento *-out the passwords for staff accounts also guarantees that staff members
206f063d76aSMatthew Dilloncan only login through secure access methods that you have setup.  You can
207f063d76aSMatthew Dillonthus force all staff members to use secure, encrypted connections for
2086ac7e896SDavid E. O'Brienall their sessions which closes an important hole used by many intruders:  That
209f063d76aSMatthew Dillonof sniffing the network from an unrelated, less secure machine.
210f063d76aSMatthew Dillon.Pp
211f063d76aSMatthew DillonThe more indirect security mechanisms also assume that you are logging in
212f063d76aSMatthew Dillonfrom a more restrictive server to a less restrictive server.  For example,
213f063d76aSMatthew Dillonif your main box is running all sorts of servers, your workstation shouldn't
214f063d76aSMatthew Dillonbe running any.  In order for your workstation to be reasonably secure
215f063d76aSMatthew Dillonyou should run as few servers as possible, up to and including no servers
216f063d76aSMatthew Dillonat all, and you should run a password-protected screen blanker.
217f063d76aSMatthew DillonOf course, given physical access to
218f063d76aSMatthew Dillona workstation an attacker can break any sort of security you put on it.
219f063d76aSMatthew DillonThis is definitely a problem that you should consider but you should also
2206ac7e896SDavid E. O'Brienconsider the fact that the vast majority of break-ins occur remotely, over
2217626ae52SMatthew Dillona network, from people who do not have physical access to your workstation or
222f063d76aSMatthew Dillonservers.
223f063d76aSMatthew Dillon.Pp
224f063d76aSMatthew DillonUsing something like kerberos also gives you the ability to disable or
225f063d76aSMatthew Dillonchange the password for a staff account in one place and have it immediately
226f063d76aSMatthew Dilloneffect all the machine the staff member may have an account on.  If a staff
227f063d76aSMatthew Dillonmember's account gets compromised, the ability to instantly change his
228f063d76aSMatthew Dillonpassword on all machines should not be underrated.  With discrete passwords,
229f063d76aSMatthew Dillonchanging a password on N machines can be a mess.  You can also impose
230f063d76aSMatthew Dillonre-passwording restrictions with kerberos:  not only can a kerberos ticket
231f063d76aSMatthew Dillonbe made to timeout after a while, but the kerberos system can require that
232568e4cbbSGuy Helmerthe user choose a new password after a certain period of time
233568e4cbbSGuy Helmer.Pq say, once a month .
234f063d76aSMatthew Dillon.Sh SECURING ROOT - ROOT-RUN SERVERS AND SUID/SGID BINARIES
235f063d76aSMatthew Dillon.Pp
2367626ae52SMatthew DillonThe prudent sysadmin only runs the servers he needs to, no more, no less.  Be
237f063d76aSMatthew Dillonaware that third party servers are often the most bug-prone.  For example,
238f063d76aSMatthew Dillonrunning an old version of imapd or popper is like giving a universal root
239f063d76aSMatthew Dillonticket out to the entire world.  Never run a server that you have not checked
240f063d76aSMatthew Dillonout carefully.  Many servers do not need to be run as root.  For example,
241568e4cbbSGuy Helmerthe ntalk, comsat, and finger daemons can be run in special user
242568e4cbbSGuy Helmer.Sq sandboxes .
2436ac7e896SDavid E. O'BrienA sandbox isn't perfect unless you go to a large amount of trouble, but the
244f063d76aSMatthew Dillononion approach to security still stands:  If someone is able to break in
245f063d76aSMatthew Dillonthrough a server running in a sandbox, they still have to break out of the
246f063d76aSMatthew Dillonsandbox.  The more layers the attacker must break through, the lower the
247f063d76aSMatthew Dillonlikelihood of his success.  Root holes have historically been found in
248f063d76aSMatthew Dillonvirtually every server ever run as root, including basic system servers.
249f063d76aSMatthew DillonIf you are running a machine through which people only login via sshd and
250f063d76aSMatthew Dillonnever login via telnetd or rshd or rlogind, then turn off those services!
251f063d76aSMatthew Dillon.Pp
252f6f8f44dSAlexey Zelkin.Fx
253568e4cbbSGuy Helmernow defaults to running ntalkd, comsat, and finger in a sandbox.
254f063d76aSMatthew DillonAnother program which may be a candidate for running in a sandbox is
255568e4cbbSGuy Helmer.Xr named 8 .
256568e4cbbSGuy HelmerThe default rc.conf includes the arguments necessary to run
257f063d76aSMatthew Dillonnamed in a sandbox in a commented-out form.  Depending on whether you
258f063d76aSMatthew Dillonare installing a new system or upgrading an existing system, the special
259f063d76aSMatthew Dillonuser accounts used by these sandboxes may not be installed.  The prudent
2607626ae52SMatthew Dillonsysadmin would research and implement sandboxes for servers whenever possible.
261f063d76aSMatthew Dillon.Pp
262f063d76aSMatthew DillonThere are a number of other servers that typically do not run in sandboxes:
263f063d76aSMatthew Dillonsendmail, popper, imapd, ftpd, and others.  There are alternatives to
264f063d76aSMatthew Dillonsome of these, but installing them may require more work then you are willing
265568e4cbbSGuy Helmerto put
266568e4cbbSGuy Helmer.Pq the convenience factor strikes again .
267568e4cbbSGuy HelmerYou may have to run these
2686ac7e896SDavid E. O'Brienservers as root and rely on other mechanisms to detect break-ins that might
269f063d76aSMatthew Dillonoccur through them.
270f063d76aSMatthew Dillon.Pp
271f063d76aSMatthew DillonThe other big potential root hole in a system are the suid-root and sgid
272f063d76aSMatthew Dillonbinaries installed on the system.  Most of these binaries, such as rlogin,
273568e4cbbSGuy Helmerreside in
274568e4cbbSGuy Helmer.Pa /bin ,
275568e4cbbSGuy Helmer.Pa /sbin ,
276568e4cbbSGuy Helmer.Pa /usr/bin ,
277568e4cbbSGuy Helmeror
278568e4cbbSGuy Helmer.Pa /usr/sbin .
279568e4cbbSGuy HelmerWhile nothing is 100% safe,
280f063d76aSMatthew Dillonthe system-default suid and sgid binaries can be considered reasonably safe.
2816ac7e896SDavid E. O'BrienStill, root holes are occasionally found in these binaries.  A root hole
282568e4cbbSGuy Helmerwas found in Xlib in 1998 that made xterm
283568e4cbbSGuy Helmer.Pq which is typically suid
284568e4cbbSGuy Helmervulnerable.
2857626ae52SMatthew DillonIt is better to be safe then sorry and the prudent sysadmin will restrict suid
286f063d76aSMatthew Dillonbinaries that only staff should run to a special group that only staff can
287568e4cbbSGuy Helmeraccess, and get rid of
288568e4cbbSGuy Helmer.Pq chmod 000
289568e4cbbSGuy Helmerany suid binaries that nobody uses.  A
290f063d76aSMatthew Dillonserver with no display generally does not need an xterm binary.  Sgid binaries
2916ac7e896SDavid E. O'Briencan be almost as dangerous.  If an intruder can break an sgid-kmem binary the
292568e4cbbSGuy Helmerintruder might be able to read
293568e4cbbSGuy Helmer.Pa /dev/kmem
294568e4cbbSGuy Helmerand thus read the crypted password
295d93b26d6SMatthew Dillonfile, potentially compromising any passworded account.  Alternatively an
296d93b26d6SMatthew Dillonintruder who breaks group kmem can monitor keystrokes sent through pty's,
297d93b26d6SMatthew Dillonincluding pty's used by users who login through secure methods.  An intruder
298d93b26d6SMatthew Dillonthat breaks the tty group can write to almost any user's tty.  If a user
299d93b26d6SMatthew Dillonis running a terminal
300d93b26d6SMatthew Dillonprogram or emulator with a keyboard-simulation feature, the intruder can
301d93b26d6SMatthew Dillonpotentially
302f063d76aSMatthew Dillongenerate a data stream that causes the user's terminal to echo a command, which
303f063d76aSMatthew Dillonis then run as that user.
304f063d76aSMatthew Dillon.Sh SECURING USER ACCOUNTS
305f063d76aSMatthew Dillon.Pp
306f063d76aSMatthew DillonUser accounts are usually the most difficult to secure.  While you can impose
3076ac7e896SDavid E. O'BrienDraconian access restrictions on your staff and *-out their passwords, you
308f063d76aSMatthew Dillonmay not be able to do so with any general user accounts you might have.  If
309f063d76aSMatthew Dillonyou do have sufficient control then you may win out and be able to secure the
310f063d76aSMatthew Dillonuser accounts properly.  If not, you simply have to be more vigilant in your
311f063d76aSMatthew Dillonmonitoring of those accounts.  Use of ssh and kerberos for user accounts is
312d93b26d6SMatthew Dillonmore problematic due to the extra administration and technical support
313d93b26d6SMatthew Dillonrequired, but still a very good solution compared to a crypted password
314d93b26d6SMatthew Dillonfile.
315f063d76aSMatthew Dillon.Sh SECURING THE PASSWORD FILE
316f063d76aSMatthew Dillon.Pp
317f063d76aSMatthew DillonThe only sure fire way is to *-out as many passwords as you can and
318f063d76aSMatthew Dillonuse ssh or kerberos for access to those accounts.  Even though the
319568e4cbbSGuy Helmercrypted password file
320568e4cbbSGuy Helmer.Pq Pa /etc/spwd.db
321568e4cbbSGuy Helmercan only be read by root, it may
322568e4cbbSGuy Helmerbe possible for an intruder to obtain read access to that file even if the
323f063d76aSMatthew Dillonattacker cannot obtain root-write access.
324f063d76aSMatthew Dillon.Pp
325f063d76aSMatthew DillonYour security scripts should always check for and report changes to
326568e4cbbSGuy Helmerthe password file
327568e4cbbSGuy Helmer.Po
328568e4cbbSGuy Helmersee
329568e4cbbSGuy Helmer.Sq Checking file integrity
330568e4cbbSGuy Helmerbelow
331568e4cbbSGuy Helmer.Pc .
332f063d76aSMatthew Dillon.Sh SECURING THE KERNEL CORE, RAW DEVICES, AND FILESYSTEMS
333f063d76aSMatthew Dillon.Pp
334f063d76aSMatthew DillonIf an attacker breaks root he can do just about anything, but there
335f063d76aSMatthew Dillonare certain conveniences.  For example, most modern kernels have a
336568e4cbbSGuy Helmerpacket sniffing device driver built in.  Under
337f6f8f44dSAlexey Zelkin.Fx
338568e4cbbSGuy Helmerit is called
339568e4cbbSGuy Helmerthe
340568e4cbbSGuy Helmer.Sq bpf
341568e4cbbSGuy Helmerdevice.  An intruder will commonly attempt to run a packet sniffer
3426ac7e896SDavid E. O'Brienon a compromised machine.  You do not need to give the intruder the
343f063d76aSMatthew Dilloncapability and most systems should not have the bpf device compiled in.
344f063d76aSMatthew Dillon.Pp
345568e4cbbSGuy HelmerBut even if you turn off the bpf device,
346568e4cbbSGuy Helmeryou still have
347568e4cbbSGuy Helmer.Pa /dev/mem
348568e4cbbSGuy Helmerand
349568e4cbbSGuy Helmer.Pa /dev/kmem
350568e4cbbSGuy Helmerto worry about.  For that matter,
351d93b26d6SMatthew Dillonthe intruder can still write to raw disk devices.
352d93b26d6SMatthew DillonAlso, there is another kernel feature called the module loader,
353568e4cbbSGuy Helmer.Xr kldload 8 .
354568e4cbbSGuy HelmerAn enterprising intruder can use a KLD module to install
355568e4cbbSGuy Helmerhis own bpf device or other sniffing device on a running kernel.
356568e4cbbSGuy HelmerTo avoid these problems you have to run
357568e4cbbSGuy Helmerthe kernel at a higher secure level, at least securelevel 1.  The securelevel
358f063d76aSMatthew Dilloncan be set with a sysctl on the kern.securelevel variable.  Once you have
359f063d76aSMatthew Dillonset the securelevel to 1, write access to raw devices will be denied and
360568e4cbbSGuy Helmerspecial chflags flags, such as
361568e4cbbSGuy Helmer.Sq schg ,
362568e4cbbSGuy Helmerwill be enforced.  You must also ensure
363568e4cbbSGuy Helmerthat the
364568e4cbbSGuy Helmer.Sq schg
365568e4cbbSGuy Helmerflag is set on critical startup binaries, directories, and
366f063d76aSMatthew Dillonscript files - everything that gets run up to the point where the securelevel
367f063d76aSMatthew Dillonis set.  This might be overdoing it, and upgrading the system is much more
368f063d76aSMatthew Dillondifficult when you operate at a higher secure level.  You may compromise and
369f063d76aSMatthew Dillonrun the system at a higher secure level but not set the schg flag for every
370d93b26d6SMatthew Dillonsystem file and directory under the sun.  Another possibility is to simply
371d93b26d6SMatthew Dillonmount / and /usr read-only.  It should be noted that being too draconian in
372d93b26d6SMatthew Dillonwhat you attempt to protect may prevent the all-important detection of an
373d93b26d6SMatthew Dillonintrusion.
374f063d76aSMatthew Dillon.Sh CHECKING FILE INTEGRITY: BINARIES, CONFIG FILES, ETC
375f063d76aSMatthew Dillon.Pp
376f063d76aSMatthew DillonWhen it comes right down to it, you can only protect your core system
377f063d76aSMatthew Dillonconfiguration and control files so much before the convenience factor
378d93b26d6SMatthew Dillonrears its ugly head.  For example, using chflags to set the schg bit
379d93b26d6SMatthew Dillonon most of the files in / and /usr is probably counterproductive because
380d93b26d6SMatthew Dillonwhile it may protect the files, it also closes a detection window.  The
381d93b26d6SMatthew Dillonlast layer of your security onion is perhaps the most important - detection.
382d93b26d6SMatthew DillonThe rest of your security is pretty much useless (or, worse, presents you with
383d93b26d6SMatthew Dillona false sense of safety) if you cannot detect potential incursions.  Half
384d93b26d6SMatthew Dillonthe job of the onion is to slow down the attacker rather then stop him
385d93b26d6SMatthew Dillonin order to give the detection side of the equation a chance to catch him in
386d93b26d6SMatthew Dillonthe act.
387f063d76aSMatthew Dillon.Pp
388d93b26d6SMatthew DillonThe best way to detect an incursion is to look for modified, missing, or
389d93b26d6SMatthew Dillonunexpected files.  The best
390d93b26d6SMatthew Dillonway to look for modified files is from another (often centralized)
391d93b26d6SMatthew Dillonlimited-access system.
392d93b26d6SMatthew DillonWriting your security scripts on the extra-secure limited-access system
393d93b26d6SMatthew Dillonmakes them mostly invisible to potential hackers, and this is important.
394d93b26d6SMatthew DillonIn order to take maximum advantage you generally have to give the
395d93b26d6SMatthew Dillonlimited-access box significant access to the other machines in the business,
396d93b26d6SMatthew Dillonusually either by doing a read-only NFS export of the other machines to the
397d93b26d6SMatthew Dillonlimited-access box, or by setting up ssh keypairs to allow the limit-access
398d93b26d6SMatthew Dillonbox to ssh to the other machines.  Except for its network traffic, NFS is
399d93b26d6SMatthew Dillonthe least visible method - allowing you to monitor the filesystems on each
400d93b26d6SMatthew Dillonclient box virtually undetected.  If your
401d93b26d6SMatthew Dillonlimited-access server is connected to the client boxes through a switch,
402d93b26d6SMatthew Dillonthe NFS method is often the better choice.  If your limited-access server
403d93b26d6SMatthew Dillonis connected to the client boxes through a hub or through several layers
404d93b26d6SMatthew Dillonof routing, the NFS method may be too insecure (network-wise) and using ssh
405d93b26d6SMatthew Dillonmay be the better choice even with the audit-trail tracks that ssh lays.
406d93b26d6SMatthew Dillon.Pp
407d93b26d6SMatthew DillonOnce you give a limit-access box at least read access to the client systems
408d93b26d6SMatthew Dillonit is supposed to monitor, you must write scripts to do the actual
409d93b26d6SMatthew Dillonmonitoring.  Given an NFS mount, you can write scripts out of simple system
410d93b26d6SMatthew Dillonutilities such as
411d93b26d6SMatthew Dillon.Xr find 1
412d93b26d6SMatthew Dillonand
413d93b26d6SMatthew Dillon.Xr md5 1
414d93b26d6SMatthew DillonIt is best to physically md5 the client-box files boxes at least once a
415ad27d066SMatthew Dillonday, and to test control files such as those found in
416ad27d066SMatthew Dillon.Pa /etc
417ad27d066SMatthew Dillonand
418ad27d066SMatthew Dillon.Pa /usr/local/etc
419d93b26d6SMatthew Dilloneven more often.  When mismatches are found relative to the base md5
420d93b26d6SMatthew Dilloninformation the limited-access machine knows is valid, it should scream at
421d93b26d6SMatthew Dillona sysadmin to go check it out.  A good security script will also check for
422d93b26d6SMatthew Dilloninappropriate suid binaries and for new or deleted files on system partitions
423d93b26d6SMatthew Dillonsuch as
424d93b26d6SMatthew Dillon.Pa /
425568e4cbbSGuy Helmerand
426568e4cbbSGuy Helmer.Pa /usr
427f063d76aSMatthew Dillon.Pp
428d93b26d6SMatthew DillonWhen using ssh rather then NFS, writing the security script is much more
429d93b26d6SMatthew Dillondifficult.   You essentially have to
430d93b26d6SMatthew Dillon.Pa scp
431d93b26d6SMatthew Dillonthe scripts to the client box in order to run them, making them visible, and
432d93b26d6SMatthew Dillonfor safety you also need to scp the binaries (such as find) that those scripts
433d93b26d6SMatthew Dillonuse.  The ssh daemon on the client box may already be compromised.  All in all,
434d93b26d6SMatthew Dillonusing ssh may be necessary when running over unsecure links, but it's also a
435d93b26d6SMatthew Dillonlot harder to deal with.
436f063d76aSMatthew Dillon.Pp
437f063d76aSMatthew DillonA good security script will also check for changes to user and staff members
438ad27d066SMatthew Dillonaccess configuration files:
439ad27d066SMatthew Dillon.Pa .rhosts ,
440ad27d066SMatthew Dillon.Pa .shosts ,
441ad27d066SMatthew Dillon.Pa .ssh/authorized_keys
442ad27d066SMatthew Dillonand so forth... files that might fall outside the purview of the MD5 check.
443f063d76aSMatthew Dillon.Pp
444d93b26d6SMatthew DillonIf you have a huge amount of user disk space it may take too long to run
445d93b26d6SMatthew Dillonthrough every file on those partitions.  In this case, setting mount
446d93b26d6SMatthew Dillonflags to disallow suid binaries and devices on those partitions is a good
447d93b26d6SMatthew Dillonidea.  The
448568e4cbbSGuy Helmer.Sq nodev
449d93b26d6SMatthew Dillonand
450d93b26d6SMatthew Dillon.Sq nosuid
451d93b26d6SMatthew Dillonoptions
452d93b26d6SMatthew Dillon.Po
453d93b26d6SMatthew Dillonsee
454d93b26d6SMatthew Dillon.Xr mount 8
455568e4cbbSGuy Helmer.Pc
456d93b26d6SMatthew Dillonare what you want to look into.  I would scan them anyway at least once a
457d93b26d6SMatthew Dillonweek, since the object of this layer is to detect a break-in whether or
458d93b26d6SMatthew Dillonnot the breakin is effective.
459f063d76aSMatthew Dillon.Pp
460568e4cbbSGuy HelmerProcess accounting
461568e4cbbSGuy Helmer.Po
462568e4cbbSGuy Helmersee
463f437b38cSChris Costello.Xr accton 8
464568e4cbbSGuy Helmer.Pc
465568e4cbbSGuy Helmeris a relatively low-overhead feature of
4666ac7e896SDavid E. O'Brienthe operating system which I recommend using as a post-break-in evaluation
4676ac7e896SDavid E. O'Brienmechanism.  It is especially useful in tracking down how an intruder has
468d93b26d6SMatthew Dillonactually broken into a system, assuming the file is still intact after
4696ac7e896SDavid E. O'Brienthe break-in occurs.
470f063d76aSMatthew Dillon.Pp
471f063d76aSMatthew DillonFinally, security scripts should process the log files and the logs themselves
472d93b26d6SMatthew Dillonshould be generated in as secure a manner as possible - remote syslog can be
4736ac7e896SDavid E. O'Brienvery useful.  An intruder tries to cover his tracks, and log files are critical
474d93b26d6SMatthew Dillonto the sysadmin trying to track down the time and method of the initial
475d93b26d6SMatthew Dillonbreak-in.  One way to keep a permanent record of the log files is to run
476d93b26d6SMatthew Dillonthe system console to a serial port and collect the information on a
477d93b26d6SMatthew Dilloncontinuing basis through a secure machine monitoring the consoles.
478f063d76aSMatthew Dillon.Sh PARANOIA
479f063d76aSMatthew Dillon.Pp
4807626ae52SMatthew DillonA little paranoia never hurts.  As a rule, a sysadmin can add any number
481f063d76aSMatthew Dillonof security features as long as they do not effect convenience, and
482f063d76aSMatthew Dilloncan add security features that do effect convenience with some added
483d93b26d6SMatthew Dillonthought.  Even more importantly, a security administrator should mix it up
484d93b26d6SMatthew Dillona bit - if you use recommendations such as those given by this manual
485d93b26d6SMatthew Dillonpage verbatim, you give away your methodologies to the prospective
486d93b26d6SMatthew Dillonhacker who also has access to this manual page.
487f063d76aSMatthew Dillon.Sh SPECIAL SECTION ON D.O.S. ATTACKS
488f063d76aSMatthew Dillon.Pp
4896ac7e896SDavid E. O'BrienThis section covers Denial of Service attacks.  A DOS attack is typically
490f063d76aSMatthew Dillona packet attack.  While there isn't much you can do about modern spoofed
491f063d76aSMatthew Dillonpacket attacks that saturate your network, you can generally limit the damage
492f063d76aSMatthew Dillonby ensuring that the attacks cannot take down your servers.
493f063d76aSMatthew Dillon.Bl -enum -offset indent
494f063d76aSMatthew Dillon.It
495f063d76aSMatthew DillonLimiting server forks
496f063d76aSMatthew Dillon.It
497f063d76aSMatthew DillonLimiting springboard attacks (ICMP response attacks, ping broadcast, etc...)
498f063d76aSMatthew Dillon.It
499f063d76aSMatthew DillonKernel Route Cache
500f063d76aSMatthew Dillon.El
501f063d76aSMatthew Dillon.Pp
502f063d76aSMatthew DillonA common DOS attack is against a forking server that attempts to cause the
5036ac7e896SDavid E. O'Brienserver to eat processes, file descriptors, and memory until the machine
504568e4cbbSGuy Helmerdies.  Inetd
505568e4cbbSGuy Helmer.Po
506568e4cbbSGuy Helmersee
507568e4cbbSGuy Helmer.Xr inetd 8
508568e4cbbSGuy Helmer.Pc
509568e4cbbSGuy Helmerhas several options to limit this sort of attack.
510f063d76aSMatthew DillonIt should be noted that while it is possible to prevent a machine from going
511f063d76aSMatthew Dillondown it is not generally possible to prevent a service from being disrupted
512f063d76aSMatthew Dillonby the attack.  Read the inetd manual page carefully and pay specific attention
513568e4cbbSGuy Helmerto the
514568e4cbbSGuy Helmer.Fl c ,
515568e4cbbSGuy Helmer.Fl C ,
516568e4cbbSGuy Helmerand
517568e4cbbSGuy Helmer.Fl R
518568e4cbbSGuy Helmeroptions.  Note that spoofed-IP attacks will circumvent
519568e4cbbSGuy Helmerthe
520568e4cbbSGuy Helmer.Fl C
521568e4cbbSGuy Helmeroption to inetd, so typically a combination of options must be used.
522f063d76aSMatthew DillonSome standalone servers have self-fork-limitation parameters.
523f063d76aSMatthew Dillon.Pp
524568e4cbbSGuy HelmerSendmail has its
525568e4cbbSGuy Helmer.Fl OMaxDaemonChildren
526568e4cbbSGuy Helmeroption which tends to work much
527f6c24291SGuy Helmerbetter than trying to use sendmail's load limiting options due to the
528568e4cbbSGuy Helmerload lag.  You should specify a
529568e4cbbSGuy Helmer.Cm MaxDaemonChildren
530568e4cbbSGuy Helmerparameter when you start
531f063d76aSMatthew Dillonsendmail high enough to handle your expected load but no so high that the
532f063d76aSMatthew Dilloncomputer cannot handle that number of sendmails without falling on its face.
533568e4cbbSGuy HelmerIt is also prudent to run sendmail in queued mode
534568e4cbbSGuy Helmer.Pq Fl ODeliveryMode=queued
535568e4cbbSGuy Helmerand to run the daemon
536568e4cbbSGuy Helmer.Pq Cm sendmail -bd
537568e4cbbSGuy Helmerseparate from the queue-runs
538568e4cbbSGuy Helmer.Pq Cm sendmail -q15m .
539568e4cbbSGuy HelmerIf you still want realtime delivery you can run the queue
540568e4cbbSGuy Helmerat a much lower interval, such as
541568e4cbbSGuy Helmer.Fl q1m ,
542568e4cbbSGuy Helmerbut be sure to specify a reasonable
543568e4cbbSGuy Helmer.Cm MaxDaemonChildren
544568e4cbbSGuy Helmeroption for that sendmail to prevent cascade failures.
545f063d76aSMatthew Dillon.Pp
546f063d76aSMatthew DillonSyslogd can be attacked directly and it is strongly recommended that you use
547568e4cbbSGuy Helmerthe
548568e4cbbSGuy Helmer.Fl s
549568e4cbbSGuy Helmeroption whenever possible, and the
550568e4cbbSGuy Helmer.Fl a
551568e4cbbSGuy Helmeroption otherwise.
552f063d76aSMatthew Dillon.Pp
553f063d76aSMatthew DillonYou should also be fairly careful
554f063d76aSMatthew Dillonwith connect-back services such as tcpwrapper's reverse-identd, which can
555f063d76aSMatthew Dillonbe attacked directly.  You generally do not want to use the reverse-ident
556f063d76aSMatthew Dillonfeature of tcpwrappers for this reason.
557f063d76aSMatthew Dillon.Pp
558f063d76aSMatthew DillonIt is a very good idea to protect internal services from external access
559f063d76aSMatthew Dillonby firewalling them off at your border routers.  The idea here is to prevent
560f063d76aSMatthew Dillonsaturation attacks from outside your LAN, not so much to protect internal
56185752545SGuy Helmerservices from network-based root compromise.  Always configure an exclusive
562568e4cbbSGuy Helmerfirewall, i.e.
563568e4cbbSGuy Helmer.So
564568e4cbbSGuy Helmerfirewall everything *except* ports A, B, C, D, and M-Z
565568e4cbbSGuy Helmer.Sc .
566568e4cbbSGuy HelmerThis
567f063d76aSMatthew Dillonway you can firewall off all of your low ports except for certain specific
568568e4cbbSGuy Helmerservices such as named
569568e4cbbSGuy Helmer.Pq if you are primary for a zone ,
570568e4cbbSGuy Helmerntalkd, sendmail,
571f063d76aSMatthew Dillonand other internet-accessible services.
572f063d76aSMatthew DillonIf you try to configure the firewall the other
573f063d76aSMatthew Dillonway - as an inclusive or permissive firewall, there is a good chance that you
574568e4cbbSGuy Helmerwill forget to
575568e4cbbSGuy Helmer.Sq close
576568e4cbbSGuy Helmera couple of services or that you will add a new internal
577f063d76aSMatthew Dillonservice and forget to update the firewall.  You can still open up the
578f063d76aSMatthew Dillonhigh-numbered port range on the firewall to allow permissive-like operation
579568e4cbbSGuy Helmerwithout compromising your low ports.  Also take note that
580f6f8f44dSAlexey Zelkin.Fx
581568e4cbbSGuy Helmerallows you to
582f063d76aSMatthew Dilloncontrol the range of port numbers used for dynamic binding via the various
583568e4cbbSGuy Helmernet.inet.ip.portrange sysctl's
584568e4cbbSGuy Helmer.Pq sysctl -a \&| fgrep portrange ,
585568e4cbbSGuy Helmerwhich can also
586f063d76aSMatthew Dillonease the complexity of your firewall's configuration.  I usually use a normal
587f063d76aSMatthew Dillonfirst/last range of 4000 to 5000, and a hiport range of 49152 to 65535, then
588568e4cbbSGuy Helmerblock everything under 4000 off in my firewall
589568e4cbbSGuy Helmer.Po
590568e4cbbSGuy Helmerexcept for certain specific
591568e4cbbSGuy Helmerinternet-accessible ports, of course
592568e4cbbSGuy Helmer.Pc .
593f063d76aSMatthew Dillon.Pp
594f063d76aSMatthew DillonAnother common DOS attack is called a springboard attack - to attack a server
595f063d76aSMatthew Dillonin a manner that causes the server to generate responses which then overload
596f063d76aSMatthew Dillonthe server, the local network, or some other machine.  The most common attack
597568e4cbbSGuy Helmerof this nature is the ICMP PING BROADCAST attack.  The attacker spoofs ping
598f063d76aSMatthew Dillonpackets sent to your LAN's broadcast address with the source IP address set
599f063d76aSMatthew Dillonto the actual machine they wish to attack.  If your border routers are not
600f063d76aSMatthew Dillonconfigured to stomp on ping's to broadcast addresses, your LAN winds up
601f063d76aSMatthew Dillongenerating sufficient responses to the spoofed source address to saturate the
602f063d76aSMatthew Dillonvictim, especially when the attacker uses the same trick on several dozen
603f063d76aSMatthew Dillonbroadcast addresses over several dozen different networks at once.  Broadcast
604f063d76aSMatthew Dillonattacks of over a hundred and twenty megabits have been measured.  A second
605f063d76aSMatthew Dilloncommon springboard attack is against the ICMP error reporting system.  By
606f063d76aSMatthew Dillonconstructing packets that generate ICMP error responses, an attacker can
607f063d76aSMatthew Dillonsaturate a server's incoming network and cause the server to saturate its
608f063d76aSMatthew Dillonoutgoing network with ICMP responses.  This type of attack can also crash the
609f063d76aSMatthew Dillonserver by running it out of mbuf's, especially if the server cannot drain the
610568e4cbbSGuy HelmerICMP responses it generates fast enough.  The
611f6f8f44dSAlexey Zelkin.Fx
612568e4cbbSGuy Helmerkernel has a new kernel
613f063d76aSMatthew Dilloncompile option called ICMP_BANDLIM which limits the effectiveness of these
614f063d76aSMatthew Dillonsorts of attacks.  The last major class of springboard attacks is related to
615f063d76aSMatthew Dilloncertain internal inetd services such as the udp echo service.  An attacker
616f063d76aSMatthew Dillonsimply spoofs a UDP packet with the source address being server A's echo port,
617f063d76aSMatthew Dillonand the destination address being server B's echo port, where server A and B
618f063d76aSMatthew Dillonare both on your LAN.  The two servers then bounce this one packet back and
619f063d76aSMatthew Dillonforth between each other.  The attacker can overload both servers and their
620f063d76aSMatthew DillonLANs simply by injecting a few packets in this manner.  Similar problems
6217626ae52SMatthew Dillonexist with the internal chargen port.  A competent sysadmin will turn off all
622f063d76aSMatthew Dillonof these inetd-internal test services.
623f063d76aSMatthew Dillon.Pp
624f063d76aSMatthew DillonSpoofed packet attacks may also be used to overload the kernel route cache.
625f063d76aSMatthew DillonRefer to the net.inet.ip.rtexpire, rtminexpire, and rtmaxcache sysctl
626f063d76aSMatthew Dillonparameters.  A spoofed packet attack that uses a random source IP will cause
627f063d76aSMatthew Dillonthe kernel to generate a temporary cached route in the route table, viewable
628568e4cbbSGuy Helmerwith
629568e4cbbSGuy Helmer.Sq netstat -rna \&| fgrep W3 .
630568e4cbbSGuy HelmerThese routes typically timeout in 1600
631f063d76aSMatthew Dillonseconds or so.  If the kernel detects that the cached route table has gotten
632f063d76aSMatthew Dillontoo big it will dynamically reduce the rtexpire but will never decrease it to
633f063d76aSMatthew Dillonless then rtminexpire.  There are two problems:  (1) The kernel does not react
634f063d76aSMatthew Dillonquickly enough when a lightly loaded server is suddenly attacked, and (2) The
635f063d76aSMatthew Dillonrtminexpire is not low enough for the kernel to survive a sustained attack.
636f063d76aSMatthew DillonIf your servers are connected to the internet via a T3 or better it may be
63785752545SGuy Helmerprudent to manually override both rtexpire and rtminexpire via
63885752545SGuy Helmer.Xr sysctl 8 .
639568e4cbbSGuy HelmerNever set either parameter to zero
640568e4cbbSGuy Helmer.Pq unless you want to crash the machine :-) .
641f063d76aSMatthew DillonSetting both parameters to 2 seconds should be sufficient to protect the route
642f063d76aSMatthew Dillontable from attack.
643d93b26d6SMatthew Dillon.Sh ACCESS ISSUES WITH KERBEROS AND SSH
644d93b26d6SMatthew Dillon.Pp
645d93b26d6SMatthew DillonThere are a few issues with both kerberos and ssh that need to be addressed
646d93b26d6SMatthew Dillonif you intend to use them.  Kerberos V is an excellent authentication
647d93b26d6SMatthew Dillonprotocol but the kerberized telnet and rlogin suck rocks.  There are bugs that
648d93b26d6SMatthew Dillonmake them unsuitable for dealing with binary streams.  Also, by default
649d93b26d6SMatthew Dillonkerberos does not encrypt a session unless you use the
650d93b26d6SMatthew Dillon.Fl x
651d93b26d6SMatthew Dillonoption.  Ssh encrypts everything by default.
652d93b26d6SMatthew Dillon.Pp
6539baaab27SDima DorfmanSsh works quite well in every respect except when it is set up to
6549baaab27SDima Dorfmanforward encryption keys.
6559baaab27SDima DorfmanWhat this means is that if you have a secure workstation holding
656d93b26d6SMatthew Dillonkeys that give you access to the rest of the system, and you ssh to an
657d93b26d6SMatthew Dillonunsecure machine, your keys becomes exposed.  The actual keys themselves are
658d93b26d6SMatthew Dillonnot exposed, but ssh installs a forwarding port for the duration of your
659d93b26d6SMatthew Dillonlogin and if a hacker has broken root on the unsecure machine he can utilize
660d93b26d6SMatthew Dillonthat port to use your keys to gain access to any other machine that your
661d93b26d6SMatthew Dillonkeys unlock.
662d93b26d6SMatthew Dillon.Pp
663d93b26d6SMatthew DillonWe recommend that you use ssh in combination with kerberos whenever possible
664d93b26d6SMatthew Dillonfor staff logins.  Ssh can be compiled with kerberos support.  This reduces
665d93b26d6SMatthew Dillonyour reliance on potentially exposable ssh keys while at the same time
666d93b26d6SMatthew Dillonprotecting passwords via kerberos.  Ssh keys
667d93b26d6SMatthew Dillonshould only be used for automated tasks from secure machines (something
668d93b26d6SMatthew Dillonthat kerberos is unsuited to).  We also recommend that you either turn off
669d93b26d6SMatthew Dillonkey-forwarding in the ssh configuration, or that you make use of the
670d93b26d6SMatthew Dillon.Pa "from=IP/DOMAIN"
671d93b26d6SMatthew Dillonoption that ssh allows in its
672d93b26d6SMatthew Dillon.Pa authorized_keys
673d93b26d6SMatthew Dillonfile to make the key only useable to entities logging in from specific
674d93b26d6SMatthew Dillonmachines.
675f063d76aSMatthew Dillon.Sh SEE ALSO
676f063d76aSMatthew Dillon.Xr chflags 1 ,
677f063d76aSMatthew Dillon.Xr find 1 ,
6786ac7e896SDavid E. O'Brien.Xr kerberos 1 ,
679f063d76aSMatthew Dillon.Xr md5 1 ,
680f6f8f44dSAlexey Zelkin.Xr netstat 1 ,
6818596de53SNik Clayton.Xr openssl 1 ,
6825521ff5aSRuslan Ermilov.Xr ssh 1 ,
6836ac7e896SDavid E. O'Brien.Xr xdm 1 ,
684d93b26d6SMatthew Dillon.Xr group 5 ,
685ad27d066SMatthew Dillon.Xr ttys 5 ,
6868596de53SNik Clayton.Xr accton 8 ,
687d93b26d6SMatthew Dillon.Xr init 8 ,
6888596de53SNik Clayton.Xr sshd 8 ,
689ad27d066SMatthew Dillon.Xr sysctl 8 ,
6908596de53SNik Clayton.Xr syslogd 8 ,
691ad27d066SMatthew Dillon.Xr vipw 8
692f063d76aSMatthew Dillon.Sh HISTORY
693f063d76aSMatthew DillonThe
694f063d76aSMatthew Dillon.Nm
695568e4cbbSGuy Helmermanual page was originally written by
696568e4cbbSGuy Helmer.An Matthew Dillon
697568e4cbbSGuy Helmerand first appeared
698568e4cbbSGuy Helmerin
69985752545SGuy Helmer.Fx 3.1 ,
700568e4cbbSGuy HelmerDecember 1998.
701