1.\" Copyright (c) 1998, Matthew Dillon. Terms and conditions are those of 2.\" the BSD Copyright as specified in the file "/usr/src/COPYRIGHT" in 3.\" the source tree. 4.\" 5.\" $FreeBSD$ 6.\" 7.Dd September 18, 1999 8.Dt SECURITY 7 9.Os 10.Sh NAME 11.Nm security 12.Nd introduction to security under 13.Fx 14.Sh DESCRIPTION 15Security is a function that begins and ends with the system administrator. 16While all 17.Bx 18multi-user systems have some inherent security, the job of building and 19maintaining additional security mechanisms to keep users 20.Dq honest 21is probably 22one of the single largest undertakings of the sysadmin. 23Machines are 24only as secure as you make them, and security concerns are ever competing 25with the human necessity for convenience. 26.Ux 27systems, 28in general, are capable of running a huge number of simultaneous processes 29and many of these processes operate as servers \(em meaning that external 30entities can connect and talk to them. 31As yesterday's mini-computers and mainframes 32become today's desktops, and as computers become networked and internetworked, 33security becomes an ever bigger issue. 34.Pp 35Security is best implemented through a layered onion approach. 36In a nutshell, 37what you want to do is to create as many layers of security as are convenient 38and then carefully monitor the system for intrusions. 39You do not want to 40overbuild your security or you will interfere with the detection side, and 41detection is one of the single most important aspects of any security 42mechanism. 43For example, it makes little sense to set the 44.Cm schg 45flags 46(see 47.Xr chflags 1 ) 48on every system binary because while this may temporarily protect the 49binaries, it prevents an attacker who has broken in from making an 50easily detectable change that may result in your security mechanisms not 51detecting the attacker at all. 52.Pp 53System security also pertains to dealing with various forms of attacks, 54including attacks that attempt to crash or otherwise make a system unusable 55but do not attempt to break root. 56Security concerns can be split up into 57several categories: 58.Bl -enum -offset indent 59.It 60Denial of Service attacks (DoS) 61.It 62User account compromises 63.It 64Root compromise through accessible servers 65.It 66Root compromise via user accounts 67.It 68Backdoor creation 69.El 70.Pp 71A denial of service attack is an action that deprives the machine of needed 72resources. 73Typically, DoS attacks are brute-force mechanisms that attempt 74to crash or otherwise make a machine unusable by overwhelming its servers or 75network stack. 76Some DoS attacks try to take advantages of bugs in the 77networking stack to crash a machine with a single packet. 78The latter can 79only be fixed by applying a bug fix to the kernel. 80Attacks on servers can 81often be fixed by properly specifying options to limit the load the servers 82incur on the system under adverse conditions. 83Brute-force network attacks are harder to deal with. 84A spoofed-packet attack, for example, is 85nearly impossible to stop short of cutting your system off from the Internet. 86It may not be able to take your machine down, but it can fill up Internet 87pipe. 88.Pp 89A user account compromise is even more common than a DoS attack. 90Many 91sysadmins still run standard 92.Xr telnetd 8 , 93.Xr rlogind 8 , 94.Xr rshd 8 , 95and 96.Xr ftpd 8 97servers on their machines. 98These servers, by default, do not operate over encrypted 99connections. 100The result is that if you have any moderate-sized user base, 101one or more of your users logging into your system from a remote location 102(which is the most common and convenient way to log in to a system) 103will have his or her password sniffed. 104The attentive system administrator will analyze 105his remote access logs looking for suspicious source addresses 106even for successful logins. 107.Pp 108One must always assume that once an attacker has access to a user account, 109the attacker can break root. 110However, the reality is that in a well secured 111and maintained system, access to a user account does not necessarily give the 112attacker access to root. 113The distinction is important because without access 114to root the attacker cannot generally hide his tracks and may, at best, be 115able to do nothing more than mess with the user's files or crash the machine. 116User account compromises are very common because users tend not to take the 117precautions that sysadmins take. 118.Pp 119System administrators must keep in mind that there are potentially many ways 120to break root on a machine. 121The attacker may know the root password, 122the attacker 123may find a bug in a root-run server and be able to break root over a network 124connection to that server, or the attacker may know of a bug in an SUID-root 125program that allows the attacker to break root once he has broken into a 126user's account. 127If an attacker has found a way to break root on a machine, 128the attacker may not have a need to install a backdoor. 129Many of the root holes found and closed to date involve a considerable amount 130of work by the attacker to clean up after himself, so most attackers do install 131backdoors. 132This gives you a convenient way to detect the attacker. 133Making 134it impossible for an attacker to install a backdoor may actually be detrimental 135to your security because it will not close off the hole the attacker used to 136break in in the first place. 137.Pp 138Security remedies should always be implemented with a multi-layered 139.Dq onion peel 140approach and can be categorized as follows: 141.Bl -enum -offset indent 142.It 143Securing root and staff accounts 144.It 145Securing root \(em root-run servers and SUID/SGID binaries 146.It 147Securing user accounts 148.It 149Securing the password file 150.It 151Securing the kernel core, raw devices, and file systems 152.It 153Quick detection of inappropriate changes made to the system 154.It 155Paranoia 156.El 157.Sh SECURING THE ROOT ACCOUNT AND SECURING STAFF ACCOUNTS 158Do not bother securing staff accounts if you have not secured the root 159account. 160Most systems have a password assigned to the root account. 161The 162first thing you do is assume that the password is 163.Em always 164compromised. 165This does not mean that you should remove the password. 166The 167password is almost always necessary for console access to the machine. 168What it does mean is that you should not make it possible to use the password 169outside of the console or possibly even with a 170.Xr su 1 171utility. 172For example, make sure that your PTYs are specified as being 173.Dq Li unsecure 174in the 175.Pa /etc/ttys 176file 177so that direct root logins via 178.Xr telnet 1 179or 180.Xr rlogin 1 181are disallowed. 182If using 183other login services such as 184.Xr sshd 8 , 185make sure that direct root logins are 186disabled there as well. 187Consider every access method \(em services such as 188.Xr ftp 1 189often fall through the cracks. 190Direct root logins should only be allowed 191via the system console. 192.Pp 193Of course, as a sysadmin you have to be able to get to root, so we open up 194a few holes. 195But we make sure these holes require additional password 196verification to operate. 197One way to make root accessible is to add appropriate 198staff accounts to the 199.Dq Li wheel 200group (in 201.Pa /etc/group ) . 202The staff members placed in the 203.Li wheel 204group are allowed to 205.Xr su 1 206to root. 207You should never give staff 208members native 209.Li wheel 210access by putting them in the 211.Li wheel 212group in their password entry. 213Staff accounts should be placed in a 214.Dq Li staff 215group, and then added to the 216.Li wheel 217group via the 218.Pa /etc/group 219file. 220Only those staff members who actually need to have root access 221should be placed in the 222.Li wheel 223group. 224It is also possible, when using an 225authentication method such as Kerberos, to use Kerberos's 226.Pa .k5login 227file in the root account to allow a 228.Xr ksu 1 229to root without having to place anyone at all in the 230.Li wheel 231group. 232This 233may be the better solution since the 234.Li wheel 235mechanism still allows an 236intruder to break root if the intruder has gotten hold of your password 237file and can break into a staff account. 238While having the 239.Li wheel 240mechanism 241is better than having nothing at all, it is not necessarily the safest 242option. 243.Pp 244An indirect way to secure the root account is to secure your staff accounts 245by using an alternative login access method and *'ing out the crypted password 246for the staff accounts. 247This way an intruder may be able to steal the password 248file but will not be able to break into any staff accounts or root, even if 249root has a crypted password associated with it (assuming, of course, that 250you have limited root access to the console). 251Staff members 252get into their staff accounts through a secure login mechanism such as 253.Xr kerberos 1 254or 255.Xr ssh 1 256using a private/public 257key pair. 258When you use something like Kerberos you generally must secure 259the machines which run the Kerberos servers and your desktop workstation. 260When you use a public/private key pair with SSH, you must generally secure 261the machine you are logging in 262.Em from 263(typically your workstation), 264but you can 265also add an additional layer of protection to the key pair by password 266protecting the keypair when you create it with 267.Xr ssh-keygen 1 . 268Being able 269to *-out the passwords for staff accounts also guarantees that staff members 270can only log in through secure access methods that you have set up. 271You can 272thus force all staff members to use secure, encrypted connections for 273all their sessions which closes an important hole used by many intruders: that 274of sniffing the network from an unrelated, less secure machine. 275.Pp 276The more indirect security mechanisms also assume that you are logging in 277from a more restrictive server to a less restrictive server. 278For example, 279if your main box is running all sorts of servers, your workstation should not 280be running any. 281In order for your workstation to be reasonably secure 282you should run as few servers as possible, up to and including no servers 283at all, and you should run a password-protected screen blanker. 284Of course, given physical access to 285a workstation, an attacker can break any sort of security you put on it. 286This is definitely a problem that you should consider but you should also 287consider the fact that the vast majority of break-ins occur remotely, over 288a network, from people who do not have physical access to your workstation or 289servers. 290.Pp 291Using something like Kerberos also gives you the ability to disable or 292change the password for a staff account in one place and have it immediately 293affect all the machines the staff member may have an account on. 294If a staff 295member's account gets compromised, the ability to instantly change his 296password on all machines should not be underrated. 297With discrete passwords, changing a password on N machines can be a mess. 298You can also impose 299re-passwording restrictions with Kerberos: not only can a Kerberos ticket 300be made to timeout after a while, but the Kerberos system can require that 301the user choose a new password after a certain period of time 302(say, once a month). 303.Sh SECURING ROOT \(em ROOT-RUN SERVERS AND SUID/SGID BINARIES 304The prudent sysadmin only runs the servers he needs to, no more, no less. 305Be aware that third party servers are often the most bug-prone. 306For example, 307running an old version of 308.Xr imapd 8 309or 310.Xr popper 8 311is like giving a universal root 312ticket out to the entire world. 313Never run a server that you have not checked 314out carefully. 315Many servers do not need to be run as root. 316For example, 317the 318.Xr talkd 8 , 319.Xr comsat 8 , 320and 321.Xr fingerd 8 322daemons can be run in special user 323.Dq sandboxes . 324A sandbox is not perfect unless you go to a large amount of trouble, but the 325onion approach to security still stands: if someone is able to break in 326through a server running in a sandbox, they still have to break out of the 327sandbox. 328The more layers the attacker must break through, the lower the 329likelihood of his success. 330Root holes have historically been found in 331virtually every server ever run as root, including basic system servers. 332If you are running a machine through which people only log in via 333.Xr sshd 8 334and never log in via 335.Xr telnetd 8 , 336.Xr rshd 8 , 337or 338.Xr rlogind 8 , 339then turn off those services! 340.Pp 341.Fx 342now defaults to running 343.Xr talkd 8 , 344.Xr comsat 8 , 345and 346.Xr fingerd 8 347in a sandbox. 348Another program which may be a candidate for running in a sandbox is 349.Xr named 8 . 350The default 351.Pa rc.conf 352includes the arguments necessary to run 353.Xr named 8 354in a sandbox in a commented-out form. 355Depending on whether you 356are installing a new system or upgrading an existing system, the special 357user accounts used by these sandboxes may not be installed. 358The prudent 359sysadmin would research and implement sandboxes for servers whenever possible. 360.Pp 361There are a number of other servers that typically do not run in sandboxes: 362.Xr sendmail 8 , 363.Xr popper 8 , 364.Xr imapd 8 , 365.Xr ftpd 8 , 366and others. 367There are alternatives to 368some of these, but installing them may require more work then you are willing 369to put 370(the convenience factor strikes again). 371You may have to run these 372servers as root and rely on other mechanisms to detect break-ins that might 373occur through them. 374.Pp 375The other big potential root hole in a system are the SUID-root and SGID 376binaries installed on the system. 377Most of these binaries, such as 378.Xr rlogin 1 , 379reside in 380.Pa /bin , /sbin , /usr/bin , 381or 382.Pa /usr/sbin . 383While nothing is 100% safe, 384the system-default SUID and SGID binaries can be considered reasonably safe. 385Still, root holes are occasionally found in these binaries. 386A root hole 387was found in Xlib in 1998 that made 388.Xr xterm 1 389(which is typically SUID) 390vulnerable. 391It is better to be safe than sorry and the prudent sysadmin will restrict SUID 392binaries that only staff should run to a special group that only staff can 393access, and get rid of 394.Pq Dq Li "chmod 000" 395any SUID binaries that nobody uses. 396A server with no display generally does not need an 397.Xr xterm 1 398binary. 399SGID binaries can be almost as dangerous. 400If an intruder can break an SGID-kmem binary the 401intruder might be able to read 402.Pa /dev/kmem 403and thus read the crypted password 404file, potentially compromising any passworded account. 405Alternatively an 406intruder who breaks group 407.Dq Li kmem 408can monitor keystrokes sent through PTYs, 409including PTYs used by users who log in through secure methods. 410An intruder 411that breaks the 412.Dq Li tty 413group can write to almost any user's TTY. 414If a user 415is running a terminal 416program or emulator with a keyboard-simulation feature, the intruder can 417potentially 418generate a data stream that causes the user's terminal to echo a command, which 419is then run as that user. 420.Sh SECURING USER ACCOUNTS 421User accounts are usually the most difficult to secure. 422While you can impose 423draconian access restrictions on your staff and *-out their passwords, you 424may not be able to do so with any general user accounts you might have. 425If 426you do have sufficient control then you may win out and be able to secure the 427user accounts properly. 428If not, you simply have to be more vigilant in your 429monitoring of those accounts. 430Use of SSH and Kerberos for user accounts is 431more problematic due to the extra administration and technical support 432required, but still a very good solution compared to a crypted password 433file. 434.Sh SECURING THE PASSWORD FILE 435The only sure fire way is to *-out as many passwords as you can and 436use SSH or Kerberos for access to those accounts. 437Even though the 438crypted password file 439.Pq Pa /etc/spwd.db 440can only be read by root, it may 441be possible for an intruder to obtain read access to that file even if the 442attacker cannot obtain root-write access. 443.Pp 444Your security scripts should always check for and report changes to 445the password file 446(see 447.Sx CHECKING FILE INTEGRITY 448below). 449.Sh SECURING THE KERNEL CORE, RAW DEVICES, AND FILE SYSTEMS 450If an attacker breaks root he can do just about anything, but there 451are certain conveniences. 452For example, most modern kernels have a packet sniffing device driver built in. 453Under 454.Fx 455it is called 456the 457.Xr bpf 4 458device. 459An intruder will commonly attempt to run a packet sniffer 460on a compromised machine. 461You do not need to give the intruder the 462capability and most systems should not have the 463.Xr bpf 4 464device compiled in. 465.Pp 466But even if you turn off the 467.Xr bpf 4 468device, you still have 469.Pa /dev/mem 470and 471.Pa /dev/kmem 472to worry about. 473For that matter, 474the intruder can still write to raw disk devices. 475Also, there is another kernel feature called the module loader, 476.Xr kldload 8 . 477An enterprising intruder can use a KLD module to install 478his own 479.Xr bpf 4 480device or other sniffing device on a running kernel. 481To avoid these problems you have to run 482the kernel at a higher secure level, at least securelevel 1. 483The securelevel can be set with a 484.Xr sysctl 8 485on the 486.Va kern.securelevel 487variable. 488Once you have 489set the securelevel to 1, write access to raw devices will be denied and 490special 491.Xr chflags 1 492flags, such as 493.Cm schg , 494will be enforced. 495You must also ensure 496that the 497.Cm schg 498flag is set on critical startup binaries, directories, and 499script files \(em everything that gets run up to the point where the securelevel 500is set. 501This might be overdoing it, and upgrading the system is much more 502difficult when you operate at a higher secure level. 503You may compromise and 504run the system at a higher secure level but not set the 505.Cm schg 506flag for every 507system file and directory under the sun. 508Another possibility is to simply 509mount 510.Pa / 511and 512.Pa /usr 513read-only. 514It should be noted that being too draconian in 515what you attempt to protect may prevent the all-important detection of an 516intrusion. 517.Sh CHECKING FILE INTEGRITY: BINARIES, CONFIG FILES, ETC 518When it comes right down to it, you can only protect your core system 519configuration and control files so much before the convenience factor 520rears its ugly head. 521For example, using 522.Xr chflags 1 523to set the 524.Cm schg 525bit on most of the files in 526.Pa / 527and 528.Pa /usr 529is probably counterproductive because 530while it may protect the files, it also closes a detection window. 531The 532last layer of your security onion is perhaps the most important \(em detection. 533The rest of your security is pretty much useless (or, worse, presents you with 534a false sense of safety) if you cannot detect potential incursions. 535Half 536the job of the onion is to slow down the attacker rather than stop him 537in order to give the detection layer a chance to catch him in 538the act. 539.Pp 540The best way to detect an incursion is to look for modified, missing, or 541unexpected files. 542The best 543way to look for modified files is from another (often centralized) 544limited-access system. 545Writing your security scripts on the extra-secure limited-access system 546makes them mostly invisible to potential attackers, and this is important. 547In order to take maximum advantage you generally have to give the 548limited-access box significant access to the other machines in the business, 549usually either by doing a read-only NFS export of the other machines to the 550limited-access box, or by setting up SSH keypairs to allow the limit-access 551box to SSH to the other machines. 552Except for its network traffic, NFS is 553the least visible method \(em allowing you to monitor the file systems on each 554client box virtually undetected. 555If your 556limited-access server is connected to the client boxes through a switch, 557the NFS method is often the better choice. 558If your limited-access server 559is connected to the client boxes through a hub or through several layers 560of routing, the NFS method may be too insecure (network-wise) and using SSH 561may be the better choice even with the audit-trail tracks that SSH lays. 562.Pp 563Once you give a limit-access box at least read access to the client systems 564it is supposed to monitor, you must write scripts to do the actual 565monitoring. 566Given an NFS mount, you can write scripts out of simple system 567utilities such as 568.Xr find 1 569and 570.Xr md5 1 . 571It is best to physically 572.Xr md5 1 573the client-box files boxes at least once a 574day, and to test control files such as those found in 575.Pa /etc 576and 577.Pa /usr/local/etc 578even more often. 579When mismatches are found relative to the base MD5 580information the limited-access machine knows is valid, it should scream at 581a sysadmin to go check it out. 582A good security script will also check for 583inappropriate SUID binaries and for new or deleted files on system partitions 584such as 585.Pa / 586and 587.Pa /usr . 588.Pp 589When using SSH rather than NFS, writing the security script is much more 590difficult. 591You essentially have to 592.Xr scp 1 593the scripts to the client box in order to run them, making them visible, and 594for safety you also need to 595.Xr scp 1 596the binaries (such as 597.Xr find 1 ) 598that those scripts use. 599The 600.Xr sshd 8 601daemon on the client box may already be compromised. 602All in all, 603using SSH may be necessary when running over unsecure links, but it is also a 604lot harder to deal with. 605.Pp 606A good security script will also check for changes to user and staff members 607access configuration files: 608.Pa .rhosts , .shosts , .ssh/authorized_keys 609and so forth, files that might fall outside the purview of the MD5 check. 610.Pp 611If you have a huge amount of user disk space it may take too long to run 612through every file on those partitions. 613In this case, setting mount 614flags to disallow SUID binaries and devices on those partitions is a good 615idea. 616The 617.Cm nodev 618and 619.Cm nosuid 620options 621(see 622.Xr mount 8 ) 623are what you want to look into. 624I would scan them anyway at least once a 625week, since the object of this layer is to detect a break-in whether or 626not the break-in is effective. 627.Pp 628Process accounting 629(see 630.Xr accton 8 ) 631is a relatively low-overhead feature of 632the operating system which I recommend using as a post-break-in evaluation 633mechanism. 634It is especially useful in tracking down how an intruder has 635actually broken into a system, assuming the file is still intact after 636the break-in occurs. 637.Pp 638Finally, security scripts should process the log files and the logs themselves 639should be generated in as secure a manner as possible \(em remote syslog can be 640very useful. 641An intruder tries to cover his tracks, and log files are critical 642to the sysadmin trying to track down the time and method of the initial 643break-in. 644One way to keep a permanent record of the log files is to run 645the system console to a serial port and collect the information on a 646continuing basis through a secure machine monitoring the consoles. 647.Sh PARANOIA 648A little paranoia never hurts. 649As a rule, a sysadmin can add any number 650of security features as long as they do not affect convenience, and 651can add security features that do affect convenience with some added 652thought. 653Even more importantly, a security administrator should mix it up 654a bit \(em if you use recommendations such as those given by this manual 655page verbatim, you give away your methodologies to the prospective 656attacker who also has access to this manual page. 657.Sh SPECIAL SECTION ON DoS ATTACKS 658This section covers Denial of Service attacks. 659A DoS attack is typically a packet attack. 660While there is not much you can do about modern spoofed 661packet attacks that saturate your network, you can generally limit the damage 662by ensuring that the attacks cannot take down your servers. 663.Bl -enum -offset indent 664.It 665Limiting server forks 666.It 667Limiting springboard attacks (ICMP response attacks, ping broadcast, etc.) 668.It 669Kernel Route Cache 670.El 671.Pp 672A common DoS attack is against a forking server that attempts to cause the 673server to eat processes, file descriptors, and memory until the machine 674dies. 675The 676.Xr inetd 8 677server 678has several options to limit this sort of attack. 679It should be noted that while it is possible to prevent a machine from going 680down it is not generally possible to prevent a service from being disrupted 681by the attack. 682Read the 683.Xr inetd 8 684manual page carefully and pay specific attention 685to the 686.Fl c , C , 687and 688.Fl R 689options. 690Note that spoofed-IP attacks will circumvent 691the 692.Fl C 693option to 694.Xr inetd 8 , 695so typically a combination of options must be used. 696Some standalone servers have self-fork-limitation parameters. 697.Pp 698The 699.Xr sendmail 8 700daemon has its 701.Fl OMaxDaemonChildren 702option which tends to work much 703better than trying to use 704.Xr sendmail 8 Ns 's 705load limiting options due to the 706load lag. 707You should specify a 708.Va MaxDaemonChildren 709parameter when you start 710.Xr sendmail 8 711high enough to handle your expected load but not so high that the 712computer cannot handle that number of 713.Nm sendmail Ns 's 714without falling on its face. 715It is also prudent to run 716.Xr sendmail 8 717in 718.Dq queued 719mode 720.Pq Fl ODeliveryMode=queued 721and to run the daemon 722.Pq Dq Nm sendmail Fl bd 723separate from the queue-runs 724.Pq Dq Nm sendmail Fl q15m . 725If you still want real-time delivery you can run the queue 726at a much lower interval, such as 727.Fl q1m , 728but be sure to specify a reasonable 729.Va MaxDaemonChildren 730option for that 731.Xr sendmail 8 732to prevent cascade failures. 733.Pp 734The 735.Xr syslogd 8 736daemon can be attacked directly and it is strongly recommended that you use 737the 738.Fl s 739option whenever possible, and the 740.Fl a 741option otherwise. 742.Pp 743You should also be fairly careful 744with connect-back services such as tcpwrapper's reverse-identd, which can 745be attacked directly. 746You generally do not want to use the reverse-ident 747feature of tcpwrappers for this reason. 748.Pp 749It is a very good idea to protect internal services from external access 750by firewalling them off at your border routers. 751The idea here is to prevent 752saturation attacks from outside your LAN, not so much to protect internal 753services from network-based root compromise. 754Always configure an exclusive 755firewall, i.e., 756.So 757firewall everything 758.Em except 759ports A, B, C, D, and M-Z 760.Sc . 761This 762way you can firewall off all of your low ports except for certain specific 763services such as 764.Xr named 8 765(if you are primary for a zone), 766.Xr talkd 8 , 767.Xr sendmail 8 , 768and other internet-accessible services. 769If you try to configure the firewall the other 770way \(em as an inclusive or permissive firewall, there is a good chance that you 771will forget to 772.Dq close 773a couple of services or that you will add a new internal 774service and forget to update the firewall. 775You can still open up the 776high-numbered port range on the firewall to allow permissive-like operation 777without compromising your low ports. 778Also take note that 779.Fx 780allows you to 781control the range of port numbers used for dynamic binding via the various 782.Va net.inet.ip.portrange 783sysctl's 784.Pq Dq Li "sysctl net.inet.ip.portrange" , 785which can also 786ease the complexity of your firewall's configuration. 787I usually use a normal 788first/last range of 4000 to 5000, and a hiport range of 49152 to 65535, then 789block everything under 4000 off in my firewall 790(except for certain specific 791internet-accessible ports, of course). 792.Pp 793Another common DoS attack is called a springboard attack \(em to attack a server 794in a manner that causes the server to generate responses which then overload 795the server, the local network, or some other machine. 796The most common attack 797of this nature is the ICMP PING BROADCAST attack. 798The attacker spoofs ping 799packets sent to your LAN's broadcast address with the source IP address set 800to the actual machine they wish to attack. 801If your border routers are not 802configured to stomp on ping's to broadcast addresses, your LAN winds up 803generating sufficient responses to the spoofed source address to saturate the 804victim, especially when the attacker uses the same trick on several dozen 805broadcast addresses over several dozen different networks at once. 806Broadcast attacks of over a hundred and twenty megabits have been measured. 807A second common springboard attack is against the ICMP error reporting system. 808By 809constructing packets that generate ICMP error responses, an attacker can 810saturate a server's incoming network and cause the server to saturate its 811outgoing network with ICMP responses. 812This type of attack can also crash the 813server by running it out of 814.Vt mbuf Ns 's , 815especially if the server cannot drain the 816ICMP responses it generates fast enough. 817The 818.Fx 819kernel has a new kernel 820compile option called 821.Dv ICMP_BANDLIM 822which limits the effectiveness of these 823sorts of attacks. 824The last major class of springboard attacks is related to 825certain internal 826.Xr inetd 8 827services such as the UDP echo service. 828An attacker 829simply spoofs a UDP packet with the source address being server A's echo port, 830and the destination address being server B's echo port, where server A and B 831are both on your LAN. 832The two servers then bounce this one packet back and 833forth between each other. 834The attacker can overload both servers and their 835LANs simply by injecting a few packets in this manner. 836Similar problems 837exist with the internal chargen port. 838A competent sysadmin will turn off all 839of these 840.Xr inetd 8 Ns -internal 841test services. 842.Pp 843Spoofed packet attacks may also be used to overload the kernel route cache. 844Refer to the 845.Va net.inet.ip.rtexpire , net.inet.ip.rtminexpire , 846and 847.Va net.inet.ip.rtmaxcache 848.Xr sysctl 8 849variables. 850A spoofed packet attack that uses a random source IP will cause 851the kernel to generate a temporary cached route in the route table, viewable 852with 853.Dq Li "netstat -rna | fgrep W3" . 854These routes typically timeout in 1600 855seconds or so. 856If the kernel detects that the cached route table has gotten 857too big it will dynamically reduce the 858.Va rtexpire 859but will never decrease it to 860less than 861.Va rtminexpire . 862There are two problems: (1) The kernel does not react 863quickly enough when a lightly loaded server is suddenly attacked, and (2) The 864.Va rtminexpire 865is not low enough for the kernel to survive a sustained attack. 866If your servers are connected to the internet via a T3 or better it may be 867prudent to manually override both 868.Va rtexpire 869and 870.Va rtminexpire 871via 872.Xr sysctl 8 . 873Never set either parameter to zero 874(unless you want to crash the machine :-)). 875Setting both parameters to 2 seconds should be sufficient to protect the route 876table from attack. 877.Sh ACCESS ISSUES WITH KERBEROS AND SSH 878There are a few issues with both Kerberos and SSH that need to be addressed 879if you intend to use them. 880Kerberos5 is an excellent authentication 881protocol but the kerberized 882.Xr telnet 1 883and 884.Xr rlogin 1 885suck rocks. 886There are bugs that make them unsuitable for dealing with binary streams. 887Also, by default 888Kerberos does not encrypt a session unless you use the 889.Fl x 890option. 891SSH encrypts everything by default. 892.Pp 893SSH works quite well in every respect except when it is set up to 894forward encryption keys. 895What this means is that if you have a secure workstation holding 896keys that give you access to the rest of the system, and you 897.Xr ssh 1 898to an 899unsecure machine, your keys become exposed. 900The actual keys themselves are 901not exposed, but 902.Xr ssh 1 903installs a forwarding port for the duration of your 904login and if an attacker has broken root on the unsecure machine he can utilize 905that port to use your keys to gain access to any other machine that your 906keys unlock. 907.Pp 908We recommend that you use SSH in combination with Kerberos whenever possible 909for staff logins. 910SSH can be compiled with Kerberos support. 911This reduces 912your reliance on potentially exposable SSH keys while at the same time 913protecting passwords via Kerberos. 914SSH keys 915should only be used for automated tasks from secure machines (something 916that Kerberos is unsuited to). 917We also recommend that you either turn off 918key-forwarding in the SSH configuration, or that you make use of the 919.Va from Ns = Ns Ar IP/DOMAIN 920option that SSH allows in its 921.Pa authorized_keys 922file to make the key only usable to entities logging in from specific 923machines. 924.Sh SEE ALSO 925.Xr chflags 1 , 926.Xr find 1 , 927.Xr md5 1 , 928.Xr netstat 1 , 929.Xr openssl 1 , 930.Xr ssh 1 , 931.Xr xdm 1 , 932.Xr group 5 , 933.Xr ttys 5 , 934.Xr accton 8 , 935.Xr init 8 , 936.Xr sshd 8 , 937.Xr sysctl 8 , 938.Xr syslogd 8 , 939.Xr vipw 8 940.Sh HISTORY 941The 942.Nm 943manual page was originally written by 944.An Matthew Dillon 945and first appeared 946in 947.Fx 3.1 , 948December 1998. 949