xref: /freebsd/share/man/man7/security.7 (revision dab59af3bcc7cb7ba01569d3044894b3e860ad56)
15ecb12e3SWarner Losh.\" Copyright (C) 1998 Matthew Dillon. All rights reserved.
2*dab59af3SLi-Wen Hsu.\" Copyright (c) 2019 The FreeBSD Foundation
3762caeb4SKonstantin Belousov.\"
4762caeb4SKonstantin Belousov.\" Parts of this documentation were written by
5762caeb4SKonstantin Belousov.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
6762caeb4SKonstantin Belousov.\" from the FreeBSD Foundation.
75ecb12e3SWarner Losh.\"
85ecb12e3SWarner Losh.\" Redistribution and use in source and binary forms, with or without
95ecb12e3SWarner Losh.\" modification, are permitted provided that the following conditions
105ecb12e3SWarner Losh.\" are met:
115ecb12e3SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
125ecb12e3SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
135ecb12e3SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
145ecb12e3SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
155ecb12e3SWarner Losh.\"    documentation and/or other materials provided with the distribution.
165ecb12e3SWarner Losh.\"
175ecb12e3SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
185ecb12e3SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
195ecb12e3SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
205ecb12e3SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
215ecb12e3SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
225ecb12e3SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
235ecb12e3SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
245ecb12e3SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
255ecb12e3SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
265ecb12e3SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
275ecb12e3SWarner Losh.\" SUCH DAMAGE.
28f063d76aSMatthew Dillon.\"
29297bb39bSEd Maste.Dd June 1, 2024
30f063d76aSMatthew Dillon.Dt SECURITY 7
313d45e180SRuslan Ermilov.Os
32f063d76aSMatthew Dillon.Sh NAME
33f063d76aSMatthew Dillon.Nm security
3452fc88b5SGiorgos Keramidas.Nd introduction to security under FreeBSD
35f063d76aSMatthew Dillon.Sh DESCRIPTION
36297bb39bSEd MasteSee
37297bb39bSEd Maste.Xr mitigations 7
38297bb39bSEd Mastefor a description of vulnerability mitigations in
39297bb39bSEd Maste.Fx .
40297bb39bSEd MasteThis man page documents other
41297bb39bSEd Maste.Fx
42297bb39bSEd Mastesecurity related topics.
43297bb39bSEd Maste.Pp
44f063d76aSMatthew DillonSecurity is a function that begins and ends with the system administrator.
45f063d76aSMatthew DillonWhile all
46f063d76aSMatthew Dillon.Bx
47d93b26d6SMatthew Dillonmulti-user systems have some inherent security, the job of building and
48992e4638SRobert Watsonmaintaining additional security mechanisms to keep users
49454ba768SRuslan Ermilov.Dq honest
50568e4cbbSGuy Helmeris probably
51454ba768SRuslan Ermilovone of the single largest undertakings of the sysadmin.
52454ba768SRuslan ErmilovMachines are
53f063d76aSMatthew Dillononly as secure as you make them, and security concerns are ever competing
54568e4cbbSGuy Helmerwith the human necessity for convenience.
55568e4cbbSGuy Helmer.Ux
56568e4cbbSGuy Helmersystems,
576ac7e896SDavid E. O'Brienin general, are capable of running a huge number of simultaneous processes
58454ba768SRuslan Ermilovand many of these processes operate as servers \(em meaning that external
59454ba768SRuslan Ermiloventities can connect and talk to them.
60454ba768SRuslan ErmilovAs yesterday's mini-computers and mainframes
61f063d76aSMatthew Dillonbecome today's desktops, and as computers become networked and internetworked,
62f063d76aSMatthew Dillonsecurity becomes an ever bigger issue.
63f063d76aSMatthew Dillon.Pp
64454ba768SRuslan ErmilovSecurity is best implemented through a layered onion approach.
65454ba768SRuslan ErmilovIn a nutshell,
66d93b26d6SMatthew Dillonwhat you want to do is to create as many layers of security as are convenient
67454ba768SRuslan Ermilovand then carefully monitor the system for intrusions.
68d93b26d6SMatthew Dillon.Pp
69454ba768SRuslan ErmilovSystem security also pertains to dealing with various forms of attacks,
70d93b26d6SMatthew Dillonincluding attacks that attempt to crash or otherwise make a system unusable
71454ba768SRuslan Ermilovbut do not attempt to break root.
72454ba768SRuslan ErmilovSecurity concerns can be split up into
73d93b26d6SMatthew Dillonseveral categories:
74f063d76aSMatthew Dillon.Bl -enum -offset indent
75f063d76aSMatthew Dillon.It
76454ba768SRuslan ErmilovDenial of Service attacks (DoS)
77f063d76aSMatthew Dillon.It
78f063d76aSMatthew DillonUser account compromises
79f063d76aSMatthew Dillon.It
806ac7e896SDavid E. O'BrienRoot compromise through accessible servers
81f063d76aSMatthew Dillon.It
826ac7e896SDavid E. O'BrienRoot compromise via user accounts
83d93b26d6SMatthew Dillon.It
84d93b26d6SMatthew DillonBackdoor creation
85f063d76aSMatthew Dillon.El
86f063d76aSMatthew Dillon.Pp
87f063d76aSMatthew DillonA denial of service attack is an action that deprives the machine of needed
88454ba768SRuslan Ermilovresources.
89454ba768SRuslan ErmilovTypically, DoS attacks are brute-force mechanisms that attempt
90f063d76aSMatthew Dillonto crash or otherwise make a machine unusable by overwhelming its servers or
91454ba768SRuslan Ermilovnetwork stack.
92454ba768SRuslan ErmilovSome DoS attacks try to take advantages of bugs in the
93454ba768SRuslan Ermilovnetworking stack to crash a machine with a single packet.
94454ba768SRuslan ErmilovThe latter can
95454ba768SRuslan Ermilovonly be fixed by applying a bug fix to the kernel.
96454ba768SRuslan ErmilovAttacks on servers can
97d93b26d6SMatthew Dillonoften be fixed by properly specifying options to limit the load the servers
98454ba768SRuslan Ermilovincur on the system under adverse conditions.
99454ba768SRuslan ErmilovBrute-force network attacks are harder to deal with.
100454ba768SRuslan ErmilovA spoofed-packet attack, for example, is
1017c86a74bSMike Pritchardnearly impossible to stop short of cutting your system off from the Internet.
1026b05959aSChristian BruefferIt may not be able to take your machine down, but it can fill up your Internet
103d93b26d6SMatthew Dillonpipe.
104f063d76aSMatthew Dillon.Pp
105454ba768SRuslan ErmilovA user account compromise is even more common than a DoS attack.
106b4cfdbfeSBrooks DavisSome
107b4cfdbfeSBrooks Davissysadmins still run
108b4cfdbfeSBrooks Davis.Nm telnetd
109454ba768SRuslan Ermilovand
110454ba768SRuslan Ermilov.Xr ftpd 8
111454ba768SRuslan Ermilovservers on their machines.
112454ba768SRuslan ErmilovThese servers, by default, do not operate over encrypted
113454ba768SRuslan Ermilovconnections.
114454ba768SRuslan ErmilovThe result is that if you have any moderate-sized user base,
115f063d76aSMatthew Dillonone or more of your users logging into your system from a remote location
116c4d9468eSRuslan Ermilov(which is the most common and convenient way to log in to a system)
117454ba768SRuslan Ermilovwill have his or her password sniffed.
118454ba768SRuslan ErmilovThe attentive system administrator will analyze
119d93b26d6SMatthew Dillonhis remote access logs looking for suspicious source addresses
120f063d76aSMatthew Dilloneven for successful logins.
121f063d76aSMatthew Dillon.Pp
122f063d76aSMatthew DillonOne must always assume that once an attacker has access to a user account,
123454ba768SRuslan Ermilovthe attacker can break root.
124454ba768SRuslan ErmilovHowever, the reality is that in a well secured
125f063d76aSMatthew Dillonand maintained system, access to a user account does not necessarily give the
126454ba768SRuslan Ermilovattacker access to root.
127454ba768SRuslan ErmilovThe distinction is important because without access
128f063d76aSMatthew Dillonto root the attacker cannot generally hide his tracks and may, at best, be
129b94231daSDima Dorfmanable to do nothing more than mess with the user's files or crash the machine.
130d93b26d6SMatthew DillonUser account compromises are very common because users tend not to take the
1317c86a74bSMike Pritchardprecautions that sysadmins take.
132f063d76aSMatthew Dillon.Pp
133d93b26d6SMatthew DillonSystem administrators must keep in mind that there are potentially many ways
134454ba768SRuslan Ermilovto break root on a machine.
135454ba768SRuslan ErmilovThe attacker may know the root password,
136d93b26d6SMatthew Dillonthe attacker
137f063d76aSMatthew Dillonmay find a bug in a root-run server and be able to break root over a network
138454ba768SRuslan Ermilovconnection to that server, or the attacker may know of a bug in an SUID-root
139f063d76aSMatthew Dillonprogram that allows the attacker to break root once he has broken into a
140454ba768SRuslan Ermilovuser's account.
141454ba768SRuslan ErmilovIf an attacker has found a way to break root on a machine,
142f167d7fbSSheldon Hearnthe attacker may not have a need to install a backdoor.
143d93b26d6SMatthew DillonMany of the root holes found and closed to date involve a considerable amount
14447afd1f8SDaniel Harrisof work by the attacker to clean up after himself, so most attackers do install
145454ba768SRuslan Ermilovbackdoors.
146454ba768SRuslan ErmilovThis gives you a convenient way to detect the attacker.
147454ba768SRuslan ErmilovMaking
14847afd1f8SDaniel Harrisit impossible for an attacker to install a backdoor may actually be detrimental
1494c0d8029SDaniel Harristo your security because it will not close off the hole the attacker used to
150ac095af5SRebecca Cranbreak in originally.
151f063d76aSMatthew Dillon.Pp
152d93b26d6SMatthew DillonSecurity remedies should always be implemented with a multi-layered
153454ba768SRuslan Ermilov.Dq onion peel
154f063d76aSMatthew Dillonapproach and can be categorized as follows:
155f063d76aSMatthew Dillon.Bl -enum -offset indent
156f063d76aSMatthew Dillon.It
157f063d76aSMatthew DillonSecuring root and staff accounts
158f063d76aSMatthew Dillon.It
159454ba768SRuslan ErmilovSecuring root \(em root-run servers and SUID/SGID binaries
160f063d76aSMatthew Dillon.It
161f063d76aSMatthew DillonSecuring user accounts
162f063d76aSMatthew Dillon.It
163f063d76aSMatthew DillonSecuring the password file
164f063d76aSMatthew Dillon.It
165f063d76aSMatthew DillonSecuring the kernel core, raw devices, and file systems
166f063d76aSMatthew Dillon.It
167d93b26d6SMatthew DillonQuick detection of inappropriate changes made to the system
168f063d76aSMatthew Dillon.It
169f063d76aSMatthew DillonParanoia
170f063d76aSMatthew Dillon.El
171f063d76aSMatthew Dillon.Sh SECURING THE ROOT ACCOUNT AND SECURING STAFF ACCOUNTS
172454ba768SRuslan ErmilovDo not bother securing staff accounts if you have not secured the root
173454ba768SRuslan Ermilovaccount.
174454ba768SRuslan ErmilovMost systems have a password assigned to the root account.
175454ba768SRuslan ErmilovThe
176568e4cbbSGuy Helmerfirst thing you do is assume that the password is
177454ba768SRuslan Ermilov.Em always
178454ba768SRuslan Ermilovcompromised.
179454ba768SRuslan ErmilovThis does not mean that you should remove the password.
180454ba768SRuslan ErmilovThe
181d93b26d6SMatthew Dillonpassword is almost always necessary for console access to the machine.
182d93b26d6SMatthew DillonWhat it does mean is that you should not make it possible to use the password
183d93b26d6SMatthew Dillonoutside of the console or possibly even with a
184d93b26d6SMatthew Dillon.Xr su 1
185454ba768SRuslan Ermilovutility.
186454ba768SRuslan ErmilovFor example, make sure that your PTYs are specified as being
187b4b13ebaSDaniel Gerzo.Dq Li insecure
188d93b26d6SMatthew Dillonin the
189454ba768SRuslan Ermilov.Pa /etc/ttys
190d93b26d6SMatthew Dillonfile
191454ba768SRuslan Ermilovso that direct root logins via
192454ba768SRuslan Ermilov.Xr telnet 1
193454ba768SRuslan Ermilovare disallowed.
194454ba768SRuslan ErmilovIf using
195454ba768SRuslan Ermilovother login services such as
196454ba768SRuslan Ermilov.Xr sshd 8 ,
197454ba768SRuslan Ermilovmake sure that direct root logins are
198454ba768SRuslan Ermilovdisabled there as well.
199454ba768SRuslan ErmilovConsider every access method \(em services such as
200454ba768SRuslan Ermilov.Xr ftp 1
201454ba768SRuslan Ermilovoften fall through the cracks.
202454ba768SRuslan ErmilovDirect root logins should only be allowed
203d93b26d6SMatthew Dillonvia the system console.
204f063d76aSMatthew Dillon.Pp
2057626ae52SMatthew DillonOf course, as a sysadmin you have to be able to get to root, so we open up
206454ba768SRuslan Ermilova few holes.
207454ba768SRuslan ErmilovBut we make sure these holes require additional password
208454ba768SRuslan Ermilovverification to operate.
209454ba768SRuslan ErmilovOne way to make root accessible is to add appropriate
210454ba768SRuslan Ermilovstaff accounts to the
211454ba768SRuslan Ermilov.Dq Li wheel
212454ba768SRuslan Ermilovgroup (in
213c4d9468eSRuslan Ermilov.Pa /etc/group ) .
214454ba768SRuslan ErmilovThe staff members placed in the
215454ba768SRuslan Ermilov.Li wheel
216454ba768SRuslan Ermilovgroup are allowed to
217454ba768SRuslan Ermilov.Xr su 1
218454ba768SRuslan Ermilovto root.
219454ba768SRuslan ErmilovYou should never give staff
220454ba768SRuslan Ermilovmembers native
221454ba768SRuslan Ermilov.Li wheel
222454ba768SRuslan Ermilovaccess by putting them in the
223454ba768SRuslan Ermilov.Li wheel
224454ba768SRuslan Ermilovgroup in their password entry.
225454ba768SRuslan ErmilovStaff accounts should be placed in a
226454ba768SRuslan Ermilov.Dq Li staff
227454ba768SRuslan Ermilovgroup, and then added to the
228454ba768SRuslan Ermilov.Li wheel
229454ba768SRuslan Ermilovgroup via the
230454ba768SRuslan Ermilov.Pa /etc/group
231454ba768SRuslan Ermilovfile.
232454ba768SRuslan ErmilovOnly those staff members who actually need to have root access
233454ba768SRuslan Ermilovshould be placed in the
234454ba768SRuslan Ermilov.Li wheel
235454ba768SRuslan Ermilovgroup.
236454ba768SRuslan ErmilovIt is also possible, when using an
237454ba768SRuslan Ermilovauthentication method such as Kerberos, to use Kerberos's
238454ba768SRuslan Ermilov.Pa .k5login
239d93b26d6SMatthew Dillonfile in the root account to allow a
240d93b26d6SMatthew Dillon.Xr ksu 1
241454ba768SRuslan Ermilovto root without having to place anyone at all in the
242454ba768SRuslan Ermilov.Li wheel
243454ba768SRuslan Ermilovgroup.
244454ba768SRuslan ErmilovThis
245454ba768SRuslan Ermilovmay be the better solution since the
246454ba768SRuslan Ermilov.Li wheel
247454ba768SRuslan Ermilovmechanism still allows an
248d93b26d6SMatthew Dillonintruder to break root if the intruder has gotten hold of your password
249454ba768SRuslan Ermilovfile and can break into a staff account.
250454ba768SRuslan ErmilovWhile having the
251454ba768SRuslan Ermilov.Li wheel
252454ba768SRuslan Ermilovmechanism
253454ba768SRuslan Ermilovis better than having nothing at all, it is not necessarily the safest
254d93b26d6SMatthew Dillonoption.
255f063d76aSMatthew Dillon.Pp
256f063d76aSMatthew DillonAn indirect way to secure the root account is to secure your staff accounts
257f063d76aSMatthew Dillonby using an alternative login access method and *'ing out the crypted password
258454ba768SRuslan Ermilovfor the staff accounts.
259454ba768SRuslan ErmilovThis way an intruder may be able to steal the password
26047afd1f8SDaniel Harrisfile but will not be able to break into any staff accounts or root, even if
26147afd1f8SDaniel Harrisroot has a crypted password associated with it (assuming, of course, that
262454ba768SRuslan Ermilovyou have limited root access to the console).
263454ba768SRuslan ErmilovStaff members
264f063d76aSMatthew Dillonget into their staff accounts through a secure login mechanism such as
265a3f9c9fcSRuslan Ermilov.Xr kerberos 8
266568e4cbbSGuy Helmeror
267568e4cbbSGuy Helmer.Xr ssh 1
268568e4cbbSGuy Helmerusing a private/public
269454ba768SRuslan Ermilovkey pair.
270454ba768SRuslan ErmilovWhen you use something like Kerberos you generally must secure
271454ba768SRuslan Ermilovthe machines which run the Kerberos servers and your desktop workstation.
272454ba768SRuslan ErmilovWhen you use a public/private key pair with SSH, you must generally secure
273454ba768SRuslan Ermilovthe machine you are logging in
274454ba768SRuslan Ermilov.Em from
275c4d9468eSRuslan Ermilov(typically your workstation),
276568e4cbbSGuy Helmerbut you can
277f063d76aSMatthew Dillonalso add an additional layer of protection to the key pair by password
278568e4cbbSGuy Helmerprotecting the keypair when you create it with
279568e4cbbSGuy Helmer.Xr ssh-keygen 1 .
280568e4cbbSGuy HelmerBeing able
2812125f57aSMateusz Piotrowskito star-out the passwords for staff accounts also guarantees that staff
2822125f57aSMateusz Piotrowskimembers can only log in through secure access methods that you have set up.
283454ba768SRuslan ErmilovYou can
284f063d76aSMatthew Dillonthus force all staff members to use secure, encrypted connections for
285454ba768SRuslan Ermilovall their sessions which closes an important hole used by many intruders: that
286f063d76aSMatthew Dillonof sniffing the network from an unrelated, less secure machine.
287f063d76aSMatthew Dillon.Pp
288f063d76aSMatthew DillonThe more indirect security mechanisms also assume that you are logging in
289454ba768SRuslan Ermilovfrom a more restrictive server to a less restrictive server.
290454ba768SRuslan ErmilovFor example,
291454ba768SRuslan Ermilovif your main box is running all sorts of servers, your workstation should not
292454ba768SRuslan Ermilovbe running any.
293454ba768SRuslan ErmilovIn order for your workstation to be reasonably secure
294f063d76aSMatthew Dillonyou should run as few servers as possible, up to and including no servers
295f063d76aSMatthew Dillonat all, and you should run a password-protected screen blanker.
296f063d76aSMatthew DillonOf course, given physical access to
297454ba768SRuslan Ermilova workstation, an attacker can break any sort of security you put on it.
298f063d76aSMatthew DillonThis is definitely a problem that you should consider but you should also
2996ac7e896SDavid E. O'Brienconsider the fact that the vast majority of break-ins occur remotely, over
3007626ae52SMatthew Dillona network, from people who do not have physical access to your workstation or
301f063d76aSMatthew Dillonservers.
302f063d76aSMatthew Dillon.Pp
303454ba768SRuslan ErmilovUsing something like Kerberos also gives you the ability to disable or
304f063d76aSMatthew Dillonchange the password for a staff account in one place and have it immediately
305454ba768SRuslan Ermilovaffect all the machines the staff member may have an account on.
306454ba768SRuslan ErmilovIf a staff
307f063d76aSMatthew Dillonmember's account gets compromised, the ability to instantly change his
308454ba768SRuslan Ermilovpassword on all machines should not be underrated.
309454ba768SRuslan ErmilovWith discrete passwords, changing a password on N machines can be a mess.
310454ba768SRuslan ErmilovYou can also impose
311454ba768SRuslan Ermilovre-passwording restrictions with Kerberos: not only can a Kerberos ticket
312454ba768SRuslan Ermilovbe made to timeout after a while, but the Kerberos system can require that
313568e4cbbSGuy Helmerthe user choose a new password after a certain period of time
314c4d9468eSRuslan Ermilov(say, once a month).
31547afd1f8SDaniel Harris.Sh SECURING ROOT \(em ROOT-RUN SERVERS AND SUID/SGID BINARIES
316454ba768SRuslan ErmilovThe prudent sysadmin only runs the servers he needs to, no more, no less.
317454ba768SRuslan ErmilovBe aware that third party servers are often the most bug-prone.
318454ba768SRuslan ErmilovFor example,
319454ba768SRuslan Ermilovrunning an old version of
320454ba768SRuslan Ermilov.Xr imapd 8
321454ba768SRuslan Ermilovor
322f0ea72a0SChristian Brueffer.Xr popper 8 Pq Pa ports/mail/popper
323454ba768SRuslan Ermilovis like giving a universal root
324454ba768SRuslan Ermilovticket out to the entire world.
325454ba768SRuslan ErmilovNever run a server that you have not checked
326454ba768SRuslan Ermilovout carefully.
327454ba768SRuslan ErmilovMany servers do not need to be run as root.
328454ba768SRuslan ErmilovFor example,
329454ba768SRuslan Ermilovthe
330454ba768SRuslan Ermilov.Xr talkd 8 ,
331454ba768SRuslan Ermilov.Xr comsat 8 ,
332454ba768SRuslan Ermilovand
333454ba768SRuslan Ermilov.Xr fingerd 8
334454ba768SRuslan Ermilovdaemons can be run in special user
335454ba768SRuslan Ermilov.Dq sandboxes .
336454ba768SRuslan ErmilovA sandbox is not perfect unless you go to a large amount of trouble, but the
337454ba768SRuslan Ermilovonion approach to security still stands: if someone is able to break in
338f063d76aSMatthew Dillonthrough a server running in a sandbox, they still have to break out of the
339454ba768SRuslan Ermilovsandbox.
340454ba768SRuslan ErmilovThe more layers the attacker must break through, the lower the
341454ba768SRuslan Ermilovlikelihood of his success.
342454ba768SRuslan ErmilovRoot holes have historically been found in
343f063d76aSMatthew Dillonvirtually every server ever run as root, including basic system servers.
344454ba768SRuslan ErmilovIf you are running a machine through which people only log in via
345454ba768SRuslan Ermilov.Xr sshd 8
346454ba768SRuslan Ermilovand never log in via
347b4cfdbfeSBrooks Davis.Nm telnetd
348b4cfdbfeSBrooks Davisthen turn off this service!
349f063d76aSMatthew Dillon.Pp
350f6f8f44dSAlexey Zelkin.Fx
351454ba768SRuslan Ermilovnow defaults to running
352454ba768SRuslan Ermilov.Xr talkd 8 ,
353454ba768SRuslan Ermilov.Xr comsat 8 ,
354454ba768SRuslan Ermilovand
355454ba768SRuslan Ermilov.Xr fingerd 8
356454ba768SRuslan Ermilovin a sandbox.
357454ba768SRuslan ErmilovDepending on whether you
358f063d76aSMatthew Dillonare installing a new system or upgrading an existing system, the special
359454ba768SRuslan Ermilovuser accounts used by these sandboxes may not be installed.
360454ba768SRuslan ErmilovThe prudent
3617626ae52SMatthew Dillonsysadmin would research and implement sandboxes for servers whenever possible.
362f063d76aSMatthew Dillon.Pp
363f063d76aSMatthew DillonThere are a number of other servers that typically do not run in sandboxes:
364454ba768SRuslan Ermilov.Xr sendmail 8 ,
365454ba768SRuslan Ermilov.Xr popper 8 ,
366454ba768SRuslan Ermilov.Xr imapd 8 ,
367454ba768SRuslan Ermilov.Xr ftpd 8 ,
368454ba768SRuslan Ermilovand others.
369454ba768SRuslan ErmilovThere are alternatives to
3709518a247SJens Schweikhardtsome of these, but installing them may require more work than you are willing
371568e4cbbSGuy Helmerto put
372c4d9468eSRuslan Ermilov(the convenience factor strikes again).
373568e4cbbSGuy HelmerYou may have to run these
3746ac7e896SDavid E. O'Brienservers as root and rely on other mechanisms to detect break-ins that might
375f063d76aSMatthew Dillonoccur through them.
376f063d76aSMatthew Dillon.Pp
377454ba768SRuslan ErmilovThe other big potential root hole in a system are the SUID-root and SGID
378454ba768SRuslan Ermilovbinaries installed on the system.
379454ba768SRuslan ErmilovMost of these binaries, such as
3807e527d26SEd Maste.Xr su 1 ,
381568e4cbbSGuy Helmerreside in
382454ba768SRuslan Ermilov.Pa /bin , /sbin , /usr/bin ,
383568e4cbbSGuy Helmeror
384568e4cbbSGuy Helmer.Pa /usr/sbin .
385568e4cbbSGuy HelmerWhile nothing is 100% safe,
386454ba768SRuslan Ermilovthe system-default SUID and SGID binaries can be considered reasonably safe.
387454ba768SRuslan ErmilovStill, root holes are occasionally found in these binaries.
388454ba768SRuslan ErmilovA root hole
389454ba768SRuslan Ermilovwas found in Xlib in 1998 that made
390f0ea72a0SChristian Brueffer.Xr xterm 1 Pq Pa ports/x11/xterm
391454ba768SRuslan Ermilov(which is typically SUID)
392568e4cbbSGuy Helmervulnerable.
393454ba768SRuslan ErmilovIt is better to be safe than sorry and the prudent sysadmin will restrict SUID
394f063d76aSMatthew Dillonbinaries that only staff should run to a special group that only staff can
395568e4cbbSGuy Helmeraccess, and get rid of
396454ba768SRuslan Ermilov.Pq Dq Li "chmod 000"
397454ba768SRuslan Ermilovany SUID binaries that nobody uses.
398454ba768SRuslan ErmilovA server with no display generally does not need an
399825225e5SJens Schweikhardt.Xr xterm 1 Pq Pa ports/x11/xterm
400454ba768SRuslan Ermilovbinary.
401454ba768SRuslan ErmilovSGID binaries can be almost as dangerous.
402454ba768SRuslan ErmilovIf an intruder can break an SGID-kmem binary the
403568e4cbbSGuy Helmerintruder might be able to read
404568e4cbbSGuy Helmer.Pa /dev/kmem
405568e4cbbSGuy Helmerand thus read the crypted password
406454ba768SRuslan Ermilovfile, potentially compromising any passworded account.
407454ba768SRuslan ErmilovAlternatively an
408454ba768SRuslan Ermilovintruder who breaks group
409454ba768SRuslan Ermilov.Dq Li kmem
410454ba768SRuslan Ermilovcan monitor keystrokes sent through PTYs,
411454ba768SRuslan Ermilovincluding PTYs used by users who log in through secure methods.
412454ba768SRuslan ErmilovAn intruder
413454ba768SRuslan Ermilovthat breaks the
414454ba768SRuslan Ermilov.Dq Li tty
415454ba768SRuslan Ermilovgroup can write to almost any user's TTY.
416454ba768SRuslan ErmilovIf a user
417d93b26d6SMatthew Dillonis running a terminal
418d93b26d6SMatthew Dillonprogram or emulator with a keyboard-simulation feature, the intruder can
419d93b26d6SMatthew Dillonpotentially
420f063d76aSMatthew Dillongenerate a data stream that causes the user's terminal to echo a command, which
421f063d76aSMatthew Dillonis then run as that user.
422f063d76aSMatthew Dillon.Sh SECURING USER ACCOUNTS
423454ba768SRuslan ErmilovUser accounts are usually the most difficult to secure.
424454ba768SRuslan ErmilovWhile you can impose
425454ba768SRuslan Ermilovdraconian access restrictions on your staff and *-out their passwords, you
426454ba768SRuslan Ermilovmay not be able to do so with any general user accounts you might have.
427454ba768SRuslan ErmilovIf
428f063d76aSMatthew Dillonyou do have sufficient control then you may win out and be able to secure the
429454ba768SRuslan Ermilovuser accounts properly.
430454ba768SRuslan ErmilovIf not, you simply have to be more vigilant in your
431454ba768SRuslan Ermilovmonitoring of those accounts.
432454ba768SRuslan ErmilovUse of SSH and Kerberos for user accounts is
433d93b26d6SMatthew Dillonmore problematic due to the extra administration and technical support
434d93b26d6SMatthew Dillonrequired, but still a very good solution compared to a crypted password
435d93b26d6SMatthew Dillonfile.
436f063d76aSMatthew Dillon.Sh SECURING THE PASSWORD FILE
437f063d76aSMatthew DillonThe only sure fire way is to *-out as many passwords as you can and
438454ba768SRuslan Ermilovuse SSH or Kerberos for access to those accounts.
439454ba768SRuslan ErmilovEven though the
440568e4cbbSGuy Helmercrypted password file
441568e4cbbSGuy Helmer.Pq Pa /etc/spwd.db
442568e4cbbSGuy Helmercan only be read by root, it may
443568e4cbbSGuy Helmerbe possible for an intruder to obtain read access to that file even if the
444f063d76aSMatthew Dillonattacker cannot obtain root-write access.
445f063d76aSMatthew Dillon.Pp
446f063d76aSMatthew DillonYour security scripts should always check for and report changes to
447568e4cbbSGuy Helmerthe password file
448c4d9468eSRuslan Ermilov(see
449454ba768SRuslan Ermilov.Sx CHECKING FILE INTEGRITY
450c4d9468eSRuslan Ermilovbelow).
451f063d76aSMatthew Dillon.Sh SECURING THE KERNEL CORE, RAW DEVICES, AND FILE SYSTEMS
452f063d76aSMatthew DillonIf an attacker breaks root he can do just about anything, but there
453454ba768SRuslan Ermilovare certain conveniences.
454454ba768SRuslan ErmilovFor example, most modern kernels have a packet sniffing device driver built in.
455454ba768SRuslan ErmilovUnder
456f6f8f44dSAlexey Zelkin.Fx
457568e4cbbSGuy Helmerit is called
458568e4cbbSGuy Helmerthe
459454ba768SRuslan Ermilov.Xr bpf 4
460454ba768SRuslan Ermilovdevice.
461454ba768SRuslan ErmilovAn intruder will commonly attempt to run a packet sniffer
462454ba768SRuslan Ermilovon a compromised machine.
463454ba768SRuslan ErmilovYou do not need to give the intruder the
464454ba768SRuslan Ermilovcapability and most systems should not have the
465454ba768SRuslan Ermilov.Xr bpf 4
466454ba768SRuslan Ermilovdevice compiled in.
467f063d76aSMatthew Dillon.Pp
468454ba768SRuslan ErmilovBut even if you turn off the
469454ba768SRuslan Ermilov.Xr bpf 4
470454ba768SRuslan Ermilovdevice, you still have
471568e4cbbSGuy Helmer.Pa /dev/mem
472568e4cbbSGuy Helmerand
473568e4cbbSGuy Helmer.Pa /dev/kmem
474454ba768SRuslan Ermilovto worry about.
475454ba768SRuslan ErmilovFor that matter,
476d93b26d6SMatthew Dillonthe intruder can still write to raw disk devices.
477d93b26d6SMatthew DillonAlso, there is another kernel feature called the module loader,
478568e4cbbSGuy Helmer.Xr kldload 8 .
479568e4cbbSGuy HelmerAn enterprising intruder can use a KLD module to install
480454ba768SRuslan Ermilovhis own
481454ba768SRuslan Ermilov.Xr bpf 4
482454ba768SRuslan Ermilovdevice or other sniffing device on a running kernel.
483568e4cbbSGuy HelmerTo avoid these problems you have to run
484e17c0e32SGary W. Swearingenthe kernel at a higher security level, at least level 1.
485e17c0e32SGary W. SwearingenThe security level can be set with a
486454ba768SRuslan Ermilov.Xr sysctl 8
487454ba768SRuslan Ermilovon the
488454ba768SRuslan Ermilov.Va kern.securelevel
489454ba768SRuslan Ermilovvariable.
490454ba768SRuslan ErmilovOnce you have
491e17c0e32SGary W. Swearingenset the security level to 1, write access to raw devices will be denied and
492454ba768SRuslan Ermilovspecial
493454ba768SRuslan Ermilov.Xr chflags 1
494454ba768SRuslan Ermilovflags, such as
495454ba768SRuslan Ermilov.Cm schg ,
496454ba768SRuslan Ermilovwill be enforced.
497454ba768SRuslan ErmilovYou must also ensure
498568e4cbbSGuy Helmerthat the
499454ba768SRuslan Ermilov.Cm schg
500568e4cbbSGuy Helmerflag is set on critical startup binaries, directories, and
501e17c0e32SGary W. Swearingenscript files \(em everything that gets run
502e17c0e32SGary W. Swearingenup to the point where the security level is set.
503454ba768SRuslan ErmilovThis might be overdoing it, and upgrading the system is much more
504e17c0e32SGary W. Swearingendifficult when you operate at a higher security level.
505454ba768SRuslan ErmilovYou may compromise and
506e17c0e32SGary W. Swearingenrun the system at a higher security level but not set the
507454ba768SRuslan Ermilov.Cm schg
508454ba768SRuslan Ermilovflag for every
509454ba768SRuslan Ermilovsystem file and directory under the sun.
510454ba768SRuslan ErmilovAnother possibility is to simply
511454ba768SRuslan Ermilovmount
512454ba768SRuslan Ermilov.Pa /
513454ba768SRuslan Ermilovand
514454ba768SRuslan Ermilov.Pa /usr
515454ba768SRuslan Ermilovread-only.
516454ba768SRuslan ErmilovIt should be noted that being too draconian in
517d93b26d6SMatthew Dillonwhat you attempt to protect may prevent the all-important detection of an
518d93b26d6SMatthew Dillonintrusion.
519e17c0e32SGary W. Swearingen.Pp
520e17c0e32SGary W. SwearingenThe kernel runs with five different security levels.
521e17c0e32SGary W. SwearingenAny super-user process can raise the level, but no process
522e17c0e32SGary W. Swearingencan lower it.
523e17c0e32SGary W. SwearingenThe security levels are:
524e17c0e32SGary W. Swearingen.Bl -tag -width flag
525e17c0e32SGary W. Swearingen.It Ic -1
526e17c0e32SGary W. SwearingenPermanently insecure mode \- always run the system in insecure mode.
527e17c0e32SGary W. SwearingenThis is the default initial value.
528e17c0e32SGary W. Swearingen.It Ic 0
529e17c0e32SGary W. SwearingenInsecure mode \- immutable and append-only flags may be turned off.
530e17c0e32SGary W. SwearingenAll devices may be read or written subject to their permissions.
531e17c0e32SGary W. Swearingen.It Ic 1
532e17c0e32SGary W. SwearingenSecure mode \- the system immutable and system append-only flags may not
533e17c0e32SGary W. Swearingenbe turned off;
534e17c0e32SGary W. Swearingendisks for mounted file systems,
535ff8a6926SGiorgos Keramidas.Pa /dev/mem
536e17c0e32SGary W. Swearingenand
537ff8a6926SGiorgos Keramidas.Pa /dev/kmem
538ff8a6926SGiorgos Keramidasmay not be opened for writing;
539e17c0e32SGary W. Swearingen.Pa /dev/io
540ff8a6926SGiorgos Keramidas(if your platform has it) may not be opened at all;
541e17c0e32SGary W. Swearingenkernel modules (see
542e17c0e32SGary W. Swearingen.Xr kld 4 )
543e17c0e32SGary W. Swearingenmay not be loaded or unloaded.
544ef522f95SDavid E. O'BrienThe kernel debugger may not be entered using the
545ef522f95SDavid E. O'Brien.Va debug.kdb.enter
546cab10561SMark Johnstonsysctl unless a
547cab10561SMark Johnston.Xr MAC 9
548cab10561SMark Johnstonpolicy grants access, for example using
549cab10561SMark Johnston.Xr mac_ddb 4 .
550ef522f95SDavid E. O'BrienA panic or trap cannot be forced using the
55193644056SWarner Losh.Va debug.kdb.panic ,
55293644056SWarner Losh.Va debug.kdb.panic_str
553ef522f95SDavid E. O'Brienand other sysctl's.
554e17c0e32SGary W. Swearingen.It Ic 2
555e17c0e32SGary W. SwearingenHighly secure mode \- same as secure mode, plus disks may not be
556e17c0e32SGary W. Swearingenopened for writing (except by
557e17c0e32SGary W. Swearingen.Xr mount 2 )
558e17c0e32SGary W. Swearingenwhether mounted or not.
559e17c0e32SGary W. SwearingenThis level precludes tampering with file systems by unmounting them,
560e17c0e32SGary W. Swearingenbut also inhibits running
561e17c0e32SGary W. Swearingen.Xr newfs 8
562e17c0e32SGary W. Swearingenwhile the system is multi-user.
563e17c0e32SGary W. Swearingen.Pp
564e17c0e32SGary W. SwearingenIn addition, kernel time changes are restricted to less than or equal to one
565e17c0e32SGary W. Swearingensecond.
566e17c0e32SGary W. SwearingenAttempts to change the time by more than this will log the message
567e17c0e32SGary W. Swearingen.Dq Time adjustment clamped to +1 second .
568e17c0e32SGary W. Swearingen.It Ic 3
569e17c0e32SGary W. SwearingenNetwork secure mode \- same as highly secure mode, plus
570e17c0e32SGary W. SwearingenIP packet filter rules (see
571e17c0e32SGary W. Swearingen.Xr ipfw 8 ,
572e17c0e32SGary W. Swearingen.Xr ipfirewall 4
573e17c0e32SGary W. Swearingenand
574e17c0e32SGary W. Swearingen.Xr pfctl 8 )
575e17c0e32SGary W. Swearingencannot be changed and
576e17c0e32SGary W. Swearingen.Xr dummynet 4
577e17c0e32SGary W. Swearingenor
578e17c0e32SGary W. Swearingen.Xr pf 4
579e17c0e32SGary W. Swearingenconfiguration cannot be adjusted.
580e17c0e32SGary W. Swearingen.El
581e17c0e32SGary W. Swearingen.Pp
5820ebb41beSCeri DaviesThe security level can be configured with variables documented in
583814b16baSGlen Barber.Xr rc.conf 5 .
584f063d76aSMatthew Dillon.Sh CHECKING FILE INTEGRITY: BINARIES, CONFIG FILES, ETC
585f063d76aSMatthew DillonWhen it comes right down to it, you can only protect your core system
586f063d76aSMatthew Dillonconfiguration and control files so much before the convenience factor
587454ba768SRuslan Ermilovrears its ugly head.
588454ba768SRuslan ErmilovFor example, using
589454ba768SRuslan Ermilov.Xr chflags 1
590454ba768SRuslan Ermilovto set the
591454ba768SRuslan Ermilov.Cm schg
592454ba768SRuslan Ermilovbit on most of the files in
593454ba768SRuslan Ermilov.Pa /
594454ba768SRuslan Ermilovand
595454ba768SRuslan Ermilov.Pa /usr
596454ba768SRuslan Ermilovis probably counterproductive because
597454ba768SRuslan Ermilovwhile it may protect the files, it also closes a detection window.
598454ba768SRuslan ErmilovThe
59947afd1f8SDaniel Harrislast layer of your security onion is perhaps the most important \(em detection.
600d93b26d6SMatthew DillonThe rest of your security is pretty much useless (or, worse, presents you with
601454ba768SRuslan Ermilova false sense of safety) if you cannot detect potential incursions.
602454ba768SRuslan ErmilovHalf
603074ad115SRuslan Ermilovthe job of the onion is to slow down the attacker rather than stop him
6044c0d8029SDaniel Harrisin order to give the detection layer a chance to catch him in
605d93b26d6SMatthew Dillonthe act.
606f063d76aSMatthew Dillon.Pp
607d93b26d6SMatthew DillonThe best way to detect an incursion is to look for modified, missing, or
608454ba768SRuslan Ermilovunexpected files.
609454ba768SRuslan ErmilovThe best
610d93b26d6SMatthew Dillonway to look for modified files is from another (often centralized)
611d93b26d6SMatthew Dillonlimited-access system.
612d93b26d6SMatthew DillonWriting your security scripts on the extra-secure limited-access system
61347afd1f8SDaniel Harrismakes them mostly invisible to potential attackers, and this is important.
614d93b26d6SMatthew DillonIn order to take maximum advantage you generally have to give the
615d93b26d6SMatthew Dillonlimited-access box significant access to the other machines in the business,
616d93b26d6SMatthew Dillonusually either by doing a read-only NFS export of the other machines to the
617454ba768SRuslan Ermilovlimited-access box, or by setting up SSH keypairs to allow the limit-access
618454ba768SRuslan Ermilovbox to SSH to the other machines.
619454ba768SRuslan ErmilovExcept for its network traffic, NFS is
62047afd1f8SDaniel Harristhe least visible method \(em allowing you to monitor the file systems on each
621454ba768SRuslan Ermilovclient box virtually undetected.
622454ba768SRuslan ErmilovIf your
623d93b26d6SMatthew Dillonlimited-access server is connected to the client boxes through a switch,
624454ba768SRuslan Ermilovthe NFS method is often the better choice.
625454ba768SRuslan ErmilovIf your limited-access server
626d93b26d6SMatthew Dillonis connected to the client boxes through a hub or through several layers
627454ba768SRuslan Ermilovof routing, the NFS method may be too insecure (network-wise) and using SSH
628454ba768SRuslan Ermilovmay be the better choice even with the audit-trail tracks that SSH lays.
629d93b26d6SMatthew Dillon.Pp
630d93b26d6SMatthew DillonOnce you give a limit-access box at least read access to the client systems
631d93b26d6SMatthew Dillonit is supposed to monitor, you must write scripts to do the actual
632454ba768SRuslan Ermilovmonitoring.
633454ba768SRuslan ErmilovGiven an NFS mount, you can write scripts out of simple system
634d93b26d6SMatthew Dillonutilities such as
635d93b26d6SMatthew Dillon.Xr find 1
636d93b26d6SMatthew Dillonand
637454ba768SRuslan Ermilov.Xr md5 1 .
638454ba768SRuslan ErmilovIt is best to physically
639d93b26d6SMatthew Dillon.Xr md5 1
640454ba768SRuslan Ermilovthe client-box files boxes at least once a
641ad27d066SMatthew Dillonday, and to test control files such as those found in
642ad27d066SMatthew Dillon.Pa /etc
643ad27d066SMatthew Dillonand
644ad27d066SMatthew Dillon.Pa /usr/local/etc
645454ba768SRuslan Ermiloveven more often.
646454ba768SRuslan ErmilovWhen mismatches are found relative to the base MD5
647d93b26d6SMatthew Dilloninformation the limited-access machine knows is valid, it should scream at
648454ba768SRuslan Ermilova sysadmin to go check it out.
649454ba768SRuslan ErmilovA good security script will also check for
650454ba768SRuslan Ermilovinappropriate SUID binaries and for new or deleted files on system partitions
651d93b26d6SMatthew Dillonsuch as
652d93b26d6SMatthew Dillon.Pa /
653568e4cbbSGuy Helmerand
654454ba768SRuslan Ermilov.Pa /usr .
655f063d76aSMatthew Dillon.Pp
656454ba768SRuslan ErmilovWhen using SSH rather than NFS, writing the security script is much more
657454ba768SRuslan Ermilovdifficult.
658454ba768SRuslan ErmilovYou essentially have to
659454ba768SRuslan Ermilov.Xr scp 1
660d93b26d6SMatthew Dillonthe scripts to the client box in order to run them, making them visible, and
661454ba768SRuslan Ermilovfor safety you also need to
662454ba768SRuslan Ermilov.Xr scp 1
663454ba768SRuslan Ermilovthe binaries (such as
664454ba768SRuslan Ermilov.Xr find 1 )
665454ba768SRuslan Ermilovthat those scripts use.
666454ba768SRuslan ErmilovThe
667454ba768SRuslan Ermilov.Xr sshd 8
668454ba768SRuslan Ermilovdaemon on the client box may already be compromised.
669454ba768SRuslan ErmilovAll in all,
670454ba768SRuslan Ermilovusing SSH may be necessary when running over unsecure links, but it is also a
671d93b26d6SMatthew Dillonlot harder to deal with.
672f063d76aSMatthew Dillon.Pp
673f063d76aSMatthew DillonA good security script will also check for changes to user and staff members
674ad27d066SMatthew Dillonaccess configuration files:
675454ba768SRuslan Ermilov.Pa .rhosts , .shosts , .ssh/authorized_keys
6765203edcdSRuslan Ermilovand so forth, files that might fall outside the purview of the MD5 check.
677f063d76aSMatthew Dillon.Pp
678d93b26d6SMatthew DillonIf you have a huge amount of user disk space it may take too long to run
679454ba768SRuslan Ermilovthrough every file on those partitions.
680454ba768SRuslan ErmilovIn this case, setting mount
681e354922cSRuslan Ermilovflags to disallow SUID binaries on those partitions is a good
682454ba768SRuslan Ermilovidea.
683454ba768SRuslan ErmilovThe
684454ba768SRuslan Ermilov.Cm nosuid
685e354922cSRuslan Ermilovoption
686c4d9468eSRuslan Ermilov(see
687c4d9468eSRuslan Ermilov.Xr mount 8 )
688e354922cSRuslan Ermilovis what you want to look into.
689454ba768SRuslan ErmilovI would scan them anyway at least once a
690d93b26d6SMatthew Dillonweek, since the object of this layer is to detect a break-in whether or
691a30de06bSCeri Daviesnot the break-in is effective.
692f063d76aSMatthew Dillon.Pp
693568e4cbbSGuy HelmerProcess accounting
694c4d9468eSRuslan Ermilov(see
695c4d9468eSRuslan Ermilov.Xr accton 8 )
696568e4cbbSGuy Helmeris a relatively low-overhead feature of
6976ac7e896SDavid E. O'Brienthe operating system which I recommend using as a post-break-in evaluation
698454ba768SRuslan Ermilovmechanism.
699454ba768SRuslan ErmilovIt is especially useful in tracking down how an intruder has
700d93b26d6SMatthew Dillonactually broken into a system, assuming the file is still intact after
7016ac7e896SDavid E. O'Brienthe break-in occurs.
702f063d76aSMatthew Dillon.Pp
703f063d76aSMatthew DillonFinally, security scripts should process the log files and the logs themselves
70447afd1f8SDaniel Harrisshould be generated in as secure a manner as possible \(em remote syslog can be
705454ba768SRuslan Ermilovvery useful.
706454ba768SRuslan ErmilovAn intruder tries to cover his tracks, and log files are critical
707d93b26d6SMatthew Dillonto the sysadmin trying to track down the time and method of the initial
708454ba768SRuslan Ermilovbreak-in.
709454ba768SRuslan ErmilovOne way to keep a permanent record of the log files is to run
710d93b26d6SMatthew Dillonthe system console to a serial port and collect the information on a
711d93b26d6SMatthew Dilloncontinuing basis through a secure machine monitoring the consoles.
712f063d76aSMatthew Dillon.Sh PARANOIA
713454ba768SRuslan ErmilovA little paranoia never hurts.
714454ba768SRuslan ErmilovAs a rule, a sysadmin can add any number
71547afd1f8SDaniel Harrisof security features as long as they do not affect convenience, and
71647afd1f8SDaniel Harriscan add security features that do affect convenience with some added
717454ba768SRuslan Ermilovthought.
718454ba768SRuslan ErmilovEven more importantly, a security administrator should mix it up
71947afd1f8SDaniel Harrisa bit \(em if you use recommendations such as those given by this manual
720d93b26d6SMatthew Dillonpage verbatim, you give away your methodologies to the prospective
72147afd1f8SDaniel Harrisattacker who also has access to this manual page.
722454ba768SRuslan Ermilov.Sh SPECIAL SECTION ON DoS ATTACKS
723454ba768SRuslan ErmilovThis section covers Denial of Service attacks.
724454ba768SRuslan ErmilovA DoS attack is typically a packet attack.
725454ba768SRuslan ErmilovWhile there is not much you can do about modern spoofed
726f063d76aSMatthew Dillonpacket attacks that saturate your network, you can generally limit the damage
727f063d76aSMatthew Dillonby ensuring that the attacks cannot take down your servers.
728f063d76aSMatthew Dillon.Bl -enum -offset indent
729f063d76aSMatthew Dillon.It
730f063d76aSMatthew DillonLimiting server forks
731f063d76aSMatthew Dillon.It
732454ba768SRuslan ErmilovLimiting springboard attacks (ICMP response attacks, ping broadcast, etc.)
733f063d76aSMatthew Dillon.It
734f063d76aSMatthew DillonKernel Route Cache
735f063d76aSMatthew Dillon.El
736f063d76aSMatthew Dillon.Pp
737454ba768SRuslan ErmilovA common DoS attack is against a forking server that attempts to cause the
7386ac7e896SDavid E. O'Brienserver to eat processes, file descriptors, and memory until the machine
739454ba768SRuslan Ermilovdies.
740454ba768SRuslan ErmilovThe
741454ba768SRuslan Ermilov.Xr inetd 8
742454ba768SRuslan Ermilovserver
743568e4cbbSGuy Helmerhas several options to limit this sort of attack.
744f063d76aSMatthew DillonIt should be noted that while it is possible to prevent a machine from going
745f063d76aSMatthew Dillondown it is not generally possible to prevent a service from being disrupted
746454ba768SRuslan Ermilovby the attack.
747454ba768SRuslan ErmilovRead the
748454ba768SRuslan Ermilov.Xr inetd 8
749454ba768SRuslan Ermilovmanual page carefully and pay specific attention
750568e4cbbSGuy Helmerto the
751454ba768SRuslan Ermilov.Fl c , C ,
752568e4cbbSGuy Helmerand
753568e4cbbSGuy Helmer.Fl R
754454ba768SRuslan Ermilovoptions.
755454ba768SRuslan ErmilovNote that spoofed-IP attacks will circumvent
756568e4cbbSGuy Helmerthe
757568e4cbbSGuy Helmer.Fl C
758454ba768SRuslan Ermilovoption to
759454ba768SRuslan Ermilov.Xr inetd 8 ,
760454ba768SRuslan Ermilovso typically a combination of options must be used.
761f063d76aSMatthew DillonSome standalone servers have self-fork-limitation parameters.
762f063d76aSMatthew Dillon.Pp
763454ba768SRuslan ErmilovThe
764454ba768SRuslan Ermilov.Xr sendmail 8
765454ba768SRuslan Ermilovdaemon has its
766568e4cbbSGuy Helmer.Fl OMaxDaemonChildren
767568e4cbbSGuy Helmeroption which tends to work much
768454ba768SRuslan Ermilovbetter than trying to use
769454ba768SRuslan Ermilov.Xr sendmail 8 Ns 's
770454ba768SRuslan Ermilovload limiting options due to the
771454ba768SRuslan Ermilovload lag.
772454ba768SRuslan ErmilovYou should specify a
773454ba768SRuslan Ermilov.Va MaxDaemonChildren
774568e4cbbSGuy Helmerparameter when you start
775454ba768SRuslan Ermilov.Xr sendmail 8
776454ba768SRuslan Ermilovhigh enough to handle your expected load but not so high that the
777454ba768SRuslan Ermilovcomputer cannot handle that number of
778454ba768SRuslan Ermilov.Nm sendmail Ns 's
779454ba768SRuslan Ermilovwithout falling on its face.
780454ba768SRuslan ErmilovIt is also prudent to run
781454ba768SRuslan Ermilov.Xr sendmail 8
782454ba768SRuslan Ermilovin
783454ba768SRuslan Ermilov.Dq queued
784454ba768SRuslan Ermilovmode
785568e4cbbSGuy Helmer.Pq Fl ODeliveryMode=queued
786568e4cbbSGuy Helmerand to run the daemon
787454ba768SRuslan Ermilov.Pq Dq Nm sendmail Fl bd
788568e4cbbSGuy Helmerseparate from the queue-runs
789454ba768SRuslan Ermilov.Pq Dq Nm sendmail Fl q15m .
790454ba768SRuslan ErmilovIf you still want real-time delivery you can run the queue
791568e4cbbSGuy Helmerat a much lower interval, such as
792568e4cbbSGuy Helmer.Fl q1m ,
793568e4cbbSGuy Helmerbut be sure to specify a reasonable
794454ba768SRuslan Ermilov.Va MaxDaemonChildren
795454ba768SRuslan Ermilovoption for that
796454ba768SRuslan Ermilov.Xr sendmail 8
797454ba768SRuslan Ermilovto prevent cascade failures.
798f063d76aSMatthew Dillon.Pp
799454ba768SRuslan ErmilovThe
800454ba768SRuslan Ermilov.Xr syslogd 8
801454ba768SRuslan Ermilovdaemon can be attacked directly and it is strongly recommended that you use
802568e4cbbSGuy Helmerthe
803568e4cbbSGuy Helmer.Fl s
804568e4cbbSGuy Helmeroption whenever possible, and the
805568e4cbbSGuy Helmer.Fl a
806568e4cbbSGuy Helmeroption otherwise.
807f063d76aSMatthew Dillon.Pp
808f063d76aSMatthew DillonYou should also be fairly careful
809f063d76aSMatthew Dillonwith connect-back services such as tcpwrapper's reverse-identd, which can
810454ba768SRuslan Ermilovbe attacked directly.
811454ba768SRuslan ErmilovYou generally do not want to use the reverse-ident
812f063d76aSMatthew Dillonfeature of tcpwrappers for this reason.
813f063d76aSMatthew Dillon.Pp
814f063d76aSMatthew DillonIt is a very good idea to protect internal services from external access
815454ba768SRuslan Ermilovby firewalling them off at your border routers.
816454ba768SRuslan ErmilovThe idea here is to prevent
817f063d76aSMatthew Dillonsaturation attacks from outside your LAN, not so much to protect internal
818454ba768SRuslan Ermilovservices from network-based root compromise.
819454ba768SRuslan ErmilovAlways configure an exclusive
820454ba768SRuslan Ermilovfirewall, i.e.,
821568e4cbbSGuy Helmer.So
82247afd1f8SDaniel Harrisfirewall everything
82347afd1f8SDaniel Harris.Em except
82447afd1f8SDaniel Harrisports A, B, C, D, and M-Z
825568e4cbbSGuy Helmer.Sc .
826568e4cbbSGuy HelmerThis
827f063d76aSMatthew Dillonway you can firewall off all of your low ports except for certain specific
828454ba768SRuslan Ermilovservices such as
829454ba768SRuslan Ermilov.Xr talkd 8 ,
830454ba768SRuslan Ermilov.Xr sendmail 8 ,
831f063d76aSMatthew Dillonand other internet-accessible services.
832f063d76aSMatthew DillonIf you try to configure the firewall the other
83347afd1f8SDaniel Harrisway \(em as an inclusive or permissive firewall, there is a good chance that you
834568e4cbbSGuy Helmerwill forget to
835454ba768SRuslan Ermilov.Dq close
836568e4cbbSGuy Helmera couple of services or that you will add a new internal
837454ba768SRuslan Ermilovservice and forget to update the firewall.
838454ba768SRuslan ErmilovYou can still open up the
839f063d76aSMatthew Dillonhigh-numbered port range on the firewall to allow permissive-like operation
840454ba768SRuslan Ermilovwithout compromising your low ports.
841454ba768SRuslan ErmilovAlso take note that
842f6f8f44dSAlexey Zelkin.Fx
843568e4cbbSGuy Helmerallows you to
844f063d76aSMatthew Dilloncontrol the range of port numbers used for dynamic binding via the various
845454ba768SRuslan Ermilov.Va net.inet.ip.portrange
846454ba768SRuslan Ermilovsysctl's
847454ba768SRuslan Ermilov.Pq Dq Li "sysctl net.inet.ip.portrange" ,
848568e4cbbSGuy Helmerwhich can also
849454ba768SRuslan Ermilovease the complexity of your firewall's configuration.
850454ba768SRuslan ErmilovI usually use a normal
851f063d76aSMatthew Dillonfirst/last range of 4000 to 5000, and a hiport range of 49152 to 65535, then
852568e4cbbSGuy Helmerblock everything under 4000 off in my firewall
853c4d9468eSRuslan Ermilov(except for certain specific
854c4d9468eSRuslan Ermilovinternet-accessible ports, of course).
855f063d76aSMatthew Dillon.Pp
856454ba768SRuslan ErmilovAnother common DoS attack is called a springboard attack \(em to attack a server
857f063d76aSMatthew Dillonin a manner that causes the server to generate responses which then overload
858454ba768SRuslan Ermilovthe server, the local network, or some other machine.
859454ba768SRuslan ErmilovThe most common attack
860454ba768SRuslan Ermilovof this nature is the ICMP PING BROADCAST attack.
861454ba768SRuslan ErmilovThe attacker spoofs ping
862f063d76aSMatthew Dillonpackets sent to your LAN's broadcast address with the source IP address set
863454ba768SRuslan Ermilovto the actual machine they wish to attack.
864454ba768SRuslan ErmilovIf your border routers are not
865f063d76aSMatthew Dillonconfigured to stomp on ping's to broadcast addresses, your LAN winds up
866f063d76aSMatthew Dillongenerating sufficient responses to the spoofed source address to saturate the
867f063d76aSMatthew Dillonvictim, especially when the attacker uses the same trick on several dozen
868454ba768SRuslan Ermilovbroadcast addresses over several dozen different networks at once.
869454ba768SRuslan ErmilovBroadcast attacks of over a hundred and twenty megabits have been measured.
870454ba768SRuslan ErmilovA second common springboard attack is against the ICMP error reporting system.
871454ba768SRuslan ErmilovBy
872f063d76aSMatthew Dillonconstructing packets that generate ICMP error responses, an attacker can
873f063d76aSMatthew Dillonsaturate a server's incoming network and cause the server to saturate its
874454ba768SRuslan Ermilovoutgoing network with ICMP responses.
875454ba768SRuslan ErmilovThis type of attack can also crash the
876454ba768SRuslan Ermilovserver by running it out of
877454ba768SRuslan Ermilov.Vt mbuf Ns 's ,
878454ba768SRuslan Ermilovespecially if the server cannot drain the
879454ba768SRuslan ErmilovICMP responses it generates fast enough.
880454ba768SRuslan ErmilovThe
881f6f8f44dSAlexey Zelkin.Fx
882568e4cbbSGuy Helmerkernel has a new kernel
883454ba768SRuslan Ermilovcompile option called
884454ba768SRuslan Ermilov.Dv ICMP_BANDLIM
885454ba768SRuslan Ermilovwhich limits the effectiveness of these
886454ba768SRuslan Ermilovsorts of attacks.
887454ba768SRuslan ErmilovThe last major class of springboard attacks is related to
888454ba768SRuslan Ermilovcertain internal
889454ba768SRuslan Ermilov.Xr inetd 8
890454ba768SRuslan Ermilovservices such as the UDP echo service.
891454ba768SRuslan ErmilovAn attacker
892f063d76aSMatthew Dillonsimply spoofs a UDP packet with the source address being server A's echo port,
893f063d76aSMatthew Dillonand the destination address being server B's echo port, where server A and B
894454ba768SRuslan Ermilovare both on your LAN.
895454ba768SRuslan ErmilovThe two servers then bounce this one packet back and
896454ba768SRuslan Ermilovforth between each other.
897454ba768SRuslan ErmilovThe attacker can overload both servers and their
898454ba768SRuslan ErmilovLANs simply by injecting a few packets in this manner.
899454ba768SRuslan ErmilovSimilar problems
900454ba768SRuslan Ermilovexist with the internal chargen port.
901454ba768SRuslan ErmilovA competent sysadmin will turn off all
902454ba768SRuslan Ermilovof these
903454ba768SRuslan Ermilov.Xr inetd 8 Ns -internal
904454ba768SRuslan Ermilovtest services.
905d93b26d6SMatthew Dillon.Sh ACCESS ISSUES WITH KERBEROS AND SSH
906454ba768SRuslan ErmilovThere are a few issues with both Kerberos and SSH that need to be addressed
907454ba768SRuslan Ermilovif you intend to use them.
908454ba768SRuslan ErmilovKerberos5 is an excellent authentication
909454ba768SRuslan Ermilovprotocol but the kerberized
910454ba768SRuslan Ermilov.Xr telnet 1
911454ba768SRuslan Ermilovsuck rocks.
912454ba768SRuslan ErmilovThere are bugs that make them unsuitable for dealing with binary streams.
913454ba768SRuslan ErmilovAlso, by default
914454ba768SRuslan ErmilovKerberos does not encrypt a session unless you use the
915d93b26d6SMatthew Dillon.Fl x
916454ba768SRuslan Ermilovoption.
917454ba768SRuslan ErmilovSSH encrypts everything by default.
918d93b26d6SMatthew Dillon.Pp
919454ba768SRuslan ErmilovSSH works quite well in every respect except when it is set up to
9209baaab27SDima Dorfmanforward encryption keys.
9219baaab27SDima DorfmanWhat this means is that if you have a secure workstation holding
922454ba768SRuslan Ermilovkeys that give you access to the rest of the system, and you
923454ba768SRuslan Ermilov.Xr ssh 1
924454ba768SRuslan Ermilovto an
925454ba768SRuslan Ermilovunsecure machine, your keys become exposed.
926454ba768SRuslan ErmilovThe actual keys themselves are
927454ba768SRuslan Ermilovnot exposed, but
928454ba768SRuslan Ermilov.Xr ssh 1
929454ba768SRuslan Ermilovinstalls a forwarding port for the duration of your
93047afd1f8SDaniel Harrislogin and if an attacker has broken root on the unsecure machine he can utilize
931d93b26d6SMatthew Dillonthat port to use your keys to gain access to any other machine that your
932d93b26d6SMatthew Dillonkeys unlock.
933d93b26d6SMatthew Dillon.Pp
934454ba768SRuslan ErmilovWe recommend that you use SSH in combination with Kerberos whenever possible
935454ba768SRuslan Ermilovfor staff logins.
936454ba768SRuslan ErmilovSSH can be compiled with Kerberos support.
937454ba768SRuslan ErmilovThis reduces
938454ba768SRuslan Ermilovyour reliance on potentially exposable SSH keys while at the same time
939454ba768SRuslan Ermilovprotecting passwords via Kerberos.
940454ba768SRuslan ErmilovSSH keys
941d93b26d6SMatthew Dillonshould only be used for automated tasks from secure machines (something
942454ba768SRuslan Ermilovthat Kerberos is unsuited to).
943454ba768SRuslan ErmilovWe also recommend that you either turn off
944454ba768SRuslan Ermilovkey-forwarding in the SSH configuration, or that you make use of the
945454ba768SRuslan Ermilov.Va from Ns = Ns Ar IP/DOMAIN
946454ba768SRuslan Ermilovoption that SSH allows in its
947d93b26d6SMatthew Dillon.Pa authorized_keys
9487c86a74bSMike Pritchardfile to make the key only usable to entities logging in from specific
949d93b26d6SMatthew Dillonmachines.
950762caeb4SKonstantin Belousov.Sh KNOBS AND TWEAKS
951762caeb4SKonstantin Belousov.Fx
952762caeb4SKonstantin Belousovprovides several knobs and tweak handles that make some introspection
953762caeb4SKonstantin Belousovinformation access more restricted.
954762caeb4SKonstantin BelousovSome people consider this as improving system security, so the knobs are
955762caeb4SKonstantin Belousovbriefly listed there, together with controls which enable some mitigations
956762caeb4SKonstantin Belousovof the hardware state leaks.
957d777076fSEd Maste.Pp
958d777076fSEd MasteHardware mitigation sysctl knobs described below have been moved under
959d777076fSEd Maste.Pa machdep.mitigations ,
960d777076fSEd Mastewith backwards-compatibility shims to accept the existing names.
961d777076fSEd MasteA future change will rationalize the sense of the individual sysctls
962d777076fSEd Maste(so that enabled / true always indicates that the mitigation is active).
963d777076fSEd MasteFor that reason the previous names remain the canonical way to set the
964d777076fSEd Mastemitigations, and are documented here.
965d777076fSEd MasteBackwards compatibility shims for the interim sysctls under
966d777076fSEd Maste.Pa machdep.mitigations
967d777076fSEd Mastewill not be added.
968762caeb4SKonstantin Belousov.Bl -tag -width security.bsd.unprivileged_proc_debug
969762caeb4SKonstantin Belousov.It Dv security.bsd.see_other_uids
97061b6e00bSOlivier CertnerControls visibility and reachability of subjects (e.g., processes) and objects
97161b6e00bSOlivier Certner(e.g., sockets) owned by a different uid.
972762caeb4SKonstantin BelousovThe knob directly affects the
973762caeb4SKonstantin Belousov.Dv kern.proc
974762caeb4SKonstantin Belousovsysctls filtering of data, which results in restricted output from
975762caeb4SKonstantin Belousovutilities like
976762caeb4SKonstantin Belousov.Xr ps 1 .
977762caeb4SKonstantin Belousov.It Dv security.bsd.see_other_gids
97861b6e00bSOlivier CertnerSame, for subjects and objects owned by a different gid.
979762caeb4SKonstantin Belousov.It Dv security.bsd.see_jail_proc
98061b6e00bSOlivier CertnerSame, for subjects and objects belonging to a different jail, including
98161b6e00bSOlivier Certnersub-jails.
982762caeb4SKonstantin Belousov.It Dv security.bsd.conservative_signals
983762caeb4SKonstantin BelousovWhen enabled, unprivileged users are only allowed to send job control
984762caeb4SKonstantin Belousovand usual termination signals like
985762caeb4SKonstantin Belousov.Dv SIGKILL ,
986762caeb4SKonstantin Belousov.Dv SIGINT ,
987762caeb4SKonstantin Belousovand
988762caeb4SKonstantin Belousov.Dv SIGTERM ,
989762caeb4SKonstantin Belousovto the processes executing programs with changed uids.
990762caeb4SKonstantin Belousov.It Dv security.bsd.unprivileged_proc_debug
991762caeb4SKonstantin BelousovControls availability of the process debugging facilities to non-root users.
992762caeb4SKonstantin BelousovSee also
993762caeb4SKonstantin Belousov.Xr proccontrol 1
994762caeb4SKonstantin Belousovmode
995762caeb4SKonstantin Belousov.Dv trace .
996762caeb4SKonstantin Belousov.It Dv vm.pmap.pti
997762caeb4SKonstantin BelousovTunable, amd64-only.
998762caeb4SKonstantin BelousovEnables mode of operation of virtual memory system where usermode page
999762caeb4SKonstantin Belousovtables are sanitized to prevent so-called Meltdown information leak on
1000762caeb4SKonstantin Belousovsome Intel CPUs.
1001762caeb4SKonstantin BelousovBy default, the system detects whether the CPU needs the workaround,
1002762caeb4SKonstantin Belousovand enables it automatically.
1003762caeb4SKonstantin BelousovSee also
1004762caeb4SKonstantin Belousov.Xr proccontrol 1
1005762caeb4SKonstantin Belousovmode
1006762caeb4SKonstantin Belousov.Dv kpti .
1007ea602083SKonstantin Belousov.It Dv machdep.mitigations.flush_rsb_ctxsw
1008ea602083SKonstantin Belousovamd64.
1009ea602083SKonstantin BelousovControls Return Stack Buffer flush on context switch, to prevent
1010ea602083SKonstantin Belousovcross-process ret2spec attacks.
1011ea602083SKonstantin BelousovOnly needed, and only enabled by default, if the machine
1012ea602083SKonstantin Belousovsupports SMEP, otherwise IBRS would do necessary flushing on kernel
1013ea602083SKonstantin Belousoventry anyway.
1014762caeb4SKonstantin Belousov.It Dv hw.mds_disable
1015762caeb4SKonstantin Belousovamd64 and i386.
1016762caeb4SKonstantin BelousovControls Microarchitectural Data Sampling hardware information leak
1017762caeb4SKonstantin Belousovmitigation.
1018762caeb4SKonstantin Belousov.It Dv hw.spec_store_bypass_disable
1019762caeb4SKonstantin Belousovamd64 and i386.
1020762caeb4SKonstantin BelousovControls Speculative Store Bypass hardware information leak mitigation.
1021762caeb4SKonstantin Belousov.It Dv hw.ibrs_disable
1022762caeb4SKonstantin Belousovamd64 and i386.
1023762caeb4SKonstantin BelousovControls Indirect Branch Restricted Speculation hardware information leak
1024762caeb4SKonstantin Belousovmitigation.
10254233882fSPiotr Pawel Stefaniak.It Dv machdep.syscall_ret_flush_l1d
1026762caeb4SKonstantin Belousovamd64.
1027762caeb4SKonstantin BelousovControls force-flush of L1D cache on return from syscalls which report
1028762caeb4SKonstantin Belousoverrors other than
1029762caeb4SKonstantin Belousov.Ev EEXIST ,
1030762caeb4SKonstantin Belousov.Ev EAGAIN ,
1031762caeb4SKonstantin Belousov.Ev EXDEV ,
1032762caeb4SKonstantin Belousov.Ev ENOENT ,
1033762caeb4SKonstantin Belousov.Ev ENOTCONN ,
1034762caeb4SKonstantin Belousovand
1035762caeb4SKonstantin Belousov.Ev EINPROGRESS .
1036762caeb4SKonstantin BelousovThis is mostly a paranoid setting added to prevent hypothetical exploitation
1037762caeb4SKonstantin Belousovof unknown gadgets for unknown hardware issues.
1038762caeb4SKonstantin BelousovThe error codes exclusion list is composed of the most common errors which
1039762caeb4SKonstantin Belousovtypically occurs on normal system operation.
1040762caeb4SKonstantin Belousov.It Dv machdep.nmi_flush_l1d_sw
1041762caeb4SKonstantin Belousovamd64.
1042762caeb4SKonstantin BelousovControls force-flush of L1D cache on NMI;
1043762caeb4SKonstantin Belousovthis provides software assist for bhyve mitigation of L1 terminal fault
1044762caeb4SKonstantin Belousovhardware information leak.
1045762caeb4SKonstantin Belousov.It Dv hw.vmm.vmx.l1d_flush
1046762caeb4SKonstantin Belousovamd64.
1047762caeb4SKonstantin BelousovControls the mitigation of L1 Terminal Fault in bhyve hypervisor.
1048c08973d0SKonstantin Belousov.It Dv vm.pmap.allow_2m_x_ept
1049c08973d0SKonstantin Belousovamd64.
1050c08973d0SKonstantin BelousovAllows the use of superpages for executable mappings under the EPT
1051c08973d0SKonstantin Belousovpage table format used by hypervisors on Intel CPUs to map the guest
1052c08973d0SKonstantin Belousovphysical address space to machine physical memory.
1053c08973d0SKonstantin BelousovMay be disabled to work around a CPU Erratum called
1054c08973d0SKonstantin BelousovMachine Check Error Avoidance on Page Size Change.
105517edf152SKonstantin Belousov.It Dv machdep.mitigations.rngds.enable
105617edf152SKonstantin Belousovamd64 and i386.
105717edf152SKonstantin BelousovControls mitigation of Special Register Buffer Data Sampling versus
105817edf152SKonstantin Belousovoptimization of the MCU access.
105917edf152SKonstantin BelousovWhen set to zero, the mitigation is disabled, and the RDSEED and RDRAND
106017edf152SKonstantin Belousovinstructions do not incur serialization overhead for shared buffer accesses,
10612d3d29c2SJose Luis Duranand do not serialize off-core memory accesses.
1062762caeb4SKonstantin Belousov.It Dv kern.elf32.aslr.enable
10639ecaaee3SJason HelfmanControls system-global Address Space Layout Randomization (ASLR) for
106421881527SMark Johnstonnormal non-PIE (Position Independent Executable) 32-bit ELF binaries.
106521881527SMark JohnstonSee also the
1066762caeb4SKonstantin Belousov.Xr proccontrol 1
106721881527SMark Johnston.Dv aslr
106821881527SMark Johnstonmode, also affected by the per-image control note flag.
1069762caeb4SKonstantin Belousov.It Dv kern.elf32.aslr.pie_enable
1070762caeb4SKonstantin BelousovControls system-global Address Space Layout Randomization for
107121881527SMark Johnstonposition-independent (PIE) 32-bit binaries.
1072762caeb4SKonstantin Belousov.It Dv kern.elf32.aslr.honor_sbrk
1073762caeb4SKonstantin BelousovMakes ASLR less aggressive and more compatible with old binaries
1074762caeb4SKonstantin Belousovrelying on the sbrk area.
10751811c1e9SMark Johnston.It Dv kern.elf32.aslr.stack
1076d521abdfSEd MasteEnable randomization of the stack for 32-bit binaries.
10771811c1e9SMark JohnstonOtherwise, the stack is mapped at a fixed location determined by the
10781811c1e9SMark Johnstonprocess ABI.
1079762caeb4SKonstantin Belousov.It Dv kern.elf64.aslr.enable
108021881527SMark JohnstonASLR control for 64-bit ELF binaries.
1081762caeb4SKonstantin Belousov.It Dv kern.elf64.aslr.pie_enable
108221881527SMark JohnstonASLR control for 64-bit ELF PIEs.
1083762caeb4SKonstantin Belousov.It Dv kern.elf64.aslr.honor_sbrk
108421881527SMark JohnstonASLR sbrk compatibility control for 64-bit binaries.
10851811c1e9SMark Johnston.It Dv kern.elf64.aslr.stack
108621881527SMark JohnstonControls stack address randomization for 64-bit binaries.
1087762caeb4SKonstantin Belousov.It Dv kern.elf32.nxstack
108821881527SMark JohnstonEnables non-executable stack for 32-bit processes.
1089762caeb4SKonstantin BelousovEnabled by default if supported by hardware and corresponding binary.
1090762caeb4SKonstantin Belousov.It Dv kern.elf64.nxstack
109121881527SMark JohnstonEnables non-executable stack for 64-bit processes.
1092907023b4SEvgeniy Khramtsov.It Dv kern.elf32.allow_wx
1093907023b4SEvgeniy KhramtsovEnables mapping of simultaneously writable and executable pages for
109421881527SMark Johnston32-bit processes.
1095907023b4SEvgeniy Khramtsov.It Dv kern.elf64.allow_wx
1096907023b4SEvgeniy KhramtsovEnables mapping of simultaneously writable and executable pages for
109721881527SMark Johnston64-bit processes.
1098762caeb4SKonstantin Belousov.El
1099f063d76aSMatthew Dillon.Sh SEE ALSO
1100f063d76aSMatthew Dillon.Xr chflags 1 ,
1101f063d76aSMatthew Dillon.Xr find 1 ,
1102f063d76aSMatthew Dillon.Xr md5 1 ,
1103f6f8f44dSAlexey Zelkin.Xr netstat 1 ,
11048596de53SNik Clayton.Xr openssl 1 ,
1105762caeb4SKonstantin Belousov.Xr proccontrol 1 ,
1106762caeb4SKonstantin Belousov.Xr ps 1 ,
11075521ff5aSRuslan Ermilov.Xr ssh 1 ,
1108f0ea72a0SChristian Brueffer.Xr xdm 1 Pq Pa ports/x11/xorg-clients ,
1109d93b26d6SMatthew Dillon.Xr group 5 ,
1110ad27d066SMatthew Dillon.Xr ttys 5 ,
11116e5dcc61SEd Maste.Xr mitigations 7 ,
11128596de53SNik Clayton.Xr accton 8 ,
1113d93b26d6SMatthew Dillon.Xr init 8 ,
11148596de53SNik Clayton.Xr sshd 8 ,
1115ad27d066SMatthew Dillon.Xr sysctl 8 ,
11168596de53SNik Clayton.Xr syslogd 8 ,
1117ad27d066SMatthew Dillon.Xr vipw 8
1118f063d76aSMatthew Dillon.Sh HISTORY
1119f063d76aSMatthew DillonThe
1120f063d76aSMatthew Dillon.Nm
1121568e4cbbSGuy Helmermanual page was originally written by
1122568e4cbbSGuy Helmer.An Matthew Dillon
1123568e4cbbSGuy Helmerand first appeared
1124568e4cbbSGuy Helmerin
112585752545SGuy Helmer.Fx 3.1 ,
1126568e4cbbSGuy HelmerDecember 1998.
1127