PERFORCE change 55047 for review

Peter Wemm peter at FreeBSD.org
Tue Jun 15 21:08:25 GMT 2004


http://perforce.freebsd.org/chv.cgi?CH=55047

Change 55047 by peter at peter_daintree on 2004/06/15 21:07:47

	IFC @55045

Affected files ...

.. //depot/projects/hammer/lib/libarchive/archive_read_extract.c#10 integrate
.. //depot/projects/hammer/sbin/geom/core/Makefile#2 integrate
.. //depot/projects/hammer/share/man/man4/ip.4#10 integrate
.. //depot/projects/hammer/share/man/man7/security.7#7 integrate
.. //depot/projects/hammer/share/man/man9/rtentry.9#5 integrate
.. //depot/projects/hammer/sys/alpha/alpha/pmap.c#25 integrate
.. //depot/projects/hammer/sys/amd64/amd64/pmap.c#81 integrate
.. //depot/projects/hammer/sys/contrib/altq/altq/altq_subr.c#2 integrate
.. //depot/projects/hammer/sys/contrib/altq/altq/if_altq.h#2 integrate
.. //depot/projects/hammer/sys/dev/ata/ata-all.c#27 integrate
.. //depot/projects/hammer/sys/dev/ata/ata-chipset.c#35 integrate
.. //depot/projects/hammer/sys/dev/ata/ata-pci.c#22 integrate
.. //depot/projects/hammer/sys/dev/ata/ata-pci.h#22 integrate
.. //depot/projects/hammer/sys/dev/ciss/ciss.c#23 integrate
.. //depot/projects/hammer/sys/dev/firewire/sbp.c#29 integrate
.. //depot/projects/hammer/sys/fs/fifofs/fifo_vnops.c#19 integrate
.. //depot/projects/hammer/sys/geom/vinum/geom_vinum_subr.c#2 integrate
.. //depot/projects/hammer/sys/i386/acpica/acpi_toshiba.c#8 integrate
.. //depot/projects/hammer/sys/i386/i386/bios.c#14 integrate
.. //depot/projects/hammer/sys/i386/i386/pmap.c#35 integrate
.. //depot/projects/hammer/sys/kern/uipc_socket2.c#20 integrate
.. //depot/projects/hammer/sys/net/if.c#20 integrate
.. //depot/projects/hammer/sys/net/if_var.h#17 integrate
.. //depot/projects/hammer/sys/net/raw_cb.c#6 integrate
.. //depot/projects/hammer/sys/net/raw_cb.h#3 integrate
.. //depot/projects/hammer/sys/net/raw_usrreq.c#9 integrate
.. //depot/projects/hammer/sys/netinet/tcp_input.c#26 integrate
.. //depot/projects/hammer/sys/netipx/spx_usrreq.c#8 integrate
.. //depot/projects/hammer/sys/sparc64/sbus/lsi64854.c#1 branch
.. //depot/projects/hammer/sys/sparc64/sbus/lsi64854reg.h#1 branch
.. //depot/projects/hammer/sys/sparc64/sbus/lsi64854var.h#1 branch
.. //depot/projects/hammer/sys/sys/socketvar.h#17 integrate
.. //depot/projects/hammer/usr.bin/su/su.c#14 integrate
.. //depot/projects/hammer/usr.bin/talk/talk.1#4 integrate
.. //depot/projects/hammer/usr.bin/tar/bsdtar.c#12 integrate
.. //depot/projects/hammer/usr.bin/tar/bsdtar.h#7 integrate
.. //depot/projects/hammer/usr.bin/tar/matching.c#5 integrate

Differences ...

==== //depot/projects/hammer/lib/libarchive/archive_read_extract.c#10 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.17 2004/06/05 06:08:40 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.18 2004/06/15 07:12:04 kientzle Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -394,11 +394,10 @@
 	mode = st->st_mode;
 
 	/*
-	 * XXX TODO: Does this really work under all conditions?
-	 * E.g., root restores a dir owned by someone else? XXX
+	 * Use conservative permissions when creating directories
+	 * to close a few security races.
 	 */
-	/* Ensure we can write to this directory. */
-	writable_mode = mode | 0700;
+	writable_mode = 0700;
 
 	if (mode != writable_mode || flags & ARCHIVE_EXTRACT_TIME) {
 		/* Add this dir to the fixup list. */
@@ -694,21 +693,34 @@
 /*
  * Returns 0 if it successfully created necessary directories.
  * Otherwise, returns ARCHIVE_WARN.
+ *
+ * XXX TODO: Merge this with archive_extract_dir() above; that will
+ * allow us to deal with all directory-related security and
+ * permissions issues in one place. XXX
  */
 static int
 mkdirpath(struct archive *a, const char *path)
 {
 	char *p;
 	struct extract *extract;
+	size_t len;
 
 	extract = a->extract;
 
 	/* Copy path to mutable storage, then call mkdirpath_recursive. */
 	archive_strcpy(&(extract->mkdirpath), path);
+	p = extract->mkdirpath.s;
+	len = strlen(p);
+	/* Prune trailing "/." sequence. */
+	if (len > 2 && p[len - 1] == '.' && p[len - 2] == '/') {
+		p[len - 1] = 0;
+		len--;
+	}
 	/* Prune a trailing '/' character. */
-	p = extract->mkdirpath.s;
-	if (p[strlen(p)-1] == '/')
-		p[strlen(p)-1] = 0;
+	if (p[len - 1] == '/') {
+		p[len - 1] = 0;
+		len--;
+	}
 	/* Recursively try to build the path. */
 	return (mkdirpath_recursive(p));
 }
@@ -736,6 +748,10 @@
 static int
 mksubdir(char *path)
 {
+	/*
+	 * TODO: Change mode here to 0700 and add a fixup entry
+	 * to change the mode to 0755 after the extract is finished.
+	 */
 	int mode = 0755;
 
 	if (mkdir(path, mode) == 0) return (0);

==== //depot/projects/hammer/sbin/geom/core/Makefile#2 (text+ko) ====

@@ -1,9 +1,9 @@
-# $FreeBSD: src/sbin/geom/core/Makefile,v 1.5 2004/05/26 17:51:53 pjd Exp $
+# $FreeBSD: src/sbin/geom/core/Makefile,v 1.6 2004/06/15 17:31:35 pjd Exp $
 
 .PATH: ${.CURDIR}/../misc
 
 PROG=	geom
-NOMAN=	notyet
+MAN=	geom.8
 SRCS=	geom.c subr.c
 
 CFLAGS+= -DCLASSDIR=\"${CLASSDIR}\"

==== //depot/projects/hammer/share/man/man4/ip.4#10 (text+ko) ====

@@ -30,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ip.4	8.2 (Berkeley) 11/30/93
-.\" $FreeBSD: src/share/man/man4/ip.4,v 1.36 2004/06/15 01:08:09 bms Exp $
+.\" $FreeBSD: src/share/man/man4/ip.4,v 1.37 2004/06/15 16:48:42 bms Exp $
 .\"
 .Dd June 14, 2004
 .Dt IP 4
@@ -529,13 +529,20 @@
 ip->ip_off = offset;
 .Ed
 .Pp
-The ip_len and ip_off fields
-.Em must be provided in host byte order .
+The
+.Va ip_len
+and
+.Va ip_off
+fields
+.Em must
+be provided in host byte order .
 All other fields must be provided in network byte order.
 See
 .Xr byteorder 4
 for more information on network byte order.
-If the ip_id field is set to 0, then the kernel will choose an
+If the
+.Va ip_id
+field is set to 0 then the kernel will choose an
 appopriate value.
 If the header source address is set to
 .Dv INADDR_ANY ,
@@ -582,12 +589,13 @@
 datagrams via a
 .Dq raw socket
 with the
-.Em IP_HDRINCL
+.Dv IP_HDRINCL
 option set:
 .Bl -tag -width Er
 .It Bq Er EINVAL
-The user-supplied ip_len field was not equal to the length of the datagram
-written to the socket.
+The user-supplied
+.Va ip_len
+field was not equal to the length of the datagram written to the socket.
 .El
 .Sh SEE ALSO
 .Xr getsockopt 2 ,

==== //depot/projects/hammer/share/man/man7/security.7#7 (text+ko) ====

@@ -2,40 +2,46 @@
 .\" the BSD Copyright as specified in the file "/usr/src/COPYRIGHT" in
 .\" the source tree.
 .\"
-.\" $FreeBSD: src/share/man/man7/security.7,v 1.36 2004/05/18 18:17:25 dannyboy Exp $
+.\" $FreeBSD: src/share/man/man7/security.7,v 1.37 2004/06/15 12:48:50 ru Exp $
 .\"
 .Dd September 18, 1999
 .Dt SECURITY 7
 .Os
 .Sh NAME
 .Nm security
-.Nd introduction to security under FreeBSD
+.Nd introduction to security under
+.Fx
 .Sh DESCRIPTION
 Security is a function that begins and ends with the system administrator.
 While all
 .Bx
 multi-user systems have some inherent security, the job of building and
 maintaining additional security mechanisms to keep users
-.Sq honest
+.Dq honest
 is probably
-one of the single largest undertakings of the sysadmin.  Machines are
+one of the single largest undertakings of the sysadmin.
+Machines are
 only as secure as you make them, and security concerns are ever competing
 with the human necessity for convenience.
 .Ux
 systems,
 in general, are capable of running a huge number of simultaneous processes
-and many of these processes operate as servers \(em meaning that external entities
-can connect and talk to them.  As yesterday's mini-computers and mainframes
+and many of these processes operate as servers \(em meaning that external
+entities can connect and talk to them.
+As yesterday's mini-computers and mainframes
 become today's desktops, and as computers become networked and internetworked,
 security becomes an ever bigger issue.
 .Pp
-Security is best implemented through a layered onion approach.  In a nutshell,
+Security is best implemented through a layered onion approach.
+In a nutshell,
 what you want to do is to create as many layers of security as are convenient
-and then carefully monitor the system for intrusions.  You do not want to
+and then carefully monitor the system for intrusions.
+You do not want to
 overbuild your security or you will interfere with the detection side, and
 detection is one of the single most important aspects of any security
-mechanism.  For example, it makes little sense to set the
-.Pa schg
+mechanism.
+For example, it makes little sense to set the
+.Cm schg
 flags
 (see
 .Xr chflags 1 )
@@ -44,13 +50,14 @@
 easily detectable change that may result in your security mechanisms not
 detecting the attacker at all.
 .Pp
-System security also pertains to dealing with various forms of attack,
+System security also pertains to dealing with various forms of attacks,
 including attacks that attempt to crash or otherwise make a system unusable
-but do not attempt to break root.  Security concerns can be split up into
+but do not attempt to break root.
+Security concerns can be split up into
 several categories:
 .Bl -enum -offset indent
 .It
-Denial of service attacks
+Denial of Service attacks (DoS)
 .It
 User account compromises
 .It
@@ -62,61 +69,80 @@
 .El
 .Pp
 A denial of service attack is an action that deprives the machine of needed
-resources.  Typically, D.O.S. attacks are brute-force mechanisms that attempt
+resources.
+Typically, DoS attacks are brute-force mechanisms that attempt
 to crash or otherwise make a machine unusable by overwhelming its servers or
-network stack.  Some D.O.S. attacks try to take advantages of bugs in the
-networking stack to crash a machine with a single packet.  The latter can
-only be fixed by applying a bug fix to the kernel.  Attacks on servers can
+network stack.
+Some DoS attacks try to take advantages of bugs in the
+networking stack to crash a machine with a single packet.
+The latter can
+only be fixed by applying a bug fix to the kernel.
+Attacks on servers can
 often be fixed by properly specifying options to limit the load the servers
-incur on the system under adverse conditions.  Brute-force network
-attacks are harder to deal with.  A spoofed-packet attack, for example, is
+incur on the system under adverse conditions.
+Brute-force network attacks are harder to deal with.
+A spoofed-packet attack, for example, is
 nearly impossible to stop short of cutting your system off from the Internet.
 It may not be able to take your machine down, but it can fill up Internet
 pipe.
 .Pp
-A user account compromise is even more common than a D.O.S. attack.  Many
-sysadmins still run standard telnetd, rlogind, rshd, and ftpd servers on their
-machines.  These servers, by default, do not operate over encrypted
-connections.  The result is that if you have any moderate-sized user base,
+A user account compromise is even more common than a DoS attack.
+Many
+sysadmins still run standard
+.Xr telnetd 8 ,
+.Xr rlogind 8 ,
+.Xr rshd 8 ,
+and
+.Xr ftpd 8
+servers on their machines.
+These servers, by default, do not operate over encrypted
+connections.
+The result is that if you have any moderate-sized user base,
 one or more of your users logging into your system from a remote location
-(which is the most common and convenient way to login to a system)
-will
-have his or her password sniffed.  The attentive system admin will analyze
+(which is the most common and convenient way to log in to a system)
+will have his or her password sniffed.
+The attentive system administrator will analyze
 his remote access logs looking for suspicious source addresses
 even for successful logins.
 .Pp
 One must always assume that once an attacker has access to a user account,
-the attacker can break root.  However, the reality is that in a well secured
+the attacker can break root.
+However, the reality is that in a well secured
 and maintained system, access to a user account does not necessarily give the
-attacker access to root.  The distinction is important because without access
+attacker access to root.
+The distinction is important because without access
 to root the attacker cannot generally hide his tracks and may, at best, be
 able to do nothing more than mess with the user's files or crash the machine.
 User account compromises are very common because users tend not to take the
 precautions that sysadmins take.
 .Pp
 System administrators must keep in mind that there are potentially many ways
-to break root on a machine.  The attacker may know the root password,
+to break root on a machine.
+The attacker may know the root password,
 the attacker
 may find a bug in a root-run server and be able to break root over a network
-connection to that server, or the attacker may know of a bug in an suid-root
+connection to that server, or the attacker may know of a bug in an SUID-root
 program that allows the attacker to break root once he has broken into a
-user's account.  If an attacker has found a way to break root on a machine,
+user's account.
+If an attacker has found a way to break root on a machine,
 the attacker may not have a need to install a backdoor.
 Many of the root holes found and closed to date involve a considerable amount
-of work by the attacker to cleanup after himself, so most attackers do install
-backdoors.  This gives you a convenient way to detect the attacker.  Making
+of work by the attacker to clean up after himself, so most attackers do install
+backdoors.
+This gives you a convenient way to detect the attacker.
+Making
 it impossible for an attacker to install a backdoor may actually be detrimental
 to your security because it will not close off the hole the attacker used to
 break in in the first place.
 .Pp
 Security remedies should always be implemented with a multi-layered
-.Sq onion peel
+.Dq onion peel
 approach and can be categorized as follows:
 .Bl -enum -offset indent
 .It
 Securing root and staff accounts
 .It
-Securing root \(em root-run servers and suid/sgid binaries
+Securing root \(em root-run servers and SUID/SGID binaries
 .It
 Securing user accounts
 .It
@@ -129,69 +155,111 @@
 Paranoia
 .El
 .Sh SECURING THE ROOT ACCOUNT AND SECURING STAFF ACCOUNTS
-Don't bother securing staff accounts if you haven't secured the root
-account.  Most systems have a password assigned to the root account.  The
+Do not bother securing staff accounts if you have not secured the root
+account.
+Most systems have a password assigned to the root account.
+The
 first thing you do is assume that the password is
-.Sq always
-compromised.  This does not mean that you should remove the password.  The
+.Em always
+compromised.
+This does not mean that you should remove the password.
+The
 password is almost always necessary for console access to the machine.
 What it does mean is that you should not make it possible to use the password
 outside of the console or possibly even with a
 .Xr su 1
-command.
-For example, make sure that your pty's are specified as being unsecure
+utility.
+For example, make sure that your PTYs are specified as being
+.Dq Li unsecure
 in the
-.Sq Pa /etc/ttys
+.Pa /etc/ttys
 file
-so that direct root logins via telnet or rlogin are disallowed.  If using
-other login services such as sshd, make sure that direct root logins are
-disabled there as well.  Consider every access method \(em services such as
-ftp often fall through the cracks.  Direct root logins should only be allowed
+so that direct root logins via
+.Xr telnet 1
+or
+.Xr rlogin 1
+are disallowed.
+If using
+other login services such as
+.Xr sshd 8 ,
+make sure that direct root logins are
+disabled there as well.
+Consider every access method \(em services such as
+.Xr ftp 1
+often fall through the cracks.
+Direct root logins should only be allowed
 via the system console.
 .Pp
 Of course, as a sysadmin you have to be able to get to root, so we open up
-a few holes.  But we make sure these holes require additional password
-verification to operate.  One way to make root accessible is to add appropriate
-staff accounts to the wheel group
-(in
+a few holes.
+But we make sure these holes require additional password
+verification to operate.
+One way to make root accessible is to add appropriate
+staff accounts to the
+.Dq Li wheel
+group (in
 .Pa /etc/group ) .
-The staff members placed
-in the wheel group are allowed to
-.Sq su
-to root.  You should never give staff
-members native wheel access by putting them in the wheel group in their
-password entry.  Staff accounts should be placed in a
-.Sq staff
-group, and then added to the wheel group via the
-.Sq Pa /etc/group
-file.  Only those staff members who actually need to have root access
-should be placed in the wheel group.  It is also possible, when using an
-authentication method such as kerberos, to use kerberos's
-.Sq Pa .k5login
+The staff members placed in the
+.Li wheel
+group are allowed to
+.Xr su 1
+to root.
+You should never give staff
+members native
+.Li wheel
+access by putting them in the
+.Li wheel
+group in their password entry.
+Staff accounts should be placed in a
+.Dq Li staff
+group, and then added to the
+.Li wheel
+group via the
+.Pa /etc/group
+file.
+Only those staff members who actually need to have root access
+should be placed in the
+.Li wheel
+group.
+It is also possible, when using an
+authentication method such as Kerberos, to use Kerberos's
+.Pa .k5login
 file in the root account to allow a
 .Xr ksu 1
-to root without having to place anyone at all in the wheel group.  This
-may be the better solution since the wheel mechanism still allows an
+to root without having to place anyone at all in the
+.Li wheel
+group.
+This
+may be the better solution since the
+.Li wheel
+mechanism still allows an
 intruder to break root if the intruder has gotten hold of your password
-file and can break into a staff account.  While having the wheel mechanism
-is better than having nothing at all, it isn't necessarily the safest
+file and can break into a staff account.
+While having the
+.Li wheel
+mechanism
+is better than having nothing at all, it is not necessarily the safest
 option.
 .Pp
 An indirect way to secure the root account is to secure your staff accounts
 by using an alternative login access method and *'ing out the crypted password
-for the staff accounts.  This way an intruder may be able to steal the password
+for the staff accounts.
+This way an intruder may be able to steal the password
 file but will not be able to break into any staff accounts or root, even if
 root has a crypted password associated with it (assuming, of course, that
-you've limited root access to the console).  Staff members
+you have limited root access to the console).
+Staff members
 get into their staff accounts through a secure login mechanism such as
 .Xr kerberos 1
 or
 .Xr ssh 1
 using a private/public
-key pair.  When you use something like kerberos you generally must secure
-the machines which run the kerberos servers and your desktop workstation.
-When you use a public/private key pair with ssh, you must generally secure
-the machine you are logging in FROM
+key pair.
+When you use something like Kerberos you generally must secure
+the machines which run the Kerberos servers and your desktop workstation.
+When you use a public/private key pair with SSH, you must generally secure
+the machine you are logging in
+.Em from
 (typically your workstation),
 but you can
 also add an additional layer of protection to the key pair by password
@@ -199,63 +267,104 @@
 .Xr ssh-keygen 1 .
 Being able
 to *-out the passwords for staff accounts also guarantees that staff members
-can only login through secure access methods that you have setup.  You can
+can only log in through secure access methods that you have set up.
+You can
 thus force all staff members to use secure, encrypted connections for
-all their sessions which closes an important hole used by many intruders:  That
+all their sessions which closes an important hole used by many intruders: that
 of sniffing the network from an unrelated, less secure machine.
 .Pp
 The more indirect security mechanisms also assume that you are logging in
-from a more restrictive server to a less restrictive server.  For example,
-if your main box is running all sorts of servers, your workstation shouldn't
-be running any.  In order for your workstation to be reasonably secure
+from a more restrictive server to a less restrictive server.
+For example,
+if your main box is running all sorts of servers, your workstation should not
+be running any.
+In order for your workstation to be reasonably secure
 you should run as few servers as possible, up to and including no servers
 at all, and you should run a password-protected screen blanker.
 Of course, given physical access to
-a workstation an attacker can break any sort of security you put on it.
+a workstation, an attacker can break any sort of security you put on it.
 This is definitely a problem that you should consider but you should also
 consider the fact that the vast majority of break-ins occur remotely, over
 a network, from people who do not have physical access to your workstation or
 servers.
 .Pp
-Using something like kerberos also gives you the ability to disable or
+Using something like Kerberos also gives you the ability to disable or
 change the password for a staff account in one place and have it immediately
-affect all the machines the staff member may have an account on.  If a staff
+affect all the machines the staff member may have an account on.
+If a staff
 member's account gets compromised, the ability to instantly change his
-password on all machines should not be underrated.  With discrete passwords,
-changing a password on N machines can be a mess.  You can also impose
-re-passwording restrictions with kerberos:  not only can a kerberos ticket
-be made to timeout after a while, but the kerberos system can require that
+password on all machines should not be underrated.
+With discrete passwords, changing a password on N machines can be a mess.
+You can also impose
+re-passwording restrictions with Kerberos: not only can a Kerberos ticket
+be made to timeout after a while, but the Kerberos system can require that
 the user choose a new password after a certain period of time
 (say, once a month).
-.Sh SECURING ROOT \(em  ROOT-RUN SERVERS AND SUID/SGID BINARIES
-The prudent sysadmin only runs the servers he needs to, no more, no less.  Be
-aware that third party servers are often the most bug-prone.  For example,
-running an old version of imapd or popper is like giving a universal root
-ticket out to the entire world.  Never run a server that you have not checked
-out carefully.  Many servers do not need to be run as root.  For example,
-the ntalk, comsat, and finger daemons can be run in special user
-.Sq sandboxes .
-A sandbox isn't perfect unless you go to a large amount of trouble, but the
-onion approach to security still stands:  If someone is able to break in
+.Sh SECURING ROOT \(em ROOT-RUN SERVERS AND SUID/SGID BINARIES
+The prudent sysadmin only runs the servers he needs to, no more, no less.
+Be aware that third party servers are often the most bug-prone.
+For example,
+running an old version of
+.Xr imapd 8
+or
+.Xr popper 8
+is like giving a universal root
+ticket out to the entire world.
+Never run a server that you have not checked
+out carefully.
+Many servers do not need to be run as root.
+For example,
+the
+.Xr talkd 8 ,
+.Xr comsat 8 ,
+and
+.Xr fingerd 8
+daemons can be run in special user
+.Dq sandboxes .
+A sandbox is not perfect unless you go to a large amount of trouble, but the
+onion approach to security still stands: if someone is able to break in
 through a server running in a sandbox, they still have to break out of the
-sandbox.  The more layers the attacker must break through, the lower the
-likelihood of his success.  Root holes have historically been found in
+sandbox.
+The more layers the attacker must break through, the lower the
+likelihood of his success.
+Root holes have historically been found in
 virtually every server ever run as root, including basic system servers.
-If you are running a machine through which people only login via sshd and
-never login via telnetd or rshd or rlogind, then turn off those services!
+If you are running a machine through which people only log in via
+.Xr sshd 8
+and never log in via
+.Xr telnetd 8 ,
+.Xr rshd 8 ,
+or
+.Xr rlogind 8 ,
+then turn off those services!
 .Pp
 .Fx
-now defaults to running ntalkd, comsat, and finger in a sandbox.
+now defaults to running
+.Xr talkd 8 ,
+.Xr comsat 8 ,
+and
+.Xr fingerd 8
+in a sandbox.
 Another program which may be a candidate for running in a sandbox is
 .Xr named 8 .
-The default rc.conf includes the arguments necessary to run
-named in a sandbox in a commented-out form.  Depending on whether you
+The default
+.Pa rc.conf
+includes the arguments necessary to run
+.Xr named 8
+in a sandbox in a commented-out form.
+Depending on whether you
 are installing a new system or upgrading an existing system, the special
-user accounts used by these sandboxes may not be installed.  The prudent
+user accounts used by these sandboxes may not be installed.
+The prudent
 sysadmin would research and implement sandboxes for servers whenever possible.
 .Pp
 There are a number of other servers that typically do not run in sandboxes:
-sendmail, popper, imapd, ftpd, and others.  There are alternatives to
+.Xr sendmail 8 ,
+.Xr popper 8 ,
+.Xr imapd 8 ,
+.Xr ftpd 8 ,
+and others.
+There are alternatives to
 some of these, but installing them may require more work then you are willing
 to put
 (the convenience factor strikes again).
@@ -263,52 +372,69 @@
 servers as root and rely on other mechanisms to detect break-ins that might
 occur through them.
 .Pp
-The other big potential root hole in a system are the suid-root and sgid
-binaries installed on the system.  Most of these binaries, such as rlogin,
+The other big potential root hole in a system are the SUID-root and SGID
+binaries installed on the system.
+Most of these binaries, such as
+.Xr rlogin 1 ,
 reside in
-.Pa /bin ,
-.Pa /sbin ,
-.Pa /usr/bin ,
+.Pa /bin , /sbin , /usr/bin ,
 or
 .Pa /usr/sbin .
 While nothing is 100% safe,
-the system-default suid and sgid binaries can be considered reasonably safe.
-Still, root holes are occasionally found in these binaries.  A root hole
-was found in Xlib in 1998 that made xterm
-(which is typically suid)
+the system-default SUID and SGID binaries can be considered reasonably safe.
+Still, root holes are occasionally found in these binaries.
+A root hole
+was found in Xlib in 1998 that made
+.Xr xterm 1
+(which is typically SUID)
 vulnerable.
-It is better to be safe than sorry and the prudent sysadmin will restrict suid
+It is better to be safe than sorry and the prudent sysadmin will restrict SUID
 binaries that only staff should run to a special group that only staff can
 access, and get rid of
-.Pq Li "chmod 000"
-any suid binaries that nobody uses.  A
-server with no display generally does not need an xterm binary.  Sgid binaries
-can be almost as dangerous.  If an intruder can break an sgid-kmem binary the
+.Pq Dq Li "chmod 000"
+any SUID binaries that nobody uses.
+A server with no display generally does not need an
+.Xr xterm 1
+binary.
+SGID binaries can be almost as dangerous.
+If an intruder can break an SGID-kmem binary the
 intruder might be able to read
 .Pa /dev/kmem
 and thus read the crypted password
-file, potentially compromising any passworded account.  Alternatively an
-intruder who breaks group kmem can monitor keystrokes sent through pty's,
-including pty's used by users who login through secure methods.  An intruder
-that breaks the tty group can write to almost any user's tty.  If a user
+file, potentially compromising any passworded account.
+Alternatively an
+intruder who breaks group
+.Dq Li kmem
+can monitor keystrokes sent through PTYs,
+including PTYs used by users who log in through secure methods.
+An intruder
+that breaks the
+.Dq Li tty
+group can write to almost any user's TTY.
+If a user
 is running a terminal
 program or emulator with a keyboard-simulation feature, the intruder can
 potentially
 generate a data stream that causes the user's terminal to echo a command, which
 is then run as that user.
 .Sh SECURING USER ACCOUNTS
-User accounts are usually the most difficult to secure.  While you can impose
-Draconian access restrictions on your staff and *-out their passwords, you
-may not be able to do so with any general user accounts you might have.  If
+User accounts are usually the most difficult to secure.
+While you can impose
+draconian access restrictions on your staff and *-out their passwords, you
+may not be able to do so with any general user accounts you might have.
+If
 you do have sufficient control then you may win out and be able to secure the
-user accounts properly.  If not, you simply have to be more vigilant in your
-monitoring of those accounts.  Use of ssh and kerberos for user accounts is
+user accounts properly.
+If not, you simply have to be more vigilant in your
+monitoring of those accounts.
+Use of SSH and Kerberos for user accounts is
 more problematic due to the extra administration and technical support
 required, but still a very good solution compared to a crypted password
 file.
 .Sh SECURING THE PASSWORD FILE
 The only sure fire way is to *-out as many passwords as you can and
-use ssh or kerberos for access to those accounts.  Even though the
+use SSH or Kerberos for access to those accounts.
+Even though the
 crypted password file
 .Pq Pa /etc/spwd.db
 can only be read by root, it may
@@ -318,64 +444,102 @@
 Your security scripts should always check for and report changes to
 the password file
 (see
-.Sq Checking file integrity
+.Sx CHECKING FILE INTEGRITY
 below).
 .Sh SECURING THE KERNEL CORE, RAW DEVICES, AND FILE SYSTEMS
 If an attacker breaks root he can do just about anything, but there
-are certain conveniences.  For example, most modern kernels have a
-packet sniffing device driver built in.  Under
+are certain conveniences.
+For example, most modern kernels have a packet sniffing device driver built in.
+Under
 .Fx
 it is called
 the
-.Sq bpf
-device.  An intruder will commonly attempt to run a packet sniffer
-on a compromised machine.  You do not need to give the intruder the
-capability and most systems should not have the bpf device compiled in.
+.Xr bpf 4
+device.
+An intruder will commonly attempt to run a packet sniffer
+on a compromised machine.
+You do not need to give the intruder the
+capability and most systems should not have the
+.Xr bpf 4
+device compiled in.
 .Pp
-But even if you turn off the bpf device,
-you still have
+But even if you turn off the
+.Xr bpf 4
+device, you still have
 .Pa /dev/mem
 and
 .Pa /dev/kmem
-to worry about.  For that matter,
+to worry about.
+For that matter,
 the intruder can still write to raw disk devices.
 Also, there is another kernel feature called the module loader,
 .Xr kldload 8 .
 An enterprising intruder can use a KLD module to install
-his own bpf device or other sniffing device on a running kernel.
+his own
+.Xr bpf 4
+device or other sniffing device on a running kernel.
 To avoid these problems you have to run
-the kernel at a higher secure level, at least securelevel 1.  The securelevel
-can be set with a sysctl on the kern.securelevel variable.  Once you have
+the kernel at a higher secure level, at least securelevel 1.
+The securelevel can be set with a
+.Xr sysctl 8
+on the
+.Va kern.securelevel
+variable.
+Once you have
 set the securelevel to 1, write access to raw devices will be denied and
-special chflags flags, such as
-.Sq schg ,
-will be enforced.  You must also ensure
+special
+.Xr chflags 1
+flags, such as
+.Cm schg ,
+will be enforced.
+You must also ensure
 that the
-.Sq schg
+.Cm schg
 flag is set on critical startup binaries, directories, and
 script files \(em everything that gets run up to the point where the securelevel
-is set.  This might be overdoing it, and upgrading the system is much more
-difficult when you operate at a higher secure level.  You may compromise and
-run the system at a higher secure level but not set the schg flag for every
-system file and directory under the sun.  Another possibility is to simply
-mount / and /usr read-only.  It should be noted that being too draconian in
+is set.
+This might be overdoing it, and upgrading the system is much more
+difficult when you operate at a higher secure level.
+You may compromise and
+run the system at a higher secure level but not set the
+.Cm schg
+flag for every
+system file and directory under the sun.
+Another possibility is to simply
+mount
+.Pa /
+and
+.Pa /usr
+read-only.
+It should be noted that being too draconian in
 what you attempt to protect may prevent the all-important detection of an
 intrusion.
 .Sh CHECKING FILE INTEGRITY: BINARIES, CONFIG FILES, ETC
 When it comes right down to it, you can only protect your core system
 configuration and control files so much before the convenience factor
-rears its ugly head.  For example, using chflags to set the schg bit
-on most of the files in / and /usr is probably counterproductive because
-while it may protect the files, it also closes a detection window.  The
+rears its ugly head.
+For example, using
+.Xr chflags 1
+to set the
+.Cm schg
+bit on most of the files in
+.Pa /
+and
+.Pa /usr
+is probably counterproductive because
+while it may protect the files, it also closes a detection window.
+The
 last layer of your security onion is perhaps the most important \(em detection.
 The rest of your security is pretty much useless (or, worse, presents you with
-a false sense of safety) if you cannot detect potential incursions.  Half
+a false sense of safety) if you cannot detect potential incursions.
+Half
 the job of the onion is to slow down the attacker rather than stop him
 in order to give the detection layer a chance to catch him in
 the act.
 .Pp
 The best way to detect an incursion is to look for modified, missing, or
-unexpected files.  The best
+unexpected files.
+The best
 way to look for modified files is from another (often centralized)
 limited-access system.
 Writing your security scripts on the extra-secure limited-access system
@@ -383,64 +547,81 @@
 In order to take maximum advantage you generally have to give the
 limited-access box significant access to the other machines in the business,
 usually either by doing a read-only NFS export of the other machines to the
-limited-access box, or by setting up ssh keypairs to allow the limit-access
-box to ssh to the other machines.  Except for its network traffic, NFS is
+limited-access box, or by setting up SSH keypairs to allow the limit-access
+box to SSH to the other machines.
+Except for its network traffic, NFS is
 the least visible method \(em allowing you to monitor the file systems on each
-client box virtually undetected.  If your
+client box virtually undetected.
+If your
 limited-access server is connected to the client boxes through a switch,
-the NFS method is often the better choice.  If your limited-access server
+the NFS method is often the better choice.
+If your limited-access server
 is connected to the client boxes through a hub or through several layers
-of routing, the NFS method may be too insecure (network-wise) and using ssh
-may be the better choice even with the audit-trail tracks that ssh lays.
+of routing, the NFS method may be too insecure (network-wise) and using SSH
+may be the better choice even with the audit-trail tracks that SSH lays.
 .Pp
 Once you give a limit-access box at least read access to the client systems
 it is supposed to monitor, you must write scripts to do the actual
-monitoring.  Given an NFS mount, you can write scripts out of simple system
+monitoring.
+Given an NFS mount, you can write scripts out of simple system
 utilities such as
 .Xr find 1
 and
+.Xr md5 1 .
+It is best to physically
 .Xr md5 1
-It is best to physically md5 the client-box files boxes at least once a
+the client-box files boxes at least once a
 day, and to test control files such as those found in
 .Pa /etc
 and
 .Pa /usr/local/etc
-even more often.  When mismatches are found relative to the base md5
+even more often.
+When mismatches are found relative to the base MD5
 information the limited-access machine knows is valid, it should scream at
-a sysadmin to go check it out.  A good security script will also check for
-inappropriate suid binaries and for new or deleted files on system partitions
+a sysadmin to go check it out.
+A good security script will also check for
+inappropriate SUID binaries and for new or deleted files on system partitions
 such as
 .Pa /
 and
-.Pa /usr
+.Pa /usr .
 .Pp
-When using ssh rather than NFS, writing the security script is much more
-difficult.   You essentially have to
-.Pa scp
+When using SSH rather than NFS, writing the security script is much more
+difficult.
+You essentially have to
+.Xr scp 1
 the scripts to the client box in order to run them, making them visible, and
-for safety you also need to scp the binaries (such as find) that those scripts
-use.  The ssh daemon on the client box may already be compromised.  All in all,
-using ssh may be necessary when running over unsecure links, but it's also a
+for safety you also need to
+.Xr scp 1
+the binaries (such as
+.Xr find 1 )
+that those scripts use.
+The
+.Xr sshd 8
+daemon on the client box may already be compromised.
+All in all,
+using SSH may be necessary when running over unsecure links, but it is also a
 lot harder to deal with.
 .Pp
 A good security script will also check for changes to user and staff members
 access configuration files:
-.Pa .rhosts ,
-.Pa .shosts ,
-.Pa .ssh/authorized_keys
+.Pa .rhosts , .shosts , .ssh/authorized_keys
 and so forth... files that might fall outside the purview of the MD5 check.
 .Pp
 If you have a huge amount of user disk space it may take too long to run
-through every file on those partitions.  In this case, setting mount
-flags to disallow suid binaries and devices on those partitions is a good
-idea.  The
-.Sq nodev
+through every file on those partitions.
+In this case, setting mount
+flags to disallow SUID binaries and devices on those partitions is a good
+idea.
+The
+.Cm nodev
 and
-.Sq nosuid
+.Cm nosuid
 options
 (see
 .Xr mount 8 )
-are what you want to look into.  I would scan them anyway at least once a
+are what you want to look into.
+I would scan them anyway at least once a
 week, since the object of this layer is to detect a break-in whether or
 not the break-in is effective.
 .Pp
@@ -449,82 +630,110 @@
 .Xr accton 8 )
 is a relatively low-overhead feature of
 the operating system which I recommend using as a post-break-in evaluation
-mechanism.  It is especially useful in tracking down how an intruder has
+mechanism.
+It is especially useful in tracking down how an intruder has
 actually broken into a system, assuming the file is still intact after
 the break-in occurs.
 .Pp
 Finally, security scripts should process the log files and the logs themselves

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list