Passwords are the foundation of Unix security. All the other security measures are for naught if you have weak passwords (meaning that they're easy to guess or obtain) or if someone is able to obtain a user 's password, no matter how good it is.
As we discussed in Chapter 11, a good password is one that is both easy to remember (so it doesn't get written on a note taped to the user's screen) and hard to guess. The latter means that the password should not be susceptible to a dictionary attack (described below).
Unauthorized people obtain passwords in three ways. Think about whether you're vulnerable to any of these:
User error This includes writing the password on a note stuck to your screen, or sending a password via e-mail or leaving it in voice mail.
Dictionary attacks Done by a software program that tries millions of guesses to figure out a password. These attacks start by obtaining the encrypted version of a password and comparing it with every possible encrypted version of a huge list of words and possible passwords (the dictionary ). If they match, then the attacker knows what the password is.
Packet-sniffing attacks These occur when a monitoring device is illicitly used to examine all the data flowing on a network. User names and passwords can be "sniffed" out of the data stream with ease, so any unencrypted traffic is completely vulnerable. These attacks are described in more detail below in "Protecting Yourself from Internet Attacks."
The first two vulnerabilities (user error and dictionary attacks) are fairly easy to reduce or eliminate, so we'll tackle those first. The third vulnerability, packet-sniffing attacks, comes from the vulnerability of unencrypted data traveling over a network. Reducing this vulnerability is more complex.
You need to communicate to your users the potential consequences of their passwords' being obtained by an attacker: The system can be rendered unusable, data can be lost or altered , private information can be made public, and the system can be used as a staging area for further attacks.
Passwords are liable to be compromised when users do foolish things like writing them on notes left under their keyboard, letting someone watch them enter their password, or sending a password via e-mail. E-mail messages are like postcardsthey can be read at several places along their journey, and there is no way of knowing if the intended recipient is actually the person who reads the e-mail. It is a very bad idea to send unencrypted passwords via e-mail. Ultimately, you prevent the compromise of passwords through user error by educating your users.
Because computers are so fast these days, a dictionary attack using a very large dictionary of possible passwords can be completed in a matter of hours or days. This method includes adding numbers to the beginning and end of every word, so a dictionary attack can guess a password of sunny23 or 7times7.
A dictionary attack can work only if the encryption method used always produces the same encrypted text from the same input (such systems are said to be deterministic ), and if the attacker's dictionary includes the plain-text password. Sadly, the standard encryption method used to store passwords on Unix systems does indeed produce the same output whenever it is given the same input. (The encryption method used, known as crypt , is an advanced version of the World War IIera Enigma encryption system used by the German military and cracked by the Poles and later the British.)
Many modern Unix systems add a layer of defense against dictionary attacks by making the encrypted passwords available only to the root account. On Mac OS X prior to version 10.3, anyone could use the nidump command to reveal all of the encrypted passwords. Even in version 10.3, user accounts created in prior versions of Mac OS X were vulnerable to this.
It would be best if computer systems did not use authentication methods that are vulnerable to dictionary and packet-sniffing attacks (see the sidebar "S/Key and Kerberos: Better Authentication Systems" for two examples), but the crypt system of password encryption is so widely used in the Unix world that this will not happen soon (enough).
So, the best available defense against dictionary attacks is to use passwords that are not in anyone's dictionary. This means passwords that contain a combination of letters , numbers, and punctuation, and that do not contain a dictionary word.
S/Key and Kerberos: Better Authentication Systems
There are alternatives to the standard Unix password system, which uses passwords that are vulnerable to dictionary and packet-sniffing attacks.
These alternatives have been around for many years but are still far from being universally adopted:
S/Key Secure Key is a onetime password (OTP) systemthat is, a system that generates and uses passwords that are valid only once. S/Key is a registered trademark of Bell Communications Research (where it was developed), so the acronym OTP is often used instead.
When a user attempts to log in to an OTP-protected system, she gets a "challenge" (some numbers) from the server, which she enters into an OTP response generator on her end, along with her password. The response generator then creates a onetime password, which the user enters into the protected system to obtain access.
An OTP response generator for Mac OS X is SkeyCalc (www.orange-carb.org/SkeyCalc).
Kerberos Developed at the Massachusetts Institute of Technology, Kerberos (http://web.mit.edu/kerberos/www) is an even more secure system. (Kerberos is the Greek name for the three-headed dog that guarded the entrance to Hades; the dog is also known by its Latin name, Cerberus.) Kerberos exchanges encrypted information between the client and server, and the server issues a temporary "ticket" to the client. Kerberos is designed to be invulnerable to packet sniffing and to situations in which an attacker is able to commandeer a machine between the user and the service he is trying to authenticate into (a "man in the middle" attack). We believe that Apple is considering adding increased support for Kerberos to future versions of Mac OS X.
To choose a good password:
Pick a song lyric , poem, or phrase from your favorite storyfor example, "Can any human being ever reach that kind of light?" (from "Galileo," by Emily Saliers of the Indigo Girls).
Take the first letter of each word in the phrase; so here we have
Change some of the letters to numbers.
The changes should be ones that make sense to you. Perhaps the C becomes 100 because C is the Roman numeral for 100:
Change the result to include some punctuation.
Perhaps the k becomes % because it sort of looks like a % , and perhaps you add a ? at the end because the phrase itself is a question. So you have
Make sure the remaining characters include both upper- and lowercase letters.
Maybe you make the h and b uppercase because you like human beings:
You've got a great password.
The result is very unlikely to be in anyone's dictionary of passwords and should be easy for you to remember because it is based on something that has personal meaning for you.
Many Unix password systems pay attention only to the first eight characters of the password, but there is no harm in using a longer one if it helps you remember. Mac OS X pays attention to the first 32 characters, so you can have a nice long password, like
M@y your 23000 feet always be SWIFT!
Connecting to the Internet with a Private IP Address
Private TCP/IP network addresses are those that begin with 10., 172.16., or 192.168. (for example, the following are all private addresses: 10.1.1.23, 172.16.20.35, 192.168.1.254).
If your machine has a private address, it can still use the public Internet via a process called Network Address Translation ( NAT ).
Private networks often have a NAT server that allows the machines on the local, private network to connect to the Internet.
A NAT server translates the return addresses of all outgoing data so that to the rest of the world, the data is coming from a nonprivate IP address. When responses come back in to the NAT server from the outside world, it again translates and forwards the data to the appropriate machine on the private network.
One effect of using NAT is that machines on the public Internet cannot initiate connections to machines behind the NAT server. The NAT server will pass data to the local, private machines only if it comes in response to a connection started from the local network.
You can read more about private addresses at www.ietf.org/rfc/rfc1918.txt and about NAT at www.ietf.org/rfc/rfc1631.txt and www.ietf.org/rfc/rfc2766.txt.