1 .\" Copyright (C) 1998 Matthew Dillon. All rights reserved.
2 .\" Copyright (c) 2019 The FreeBSD Foundation, Inc.
4 .\" Parts of this documentation were written by
5 .\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
6 .\" from the FreeBSD Foundation.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
17 .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 .Nd introduction to security under FreeBSD
38 Security is a function that begins and ends with the system administrator.
41 multi-user systems have some inherent security, the job of building and
42 maintaining additional security mechanisms to keep users
45 one of the single largest undertakings of the sysadmin.
47 only as secure as you make them, and security concerns are ever competing
48 with the human necessity for convenience.
51 in general, are capable of running a huge number of simultaneous processes
52 and many of these processes operate as servers \(em meaning that external
53 entities can connect and talk to them.
54 As yesterday's mini-computers and mainframes
55 become today's desktops, and as computers become networked and internetworked,
56 security becomes an ever bigger issue.
58 Security is best implemented through a layered onion approach.
60 what you want to do is to create as many layers of security as are convenient
61 and then carefully monitor the system for intrusions.
63 System security also pertains to dealing with various forms of attacks,
64 including attacks that attempt to crash or otherwise make a system unusable
65 but do not attempt to break root.
66 Security concerns can be split up into
68 .Bl -enum -offset indent
70 Denial of Service attacks (DoS)
72 User account compromises
74 Root compromise through accessible servers
76 Root compromise via user accounts
81 A denial of service attack is an action that deprives the machine of needed
83 Typically, DoS attacks are brute-force mechanisms that attempt
84 to crash or otherwise make a machine unusable by overwhelming its servers or
86 Some DoS attacks try to take advantages of bugs in the
87 networking stack to crash a machine with a single packet.
89 only be fixed by applying a bug fix to the kernel.
90 Attacks on servers can
91 often be fixed by properly specifying options to limit the load the servers
92 incur on the system under adverse conditions.
93 Brute-force network attacks are harder to deal with.
94 A spoofed-packet attack, for example, is
95 nearly impossible to stop short of cutting your system off from the Internet.
96 It may not be able to take your machine down, but it can fill up your Internet
99 A user account compromise is even more common than a DoS attack.
105 servers on their machines.
106 These servers, by default, do not operate over encrypted
108 The result is that if you have any moderate-sized user base,
109 one or more of your users logging into your system from a remote location
110 (which is the most common and convenient way to log in to a system)
111 will have his or her password sniffed.
112 The attentive system administrator will analyze
113 his remote access logs looking for suspicious source addresses
114 even for successful logins.
116 One must always assume that once an attacker has access to a user account,
117 the attacker can break root.
118 However, the reality is that in a well secured
119 and maintained system, access to a user account does not necessarily give the
120 attacker access to root.
121 The distinction is important because without access
122 to root the attacker cannot generally hide his tracks and may, at best, be
123 able to do nothing more than mess with the user's files or crash the machine.
124 User account compromises are very common because users tend not to take the
125 precautions that sysadmins take.
127 System administrators must keep in mind that there are potentially many ways
128 to break root on a machine.
129 The attacker may know the root password,
131 may find a bug in a root-run server and be able to break root over a network
132 connection to that server, or the attacker may know of a bug in an SUID-root
133 program that allows the attacker to break root once he has broken into a
135 If an attacker has found a way to break root on a machine,
136 the attacker may not have a need to install a backdoor.
137 Many of the root holes found and closed to date involve a considerable amount
138 of work by the attacker to clean up after himself, so most attackers do install
140 This gives you a convenient way to detect the attacker.
142 it impossible for an attacker to install a backdoor may actually be detrimental
143 to your security because it will not close off the hole the attacker used to
146 Security remedies should always be implemented with a multi-layered
148 approach and can be categorized as follows:
149 .Bl -enum -offset indent
151 Securing root and staff accounts
153 Securing root \(em root-run servers and SUID/SGID binaries
155 Securing user accounts
157 Securing the password file
159 Securing the kernel core, raw devices, and file systems
161 Quick detection of inappropriate changes made to the system
165 .Sh SECURING THE ROOT ACCOUNT AND SECURING STAFF ACCOUNTS
166 Do not bother securing staff accounts if you have not secured the root
168 Most systems have a password assigned to the root account.
170 first thing you do is assume that the password is
173 This does not mean that you should remove the password.
175 password is almost always necessary for console access to the machine.
176 What it does mean is that you should not make it possible to use the password
177 outside of the console or possibly even with a
180 For example, make sure that your PTYs are specified as being
185 so that direct root logins via
189 other login services such as
191 make sure that direct root logins are
192 disabled there as well.
193 Consider every access method \(em services such as
195 often fall through the cracks.
196 Direct root logins should only be allowed
197 via the system console.
199 Of course, as a sysadmin you have to be able to get to root, so we open up
201 But we make sure these holes require additional password
202 verification to operate.
203 One way to make root accessible is to add appropriate
204 staff accounts to the
208 The staff members placed in the
213 You should never give staff
216 access by putting them in the
218 group in their password entry.
219 Staff accounts should be placed in a
221 group, and then added to the
226 Only those staff members who actually need to have root access
227 should be placed in the
230 It is also possible, when using an
231 authentication method such as Kerberos, to use Kerberos's
233 file in the root account to allow a
235 to root without having to place anyone at all in the
239 may be the better solution since the
241 mechanism still allows an
242 intruder to break root if the intruder has gotten hold of your password
243 file and can break into a staff account.
247 is better than having nothing at all, it is not necessarily the safest
250 An indirect way to secure the root account is to secure your staff accounts
251 by using an alternative login access method and *'ing out the crypted password
252 for the staff accounts.
253 This way an intruder may be able to steal the password
254 file but will not be able to break into any staff accounts or root, even if
255 root has a crypted password associated with it (assuming, of course, that
256 you have limited root access to the console).
258 get into their staff accounts through a secure login mechanism such as
262 using a private/public
264 When you use something like Kerberos you generally must secure
265 the machines which run the Kerberos servers and your desktop workstation.
266 When you use a public/private key pair with SSH, you must generally secure
267 the machine you are logging in
269 (typically your workstation),
271 also add an additional layer of protection to the key pair by password
272 protecting the keypair when you create it with
275 to star-out the passwords for staff accounts also guarantees that staff
276 members can only log in through secure access methods that you have set up.
278 thus force all staff members to use secure, encrypted connections for
279 all their sessions which closes an important hole used by many intruders: that
280 of sniffing the network from an unrelated, less secure machine.
282 The more indirect security mechanisms also assume that you are logging in
283 from a more restrictive server to a less restrictive server.
285 if your main box is running all sorts of servers, your workstation should not
287 In order for your workstation to be reasonably secure
288 you should run as few servers as possible, up to and including no servers
289 at all, and you should run a password-protected screen blanker.
290 Of course, given physical access to
291 a workstation, an attacker can break any sort of security you put on it.
292 This is definitely a problem that you should consider but you should also
293 consider the fact that the vast majority of break-ins occur remotely, over
294 a network, from people who do not have physical access to your workstation or
297 Using something like Kerberos also gives you the ability to disable or
298 change the password for a staff account in one place and have it immediately
299 affect all the machines the staff member may have an account on.
301 member's account gets compromised, the ability to instantly change his
302 password on all machines should not be underrated.
303 With discrete passwords, changing a password on N machines can be a mess.
305 re-passwording restrictions with Kerberos: not only can a Kerberos ticket
306 be made to timeout after a while, but the Kerberos system can require that
307 the user choose a new password after a certain period of time
309 .Sh SECURING ROOT \(em ROOT-RUN SERVERS AND SUID/SGID BINARIES
310 The prudent sysadmin only runs the servers he needs to, no more, no less.
311 Be aware that third party servers are often the most bug-prone.
313 running an old version of
316 .Xr popper 8 Pq Pa ports/mail/popper
317 is like giving a universal root
318 ticket out to the entire world.
319 Never run a server that you have not checked
321 Many servers do not need to be run as root.
328 daemons can be run in special user
330 A sandbox is not perfect unless you go to a large amount of trouble, but the
331 onion approach to security still stands: if someone is able to break in
332 through a server running in a sandbox, they still have to break out of the
334 The more layers the attacker must break through, the lower the
335 likelihood of his success.
336 Root holes have historically been found in
337 virtually every server ever run as root, including basic system servers.
338 If you are running a machine through which people only log in via
342 then turn off this service!
345 now defaults to running
351 Depending on whether you
352 are installing a new system or upgrading an existing system, the special
353 user accounts used by these sandboxes may not be installed.
355 sysadmin would research and implement sandboxes for servers whenever possible.
357 There are a number of other servers that typically do not run in sandboxes:
363 There are alternatives to
364 some of these, but installing them may require more work than you are willing
366 (the convenience factor strikes again).
367 You may have to run these
368 servers as root and rely on other mechanisms to detect break-ins that might
371 The other big potential root hole in a system are the SUID-root and SGID
372 binaries installed on the system.
373 Most of these binaries, such as
376 .Pa /bin , /sbin , /usr/bin ,
379 While nothing is 100% safe,
380 the system-default SUID and SGID binaries can be considered reasonably safe.
381 Still, root holes are occasionally found in these binaries.
383 was found in Xlib in 1998 that made
384 .Xr xterm 1 Pq Pa ports/x11/xterm
385 (which is typically SUID)
387 It is better to be safe than sorry and the prudent sysadmin will restrict SUID
388 binaries that only staff should run to a special group that only staff can
389 access, and get rid of
390 .Pq Dq Li "chmod 000"
391 any SUID binaries that nobody uses.
392 A server with no display generally does not need an
393 .Xr xterm 1 Pq Pa ports/x11/xterm
395 SGID binaries can be almost as dangerous.
396 If an intruder can break an SGID-kmem binary the
397 intruder might be able to read
399 and thus read the crypted password
400 file, potentially compromising any passworded account.
402 intruder who breaks group
404 can monitor keystrokes sent through PTYs,
405 including PTYs used by users who log in through secure methods.
409 group can write to almost any user's TTY.
411 is running a terminal
412 program or emulator with a keyboard-simulation feature, the intruder can
414 generate a data stream that causes the user's terminal to echo a command, which
415 is then run as that user.
416 .Sh SECURING USER ACCOUNTS
417 User accounts are usually the most difficult to secure.
419 draconian access restrictions on your staff and *-out their passwords, you
420 may not be able to do so with any general user accounts you might have.
422 you do have sufficient control then you may win out and be able to secure the
423 user accounts properly.
424 If not, you simply have to be more vigilant in your
425 monitoring of those accounts.
426 Use of SSH and Kerberos for user accounts is
427 more problematic due to the extra administration and technical support
428 required, but still a very good solution compared to a crypted password
430 .Sh SECURING THE PASSWORD FILE
431 The only sure fire way is to *-out as many passwords as you can and
432 use SSH or Kerberos for access to those accounts.
434 crypted password file
436 can only be read by root, it may
437 be possible for an intruder to obtain read access to that file even if the
438 attacker cannot obtain root-write access.
440 Your security scripts should always check for and report changes to
443 .Sx CHECKING FILE INTEGRITY
445 .Sh SECURING THE KERNEL CORE, RAW DEVICES, AND FILE SYSTEMS
446 If an attacker breaks root he can do just about anything, but there
447 are certain conveniences.
448 For example, most modern kernels have a packet sniffing device driver built in.
455 An intruder will commonly attempt to run a packet sniffer
456 on a compromised machine.
457 You do not need to give the intruder the
458 capability and most systems should not have the
462 But even if you turn off the
464 device, you still have
470 the intruder can still write to raw disk devices.
471 Also, there is another kernel feature called the module loader,
473 An enterprising intruder can use a KLD module to install
476 device or other sniffing device on a running kernel.
477 To avoid these problems you have to run
478 the kernel at a higher security level, at least level 1.
479 The security level can be set with a
485 set the security level to 1, write access to raw devices will be denied and
494 flag is set on critical startup binaries, directories, and
495 script files \(em everything that gets run
496 up to the point where the security level is set.
497 This might be overdoing it, and upgrading the system is much more
498 difficult when you operate at a higher security level.
499 You may compromise and
500 run the system at a higher security level but not set the
503 system file and directory under the sun.
504 Another possibility is to simply
510 It should be noted that being too draconian in
511 what you attempt to protect may prevent the all-important detection of an
514 The kernel runs with five different security levels.
515 Any super-user process can raise the level, but no process
517 The security levels are:
520 Permanently insecure mode \- always run the system in insecure mode.
521 This is the default initial value.
523 Insecure mode \- immutable and append-only flags may be turned off.
524 All devices may be read or written subject to their permissions.
526 Secure mode \- the system immutable and system append-only flags may not
528 disks for mounted file systems,
532 may not be opened for writing;
534 (if your platform has it) may not be opened at all;
537 may not be loaded or unloaded.
538 The kernel debugger may not be entered using the
542 policy grants access, for example using
544 A panic or trap cannot be forced using the
545 .Va debug.kdb.panic ,
546 .Va debug.kdb.panic_str
549 Highly secure mode \- same as secure mode, plus disks may not be
550 opened for writing (except by
552 whether mounted or not.
553 This level precludes tampering with file systems by unmounting them,
554 but also inhibits running
556 while the system is multi-user.
558 In addition, kernel time changes are restricted to less than or equal to one
560 Attempts to change the time by more than this will log the message
561 .Dq Time adjustment clamped to +1 second .
563 Network secure mode \- same as highly secure mode, plus
564 IP packet filter rules (see
569 cannot be changed and
573 configuration cannot be adjusted.
576 The security level can be configured with variables documented in
578 .Sh CHECKING FILE INTEGRITY: BINARIES, CONFIG FILES, ETC
579 When it comes right down to it, you can only protect your core system
580 configuration and control files so much before the convenience factor
586 bit on most of the files in
590 is probably counterproductive because
591 while it may protect the files, it also closes a detection window.
593 last layer of your security onion is perhaps the most important \(em detection.
594 The rest of your security is pretty much useless (or, worse, presents you with
595 a false sense of safety) if you cannot detect potential incursions.
597 the job of the onion is to slow down the attacker rather than stop him
598 in order to give the detection layer a chance to catch him in
601 The best way to detect an incursion is to look for modified, missing, or
604 way to look for modified files is from another (often centralized)
605 limited-access system.
606 Writing your security scripts on the extra-secure limited-access system
607 makes them mostly invisible to potential attackers, and this is important.
608 In order to take maximum advantage you generally have to give the
609 limited-access box significant access to the other machines in the business,
610 usually either by doing a read-only NFS export of the other machines to the
611 limited-access box, or by setting up SSH keypairs to allow the limit-access
612 box to SSH to the other machines.
613 Except for its network traffic, NFS is
614 the least visible method \(em allowing you to monitor the file systems on each
615 client box virtually undetected.
617 limited-access server is connected to the client boxes through a switch,
618 the NFS method is often the better choice.
619 If your limited-access server
620 is connected to the client boxes through a hub or through several layers
621 of routing, the NFS method may be too insecure (network-wise) and using SSH
622 may be the better choice even with the audit-trail tracks that SSH lays.
624 Once you give a limit-access box at least read access to the client systems
625 it is supposed to monitor, you must write scripts to do the actual
627 Given an NFS mount, you can write scripts out of simple system
632 It is best to physically
634 the client-box files boxes at least once a
635 day, and to test control files such as those found in
640 When mismatches are found relative to the base MD5
641 information the limited-access machine knows is valid, it should scream at
642 a sysadmin to go check it out.
643 A good security script will also check for
644 inappropriate SUID binaries and for new or deleted files on system partitions
650 When using SSH rather than NFS, writing the security script is much more
652 You essentially have to
654 the scripts to the client box in order to run them, making them visible, and
655 for safety you also need to
657 the binaries (such as
659 that those scripts use.
662 daemon on the client box may already be compromised.
664 using SSH may be necessary when running over unsecure links, but it is also a
665 lot harder to deal with.
667 A good security script will also check for changes to user and staff members
668 access configuration files:
669 .Pa .rhosts , .shosts , .ssh/authorized_keys
670 and so forth, files that might fall outside the purview of the MD5 check.
672 If you have a huge amount of user disk space it may take too long to run
673 through every file on those partitions.
674 In this case, setting mount
675 flags to disallow SUID binaries on those partitions is a good
682 is what you want to look into.
683 I would scan them anyway at least once a
684 week, since the object of this layer is to detect a break-in whether or
685 not the break-in is effective.
690 is a relatively low-overhead feature of
691 the operating system which I recommend using as a post-break-in evaluation
693 It is especially useful in tracking down how an intruder has
694 actually broken into a system, assuming the file is still intact after
697 Finally, security scripts should process the log files and the logs themselves
698 should be generated in as secure a manner as possible \(em remote syslog can be
700 An intruder tries to cover his tracks, and log files are critical
701 to the sysadmin trying to track down the time and method of the initial
703 One way to keep a permanent record of the log files is to run
704 the system console to a serial port and collect the information on a
705 continuing basis through a secure machine monitoring the consoles.
707 A little paranoia never hurts.
708 As a rule, a sysadmin can add any number
709 of security features as long as they do not affect convenience, and
710 can add security features that do affect convenience with some added
712 Even more importantly, a security administrator should mix it up
713 a bit \(em if you use recommendations such as those given by this manual
714 page verbatim, you give away your methodologies to the prospective
715 attacker who also has access to this manual page.
716 .Sh SPECIAL SECTION ON DoS ATTACKS
717 This section covers Denial of Service attacks.
718 A DoS attack is typically a packet attack.
719 While there is not much you can do about modern spoofed
720 packet attacks that saturate your network, you can generally limit the damage
721 by ensuring that the attacks cannot take down your servers.
722 .Bl -enum -offset indent
724 Limiting server forks
726 Limiting springboard attacks (ICMP response attacks, ping broadcast, etc.)
731 A common DoS attack is against a forking server that attempts to cause the
732 server to eat processes, file descriptors, and memory until the machine
737 has several options to limit this sort of attack.
738 It should be noted that while it is possible to prevent a machine from going
739 down it is not generally possible to prevent a service from being disrupted
743 manual page carefully and pay specific attention
749 Note that spoofed-IP attacks will circumvent
754 so typically a combination of options must be used.
755 Some standalone servers have self-fork-limitation parameters.
760 .Fl OMaxDaemonChildren
761 option which tends to work much
762 better than trying to use
764 load limiting options due to the
767 .Va MaxDaemonChildren
768 parameter when you start
770 high enough to handle your expected load but not so high that the
771 computer cannot handle that number of
773 without falling on its face.
774 It is also prudent to run
779 .Pq Fl ODeliveryMode=queued
780 and to run the daemon
781 .Pq Dq Nm sendmail Fl bd
782 separate from the queue-runs
783 .Pq Dq Nm sendmail Fl q15m .
784 If you still want real-time delivery you can run the queue
785 at a much lower interval, such as
787 but be sure to specify a reasonable
788 .Va MaxDaemonChildren
791 to prevent cascade failures.
795 daemon can be attacked directly and it is strongly recommended that you use
798 option whenever possible, and the
802 You should also be fairly careful
803 with connect-back services such as tcpwrapper's reverse-identd, which can
804 be attacked directly.
805 You generally do not want to use the reverse-ident
806 feature of tcpwrappers for this reason.
808 It is a very good idea to protect internal services from external access
809 by firewalling them off at your border routers.
810 The idea here is to prevent
811 saturation attacks from outside your LAN, not so much to protect internal
812 services from network-based root compromise.
813 Always configure an exclusive
818 ports A, B, C, D, and M-Z
821 way you can firewall off all of your low ports except for certain specific
825 and other internet-accessible services.
826 If you try to configure the firewall the other
827 way \(em as an inclusive or permissive firewall, there is a good chance that you
830 a couple of services or that you will add a new internal
831 service and forget to update the firewall.
832 You can still open up the
833 high-numbered port range on the firewall to allow permissive-like operation
834 without compromising your low ports.
838 control the range of port numbers used for dynamic binding via the various
839 .Va net.inet.ip.portrange
841 .Pq Dq Li "sysctl net.inet.ip.portrange" ,
843 ease the complexity of your firewall's configuration.
844 I usually use a normal
845 first/last range of 4000 to 5000, and a hiport range of 49152 to 65535, then
846 block everything under 4000 off in my firewall
847 (except for certain specific
848 internet-accessible ports, of course).
850 Another common DoS attack is called a springboard attack \(em to attack a server
851 in a manner that causes the server to generate responses which then overload
852 the server, the local network, or some other machine.
853 The most common attack
854 of this nature is the ICMP PING BROADCAST attack.
855 The attacker spoofs ping
856 packets sent to your LAN's broadcast address with the source IP address set
857 to the actual machine they wish to attack.
858 If your border routers are not
859 configured to stomp on ping's to broadcast addresses, your LAN winds up
860 generating sufficient responses to the spoofed source address to saturate the
861 victim, especially when the attacker uses the same trick on several dozen
862 broadcast addresses over several dozen different networks at once.
863 Broadcast attacks of over a hundred and twenty megabits have been measured.
864 A second common springboard attack is against the ICMP error reporting system.
866 constructing packets that generate ICMP error responses, an attacker can
867 saturate a server's incoming network and cause the server to saturate its
868 outgoing network with ICMP responses.
869 This type of attack can also crash the
870 server by running it out of
872 especially if the server cannot drain the
873 ICMP responses it generates fast enough.
876 kernel has a new kernel
877 compile option called
879 which limits the effectiveness of these
881 The last major class of springboard attacks is related to
884 services such as the UDP echo service.
886 simply spoofs a UDP packet with the source address being server A's echo port,
887 and the destination address being server B's echo port, where server A and B
888 are both on your LAN.
889 The two servers then bounce this one packet back and
890 forth between each other.
891 The attacker can overload both servers and their
892 LANs simply by injecting a few packets in this manner.
894 exist with the internal chargen port.
895 A competent sysadmin will turn off all
897 .Xr inetd 8 Ns -internal
899 .Sh ACCESS ISSUES WITH KERBEROS AND SSH
900 There are a few issues with both Kerberos and SSH that need to be addressed
901 if you intend to use them.
902 Kerberos5 is an excellent authentication
903 protocol but the kerberized
906 There are bugs that make them unsuitable for dealing with binary streams.
908 Kerberos does not encrypt a session unless you use the
911 SSH encrypts everything by default.
913 SSH works quite well in every respect except when it is set up to
914 forward encryption keys.
915 What this means is that if you have a secure workstation holding
916 keys that give you access to the rest of the system, and you
919 unsecure machine, your keys become exposed.
920 The actual keys themselves are
923 installs a forwarding port for the duration of your
924 login and if an attacker has broken root on the unsecure machine he can utilize
925 that port to use your keys to gain access to any other machine that your
928 We recommend that you use SSH in combination with Kerberos whenever possible
930 SSH can be compiled with Kerberos support.
932 your reliance on potentially exposable SSH keys while at the same time
933 protecting passwords via Kerberos.
935 should only be used for automated tasks from secure machines (something
936 that Kerberos is unsuited to).
937 We also recommend that you either turn off
938 key-forwarding in the SSH configuration, or that you make use of the
939 .Va from Ns = Ns Ar IP/DOMAIN
940 option that SSH allows in its
942 file to make the key only usable to entities logging in from specific
946 provides several knobs and tweak handles that make some introspection
947 information access more restricted.
948 Some people consider this as improving system security, so the knobs are
949 briefly listed there, together with controls which enable some mitigations
950 of the hardware state leaks.
952 Hardware mitigation sysctl knobs described below have been moved under
953 .Pa machdep.mitigations ,
954 with backwards-compatibility shims to accept the existing names.
955 A future change will rationalize the sense of the individual sysctls
956 (so that enabled / true always indicates that the mitigation is active).
957 For that reason the previous names remain the canonical way to set the
958 mitigations, and are documented here.
959 Backwards compatibility shims for the interim sysctls under
960 .Pa machdep.mitigations
962 .Bl -tag -width security.bsd.unprivileged_proc_debug
963 .It Dv security.bsd.see_other_uids
964 Controls visibility of processes owned by different uid.
965 The knob directly affects the
967 sysctls filtering of data, which results in restricted output from
970 .It Dv security.bsd.see_other_gids
971 Same, for processes owned by different gid.
972 .It Dv security.bsd.see_jail_proc
973 Same, for processes belonging to a jail.
974 .It Dv security.bsd.conservative_signals
975 When enabled, unprivileged users are only allowed to send job control
976 and usual termination signals like
981 to the processes executing programs with changed uids.
982 .It Dv security.bsd.unprivileged_proc_debug
983 Controls availability of the process debugging facilities to non-root users.
990 Enables mode of operation of virtual memory system where usermode page
991 tables are sanitized to prevent so-called Meltdown information leak on
993 By default, the system detects whether the CPU needs the workaround,
994 and enables it automatically.
999 .It Dv machdep.mitigations.flush_rsb_ctxsw
1001 Controls Return Stack Buffer flush on context switch, to prevent
1002 cross-process ret2spec attacks.
1003 Only needed, and only enabled by default, if the machine
1004 supports SMEP, otherwise IBRS would do necessary flushing on kernel
1006 .It Dv hw.mds_disable
1008 Controls Microarchitectural Data Sampling hardware information leak
1010 .It Dv hw.spec_store_bypass_disable
1012 Controls Speculative Store Bypass hardware information leak mitigation.
1013 .It Dv hw.ibrs_disable
1015 Controls Indirect Branch Restricted Speculation hardware information leak
1017 .It Dv machdep.syscall_ret_flush_l1d
1019 Controls force-flush of L1D cache on return from syscalls which report
1028 This is mostly a paranoid setting added to prevent hypothetical exploitation
1029 of unknown gadgets for unknown hardware issues.
1030 The error codes exclusion list is composed of the most common errors which
1031 typically occurs on normal system operation.
1032 .It Dv machdep.nmi_flush_l1d_sw
1034 Controls force-flush of L1D cache on NMI;
1035 this provides software assist for bhyve mitigation of L1 terminal fault
1036 hardware information leak.
1037 .It Dv hw.vmm.vmx.l1d_flush
1039 Controls the mitigation of L1 Terminal Fault in bhyve hypervisor.
1040 .It Dv vm.pmap.allow_2m_x_ept
1042 Allows the use of superpages for executable mappings under the EPT
1043 page table format used by hypervisors on Intel CPUs to map the guest
1044 physical address space to machine physical memory.
1045 May be disabled to work around a CPU Erratum called
1046 Machine Check Error Avoidance on Page Size Change.
1047 .It Dv machdep.mitigations.rngds.enable
1049 Controls mitigation of Special Register Buffer Data Sampling versus
1050 optimization of the MCU access.
1051 When set to zero, the mitigation is disabled, and the RDSEED and RDRAND
1052 instructions do not incur serialization overhead for shared buffer accesses,
1053 and do not serialize off-core memory accessses.
1054 .It Dv kern.elf32.aslr.enable
1055 Controls system-global Address Space Layout Randomization (ASLR) for
1056 normal non-PIE (Position Independent Executable) 32-bit ELF binaries.
1060 mode, also affected by the per-image control note flag.
1061 .It Dv kern.elf32.aslr.pie_enable
1062 Controls system-global Address Space Layout Randomization for
1063 position-independent (PIE) 32-bit binaries.
1064 .It Dv kern.elf32.aslr.honor_sbrk
1065 Makes ASLR less aggressive and more compatible with old binaries
1066 relying on the sbrk area.
1067 .It Dv kern.elf32.aslr.stack
1068 If ASLR is enabled for a binary, a non-zero value enables randomization
1070 Otherwise, the stack is mapped at a fixed location determined by the
1072 .It Dv kern.elf64.aslr.enable
1073 ASLR control for 64-bit ELF binaries.
1074 .It Dv kern.elf64.aslr.pie_enable
1075 ASLR control for 64-bit ELF PIEs.
1076 .It Dv kern.elf64.aslr.honor_sbrk
1077 ASLR sbrk compatibility control for 64-bit binaries.
1078 .It Dv kern.elf64.aslr.stack
1079 Controls stack address randomization for 64-bit binaries.
1080 .It Dv kern.elf32.nxstack
1081 Enables non-executable stack for 32-bit processes.
1082 Enabled by default if supported by hardware and corresponding binary.
1083 .It Dv kern.elf64.nxstack
1084 Enables non-executable stack for 64-bit processes.
1085 .It Dv kern.elf32.allow_wx
1086 Enables mapping of simultaneously writable and executable pages for
1088 .It Dv kern.elf64.allow_wx
1089 Enables mapping of simultaneously writable and executable pages for
1101 .Xr xdm 1 Pq Pa ports/x11/xorg-clients ,
1113 manual page was originally written by