CertCities.com -- The Ultimate Site for Certified IT Professionals
Listen, See, Win! Register for a Free Tech Library Webcast Share share | bookmark | e-mail
  Microsoft®
  Cisco®
  Security
  Oracle®
  A+/Network+"
  Linux/Unix
  More Certs
  Newsletters
  Salary Surveys
  Forums
  News
  Exam Reviews
  Tips
  Columns
  Features
  PopQuiz
  RSS Feeds
  Press Releases
  Contributors
  About Us
  Search
 

Advanced Search
  Free Newsletter
  Sign-up for the #1 Weekly IT
Certification News
and Advice.
Subscribe to CertCities.com Free Weekly E-mail Newsletter
CertCities.com

See What's New on
Redmondmag.com!

Cover Story: IE8: Behind the 8 Ball

Tech-Ed: Let's (Third) Party!

A Secure Leap into the Cloud

Windows Mobile's New Moves

SQL Speed Secrets


CertCities.com
Let us know what you
think! E-mail us at:



 
 
...Home ... Editorial ... Columns ..Column Story Saturday: April 5, 2014


 Inside the Kernel  
Emmett Dulaney
Emmett Dulaney


 Secrets the Shadow Knows
The /etc/shadow file, which stores users' authentification information, is a holy grail for hackers and a massive security liability for administrators.
by Emmett Dulaney  
8/31/2009 -- In a perfect world, there wouldn't be such a file as /etc/shadow; it carries too much of a security risk if it falls into the wrong hands. In the real world, however, authentication information needs to be stored somewhere -- and that responsibility falls to this file.

The danger? This file contains an encrypted version of the passwords for users who are defined in the /etc/passwd file.

In early versions of Unix/Linux, all the user account and password information was stored directly in passwd, but only root could write to it. This offered sufficient security because the password was encrypted in this file as a hash value that was then compared against the new hash created when a user typed in their password at a prompt. The problem was that the permissions allowed more than root to read the file, and everyone became root during the time needed to change their password.

To make things more secure, the hashed password values were moved from the second field of passwd to shadow, and the permissions for each file reflected additional security measures:

File

Owner

Permission

/etc/passwd

root

644

/etc/shadow

root

400 or 600, depending on distribution

When shadow is in use, only an "x" appears in the second field of passwd now (when shadow is not in use, the encrypted password hash appears in that field). While the values are now more protected, if the file were to fall into the wrong hands -- via a misplaced backup, privilege escalation, etc. -- it becomes possible for someone to wreak havoc.

Like passwd, the shadow file is colon (:) delemited, and there are nine fields. Here's an example:

edulaney:$1$AAAni/yN$uESHbzUpy9Cgfoo1Bf0tS0:13800:0:99999:7:::

The value of the fields are as follows:

  1. The username. This corresponds to the first field in the passwd file and is the only field where the two files match.

  2. A hashed copy of the password. An asterisk (*) or exclamation mark (!) denotes an account with no password and is common for accounts used by the system itself. Within this field, there is the possiblity for the first three characters to be a dollar sign ($), a number and another dollar sign. For example:
    $1$AAAni/yN$uESHbzUpy9Cgfoo1Bf0tS0
    The "1" between the dollar signs in the second field indicates that MD5 encryption has been used here. A pluggable authentication module (PAM) is needed to perform the actual MD5 encryption. If the number between the dollar signs is 2, then Blowfish was used.

  3. The date of the last password change. This is depicted as the number of days since Jan. 1, 1970.

  4. The number of days that must pass before the next password change is allowed. A 0 here means the user can change their password when they want to.

  5. The number of days after the last password change before another password change is required.

  6. The number of days before the password expiration to start giving a warning to the user. The most typical value is 7.

  7. The number of days that are allowed between expiration and deactivation.

  8. The expiration date, again expressed as a number of days since Jan. 1, 1970.

  9. A "special" flag that is reserved for future use.
Fun with Entries
For the values related to the expiration of the password (which most of these are), the easiest way to change their value is with the chage utility. The following are two examples:

First, you can check a user's password-expiration information with the command:

chage -l edulaney

This command displays expiration information, including when the last password change was, when it expires, when it goes inactive and how often the password must be changed. In the entry shown, "never" would be returned for when the password expires, when the password goes inactive, and when the account expires. The -l option is the only one that can be run with chage by all users and not just the root user (so every user can see when their account expires).

To force the user to change a password in 90 days, use the following command:

chage -M 90 edulaney

This will change the fifth field in the example from 99999 to 90.

How the File Can Be Misused
Since the file contains a copy of what value can be hashed from the correct password, having access to this file gives someone the ability to look for values that match. The first thing they would look for is the number between the dollar signs to see if MD5 or Blowfish (or neither) was used. Armed with that knowledge, they could look at the fifth field of the passwd file and begin encrypting items there (things like the user's first name, department and so on) as they look for matches.

There are programs, such as John the Ripper, which exist to simplify the cracking of this field. Given the values in a shadow file, it will begin guessing entries and encrypting them to find a match. It's amazing how quickly values can be found just by using entries in a common word file (like a dictionary).

As with most security-related issues, the best defense is a good offense. Keep all copies of the shadow file -- whether they're on backup tape or other media -- secure and out of the hands of all but those who absolutely must have access to it.


Emmett Dulaney is the author of several books on Linux, Unix and certification. He can be reached at .

 


More articles by Emmett Dulaney:

-- advertisement --


There are 29 CertCities.com user Comments for “Secrets the Shadow Knows”
Page 1 of 3
7/1/13: louis vuitton outlet from [email protected] says: ths louis vuitton outlet http://www.louisvuittonttoutlet.com
7/5/13: christian louboutin outlet from [email protected] says: good share. christian louboutin outlet http://www.christianlouboutinoutleta.com
7/25/13: Snapback Hats Online from [email protected] says: good articles Snapback Hats Online http://www.discount-snapbackhats.com/
8/30/13: nfl china from [email protected] says: thanks for share! nfl china http://www.cheapnflljerseysfromchina.com
9/5/13: cheap authentic nfl jerseys from [email protected] says: thanks for share! cheap authentic nfl jerseys http://www.cheapauthenticnfljerseyss.com
9/5/13: moncler jacket outlet from [email protected] says: thank you for share! moncler jacket outlet http://www.monclereoutletjackets.com
9/12/13: outlet moncler jackets from [email protected] says: thanks for share! outlet moncler jackets http://www.monclereoutletjackets.com
10/1/13: grey uggs from [email protected] says: nice articles grey uggs http://cheapbaileybuttonoutlet.com
10/4/13: ugg boots on sale from [email protected] says: nice articles ugg boots on sale http://bootsforcheapsale.org
12/16/13: nike air max pas cher from [email protected] says: * Aggressive styling
First Page   Next Page   Last Page
Your comment about: “Secrets the Shadow Knows”
Name: (optional)
Location: (optional)
E-mail Address: (optional)
Comment:
   

-- advertisement (story continued below) --

top