views:

131

answers:

6

I have a list of students that are being added via a form inside the admin area. I'm trying to come up with a password generating solution for each addition that will be both secure and viewable from the admin panel (like below).

alt text

I need it to be viewable so that the admin will be able to print out the passwords and hand them out to the parents. But I also want them to be secure in case there's a database breach. Any ideas?

+3  A: 

If you want the passwords to be viewable, they can never be really secure in case of a breach.

You may be interested in checking out the following Stack Overflow posts for further reading:

Daniel Vassallo
+1  A: 

Store passwords in 2 forms:

1) MF5/SHA1 hash for secure validation

2) AES encripted with master password. I.e. in order to view passwords you enter master password and bingo. In case of theft attacker would not get passwords that easy (but can bruteforce).

BarsMonster
I definitely wouldn't recommend to use MD5 for hashing purposes; almost the same counts for SHA-1. Go with *bcrypt* in this case, which has a long setup time; speed is what you don't want in a password hash function, and *bcrypt* is definitely a good choice in this case.
Giu
bcrypt? Blowfish file encryption??? Why? SHA1 is cryptographically SECURE. If one want to make it slower, just do it 10'000 times in a loop. Same counts to MD5. No real weakness found yet.
BarsMonster
@BarsMonster: Actually, I'd think Eksblowfish is meant here. The unfortunately chosen name is a source of much confusion: http://chargen.matasano.com/chargen/2007/9/7/enough-with-the-rainbow-tables-what-you-need-to-know-about-s.html
Piskvor
@BarsMonster I didn't say that MD5 with key stretching is a bad thing (PHK's MD5 scheme works like that, and it's *still* used in FreeBSD 8). I only said that using the *raw* MD5 is a bad thing; by reading your answer I'm assuming that you mean the latter. That both MD5 and SHA-1 are broken is well known, but by using key strengthening both can be used with some *caution*; just don't forget to use a big enough number of rounds (PHK's MD5 scheme uses 1000 rounds, [but it's not slow enough anymore](http://www.mail-archive.com/[email protected]/msg02771.html) ).
Giu
@Piskvor that's right; Provos and Meziers developed a new key setup algorithm for Blowfish
Giu
A: 

You can have one XOR the other.

  • If the passwords are to be secure, you mustn't store them in the database (store some_hash(per_user_salt + password) and compare that on login (as @Daniel Vassallo says)

  • If the passwords are to be viewable, then you must provide some way to get to the passwords - and if there is one, it can be abused (e.g. passwords stolen). If you decide that you absolutely, positively need to do this, encrypt the passwords in your application before storing them to the database. This won't shield you from all threats, but at least the passwords won't be readable if someone "only" steals your database.

Piskvor
Maybe check this decision with the client's lawyers. Real Story™: a company I worked for had admin-viewable passwords; one of the normal users went rogue, then built the defense on "wasn't me, any admin can see my password and impersonate me." Can't tell you more than that, but the moral should be obvious.
Piskvor
A: 

This is one of the few times I would say the software shouldn't be adjusted to the user(s). You're talking a major security risk here.

I would advice making some kind report generator to print passwords that creates (generates / salts and hashes and saves) them on the fly for printing. With this, you could generate the letters to be send as well. Makes the process mostly automated and a person would only have to send them to the printer (if that's even necessary).

Good luck.

Paul Appeldoorn
...and set a flag so that they have to change the password at first login.
caf
+1  A: 

You should not do this.

Generate a one-time password that can be used (and could also be stored in clear text) to set a new password via web.

As soon as the passwords are printed, they can be easily accessed by others, so it does not matter at all if you store them encrypted or not.

Alex
A: 

Others have had the right idea, but were missing an essential step. You should use asymmetric encryption and store a public-key encrypted form of the password + salt.

To verify a password, take the proffered password, combine it with the salt, use the public key to encrypt the combination, and compare it with the stored value.

To retrieve the password, use the private key (kept secure, i.e. on another isolated machine) to decrypt the password + salt and throw away the salt.

Cons: asymmetric encryption can be expensive, computationally, but passwords tend to be short.

You could combine this with other ideas above (i.e. also store a salted hash), and you should pad the password so that the length of the encrypted text doesn't leak the password length.

Slartibartfast