8.8 Administrative Techniques for Conventional PasswordsIf you're a system administrator and you are stuck using conventional UNIX passwords, then you will find this section helpful. It describes a number of techniques that you can use to limit the danger of conventional passwords on your computer. 8.8.1 Assigning Passwords to UsersGetting users to pick good passwords can be very difficult. You can tell users horror stories and you can threaten them, but some users will always pick easy-to-guess passwords. Because a single user with a bad password can compromise the security of the entire system, some UNIX administrators assign passwords to users directly rather than letting users choose their own. To prevent users from changing their own passwords, all that you have to do is to change the permissions on the /bin/passwd program that changes people's passwords.[14] Making the program executable only by people in the staff group, for example, will still allow staff members to change their own passwords, but will prevent other people from doing so:
# chgrp staff /bin/passwd # chmod 4750 /bin/passwd Use this approach only if staff members are available 24 hours a day. Otherwise, if a user discovers that someone has been using her account, or if she accidentally discloses her password, the user is powerless to safeguard the account until she has contacted someone on staff. Some versions of UNIX may have an administrator command that will allow you to prevent selected users from changing their passwords.[15] Thus, you do not need to change the permissions on the passwd program. You only need to disable the capability for those users who cannot be trusted to set good passwords on their own.
For example, in SVR4 UNIX , you can prevent a user from changing her password by setting the aging parameters appropriately (we discuss password aging in a few more pages). For example, to prevent Kevin from changing his password, you might use the command: # passwd -n 60 -x 50 kevin Note, however, that Kevin's password will expire in 50 days and will need to be reset by someone with superuser access. 8.8.2 Constraining PasswordsYou can easily strengthen the passwd program to disallow users from picking easy-to-guess passwords - such as those based on the user's own name, other accounts on the system, or on a word in the UNIX dictionary. So far, however, many UNIX vendors have not made the necessary modifications to their software. There are some freeware packages available on the net, including npasswd and passwd+ , which can be used for this purpose; both are available at popular FTP archives, including coast.cs.purdue.edu . Another popular system is anlpasswd, which has some advantages over npasswd and passwd+, and can be found at info.mcs.anl.gov. Some versions of UNIX , most notably the Linux operating system, come supplied with npasswd . Other vendors would do well to follow this example. An approach that is present in many versions of UNIX involves putting constraints on the passwords that users can select. Normally, this approach is controlled by some parameters accessed through the system administration interface. These settings allow the administrator to set the minimum password length, the number of nonalphabetic characters allowed, and so on. You might even be able to specify these settings per user, as well as per system. One UNIX system that combines all these features in addition to password aging is AIX . By editing the security profile via the smit management tool, the administrator can set any or all of the following for all users or individually for each user ( IBM 's recommended settings are given for each):
This list is the most comprehensive group of "settable" password constraints that we have seen. If you are using traditional passwords, having (and properly using!) options such as these can significantly improve the security of your passwords. 8.8.3 Cracking Your Own PasswordsA less drastic approach than preventing users from picking their own passwords is to run a program periodically to scan the /etc/passwd file for users with passwords that are easy to guess. Such programs, called password cracke rs, are (unfortunately?) identical to the programs that bad guys use to break into systems. The best of these crackers is a program called Crack. (We tell you in Appendix E , where to get it.) If you don't (or can't) use shadow password files, you definitely want to get and use the Crack program on your password file...because one of your users or an attacker will most certainly do so.
8.8.3.1 Joetest: a simple password crackerTo understand how a password-cracking program works, consider this program, which simply scans for accounts that have the same password as their username. From Chapter 3 , remember that such accounts are known as "Joes." The program must be run as root if you have shadow password files installed on your system: Example 8.1: Single Password Cracker/* * joetest.c: * * Scan for "joe" accounts -- accounts with the same username *and password. */ #include <stdio.h> #include <pwd.h> int main(int argc,char **argv) { struct passwd *pw; while(pw=getpwent() ){ char *crypt(); char *result; result = crypt(pw->pw_name,pw->pw_passwd); if(!strcmp(result,pw->pw_passwd)){ printf("%s is a joe\n",pw->pw_name); } } exit(0); } To show you the advantages of the Perl programming language, we have rewritten this program: #!/usr/local/bin/perl # # joetest # while (($name,$passwd) = getpwent) { print "$name is a joe\n" if (crypt($name,$passwd) eq $passwd); } To further demonstrate the power of Perl, consider the following script, which only runs under Perl5: #!/usr/local/bin/perl # # super joetest # while (($name,$passwd) = getpwent) { print "$name has no password\n" if !$passwd; print "$name is a joe\n" if (crypt($name,$passwd) eq $passwd); print "$name is a JOE\n" if (crypt(uc($name), $passwd) eq $passwd); print "$name is a Joe\n" if (crypt(ucfirst($name), $passwd) eq $passwd); print "$name is a eoj\n" if (crypt(scalar reverse $name, $passwd) eq $passwd); } If you have the time, type in the above program and run it. You might be surprised to find a Joe or two on your system. Or simply get Crack, which will scan for these possibilities, and a whole lot more. 8.8.3.2 The dilemma of password crackersBecause password crackers are used both by legitimate system administrators and computer criminals, they present an interesting problem: if you run the program, a criminal might find its results and use them to break into your system! And, if the program you're running is particularly efficient, it may be stolen and used against you. Furthermore, the program you're using could always have more bugs or have been modified so that it doesn't report some bad passwords that may be present: instead, such passwords might be silently sent by electronic mail to an anonymous repository in Finland. Instead of running a password cracker, you should prevent users from picking bad passwords in the first place. Nevertheless, this goal is not always reachable. For this reason, many system administrators run password crackers on a regular basis. If you run a program like Crack and find a bad password, you should disable the account immediately, because an attacker could also find it.
8.8.4 Password GeneratorsUnder many newer versions of UNIX , you can prevent users from choosing their own passwords altogether. Instead, the passwd program runs a password generator that produces pronounceable passwords. To force users to use the password generator under some versions of System V UNIX , you select the "AccountsDefaultsPasswords" menu from within the sysadmsh administrative program. Most users don't like passwords that are generated by password generators: despite claims of the program's authors, the passwords really aren't that easy to remember. Besides, most users would much rather pick a password that is personally significant to them. Unfortunately, these passwords are also the ones that are easiest to guess. Two more problems with generated passwords are that users frequently write them down to remember them, and that the password generator programs themselves can be maliciously modified to generate "known" passwords. There are several freely available password generators that you can download and install on your system. The mkpasswd program by Don Libes is one such program, and it can be found in most of the online archives mentioned in Appendix E . Instead of using password generators, you may want to install password "advisors" - programs that examine user choices for passwords and inform the users if the passwords are weak. There are commercial programs that do this procedure, such as password coach by Baseline Software, and various freeware and shareware filters such as passwd+. In general, these products may do comparisons against dictionaries and heuristics to determine if the candidate password is weak. However, note that these products suffer from the same set of drawbacks as password crackers - they can be modified to secretly record the passwords, and their knowledge base may be smaller than that used by potential adversaries. If you use an "advisor," don't be complacent! 8.8.5 Shadow Password FilesWhen the UNIX password system was devised, the simple security provided by the salt was enough. Computers were slow (by present standards), and hard disks were small. At the rate of one password encryption per second, the system would have taken three years and three months to encrypt the entire 25,000-word UNIX spelling dictionary with every one of the 4096 different salts. Simply holding the database would require more than 10 gigabytes of storage - well beyond the capacity of typical UNIX platforms. The advantage to a computer criminal of such a database, however, would be immense. Such a database would reduce the time to do an exhaustive key search for a password from seven hours to a few seconds. Finding accounts on a computer that had weak passwords would suddenly become a simple matter. Today, many of the original assumptions about the difficulty of encrypting passwords have broken down. For starters, the time necessary to calculate an encrypted password has shrunk dramatically. Modern workstations can perform up to several thousand password encryptions per second. Versions of crypt developed for supercomputers can encrypt tens of thousands of passwords in the same amount of time. Now you can even store a database of every word in the UNIX spelling dictionary encrypted with every possible salt on a single 10 gigabyte hard disk drive, or on a few high-density CD-ROM s. Because of these developments, placing even encrypted passwords in the world-readable /etc/passwd file is no longer secure.[16] There is still no danger that an attacker can decrypt the passwords actually stored - the danger is simply that an attacker could copy your password file and then systematically search it for weak passwords. As a result, numerous vendors have introduced shadow password files. [17] UNIX systems that offer at least so-called C2-level security features have shadow password files, or the capability to install them.
Shadow password files hold the same encrypted passwords as the regular UNIX password file: they simply prevent users from reading each other's encrypted passwords. Shadow files are protected so that they cannot be read by regular users; they can be read, however, by the setuid programs that legitimately need access. (For instance, SVR4 uses the file /etc/shadow, with protected mode 400, and owned by root; SunOS uses the file /etc/security/passwd.adjunct , where /etc/security is mode 700.) The regular /etc/passwd file has special placeholders in the password field instead of the regular encrypted values. Some systems substitute a special flag value, while others have random character strings that look like regular encrypted passwords: would-be crackers can then burn a lot of CPU cycles trying dictionary attacks on random strings. If your system does not have shadow passwords, then you should take extra precautions to ensure that the /etc/passwd file cannot be read anonymously, either over the network or with the UUCP system. (How to do this is described in Chapter 15, UUCP , and Chapter 17 .) If you use shadow password files, you should be sure that there are no backup copies of the shadow password file that are publicly readable elsewhere on your system. Copies of passwd are sometimes left (often in /tmp or /usr/tmp ) as editor backup files and by programs that install new system software. A good way to avoid leaving copies of your password files on your system is to avoid editing them with a text editor, or to exercise special care when doing so. 8.8.6 Password Aging and ExpirationSome UNIX systems allow the system administrator to set a "lifetime" for passwords.[18] With these systems, users whose passwords are older than the time allowed are forced to change their passwords the next time they log in. If a user's password is exceptionally old, the system may prevent the user from logging in altogether.
Password aging can improve security. Even if a password is learned by an attacker and the account is surreptitiously used, that password will eventually be changed. Password aging can also help you discover when people have access to passwords and accounts that aren't properly registered. In one case we know about, when a computer center started password aging, four users suddenly discovered that they were all using the same account - without each other's knowledge! The account's password had simply not been changed for years, and the users had all been working in different subdirectories. Users sometimes defeat password aging systems by changing an expired password to a new password and then back to the old password. A few password aging systems check for this type of abuse by keeping track of old and invalid passwords. Others prevent it by setting a minimum lifetime on the new password. Thus, if the password is changed, the user is forced to use it for at least a week or two before it can be changed again - presumably back to the old standby.[19] If you use password aging, you should explain to your users why it is important for them to avoid reusing old passwords.
Under SVR4 , you can set password aging using the -n (minimum days before the password can be change) and -x (maximum number of days) options (e.g., passwd -n 7 -x 42 sally ). Setting the aging value to -1 disables aging.
Password aging should not be taken to extremes. Forcing users to change their passwords more often than once every few months is probably not helpful. If users change their passwords so often that they find it difficult to remember what their current passwords are, they'll probably write these passwords down. Imagine a system that requires users to change their passwords every day. Expiration times that are too short may make the security worse, rather than better. Furthermore, it engenders discontent - feelings that the security mechanisms are annoying rather than reasonable. You may have good passwords, but having users who are constantly angry about the security measures in place probably negates any benefits gained. On the other hand, if you want your users to change their passwords every minute, or every time that they log in, then you probably want to be using a one-time password system, such as those described in Section 8.7.1, "Integrating One-time Passwords with UNIX earlier in this chapter. 8.8.7 Algorithm and Library ChangesIf you have the source code to your system, you can alter the crypt() library function to dramatically improve the resistance of your computer to password cracking. Here are some techniques you might employ:
If you decide to implement this approach, there are some issues to be aware of:
Do these techniques work? Absolutely. A few years ago, there was a computer at MIT on which guest accounts were routinely given away to members of the local community. Every now and then, somebody would use one of those guest accounts to grab a copy of the password file, crack it, and then trash other people's files. (This system didn't have shadow passwords either.) The day after the above modifications were installed in the system's crypt() library, the break-ins stopped and the system's administrators were able to figure out who was the source of the mischief. Eventually, though, the system administrators gave up on modifications and went back to the standard crypt() function. That's because changing your crypt() has some serious drawbacks:
8.8.8 Disabling an Account by Changing Its PasswordIf a user is going away for a few weeks or longer, you may wish to prevent direct logins to that user's account so the account won't be used by someone else. As mentioned earlier, one easy way to prevent logins is to insert an asterisk (*) before the first character of the user's password in the /etc/passwd file or shadow password file.[22] The asterisk will prevent the user from logging in, because the user's password will no longer encrypt to match the password stored in /etc/passwd , and the user won't know what's wrong. To re-enable the account with the same password, simply remove the asterisk.
For example, here is the /etc/passwd entry for a regular account: omega:eH5/.mj7NB3dx:315:1966:Omega Agemo:/u/omega:/bin/csh Here is the same account, with direct logins prevented: omega:*eH5/.mj7NB3dx:315:1966:Omega Agemo:/u/omega:/bin/csh Under SVR4 , you can accomplish the same thing by using the -l option to the passwd command, (e.g., passwd -l omega). You should be sure to check for at and cron jobs that are run by the user whose account you are disabling. Note that the superuser can still su to the account. The section Section 8.5, "Protecting the root Account explains the details of protecting accounts in a variety of other ways. Briefly, we'd also suggest that you set the login shell equal to /bin/false , or to some program that logs attempts to use it. You should also consider changing the permissions on the user's home directory to mode 000 and changing the ownership to user root . As the administrator, you may also want to set expiration and inactivity time-outs on accounts. This step means that accounts cease to be valid after a certain date unless renewed, or they cease to be usable unless a valid login occurs every so often. This last case is especially important in environments where you have a dynamic user population (as in a university) and it is difficult to monitor all of the accounts. We discussed this in greater detail earlier in this chapter. 8.8.9 Account Names Revisited: Using Aliases for Increased SecurityAs we described earlier in this chapter, you can give accounts almost any name you want. The choice of account names will usually be guided by a mixture of administrative convenience and user preference. You might prefer to call the accounts something mnemonic, so that users will be able to remember other usernames for electronic mail and other communications. This method is especially useful if you give your users access to Usenet and they intend to post news. A properly chosen username, such as paula , is more likely remembered by correspondents than is AC00045 . At the same time, you can achieve slightly better security by having nonobvious usernames. This method is a form of security through obscurity. If an attacker does not know a valid username at your site, she will have greater difficulty breaking in. If your users' account names are not known outside your site and are nonobvious, potential intruders have to guess the account names as well as the password. This strategy adds some additional complexity to the task of breaking in, especially if some of your users have weak passwords. If you use obscure account names, you need a way to protect those account names from outsiders while still allowing your users to access electronic mail and participate in Usenet discussions. The way to do this is with aliasing. If you configure one machine to be your central mail and news site, you can set your software to change all outgoing mail and news to contain an alias instead of the real account name. This is probably what you wish to do if you decide to install a firewall between your site and the outside network (see Chapter 21, Firewalls ). For example, your mailer could rewrite the From: line of outgoing messages to change a line that looks like this: From: paula@home.acs.com to look like this: From: Paula.Harris@ACS.COM This address is also the electronic mail address Paula would put on her business cards and correspondence. Incoming mail to those addresses would go through some form of alias resolution and be delivered to her account. You would also make similar configuration changes to the Usenet software. There is an additional advantage to aliasing - if an outsider knows the names of his correspondents but not their account names (or machine names), he can still get mail to them. If you take this approach, other network services, such as finger and who, must similarly be modified or disabled.[23]
Many large organizations use some form of aliasing. For example, mail to people at AT&T Bell Laboratories that's addressed to First.Last@att.com will usually be delivered to the right person. | ||||||||
|