encrypted password storage

41
November 1 st , 2007 Internet Vision Technologies Melbourne, Victoria, AU Jonathan Oxer <[email protected]> Secure Password Storage in SiteBuilder

Upload: jonathan-oxer

Post on 02-Nov-2014

1.750 views

Category:

Technology


2 download

Tags:

DESCRIPTION

IVT Tech Talk by Jonathan Oxer in November 2007. Covers use of hashed passwords in web applications and outlines a method to progressively migrate from plain-text to hashed storage. More information at http://jon.oxer.com.au/talks/id/90

TRANSCRIPT

Page 1: Encrypted password storage

November 1st, 2007Internet Vision Technologies

Melbourne, Victoria, AU

Jonathan Oxer <[email protected]>

Secure PasswordStorage in SiteBuilder

Page 2: Encrypted password storage

November 1st, 2007Internet Vision Technologies

Melbourne, Victoria, AU

Jonathan Oxer <[email protected]>

18cf7f57ff36142a473acdce6e602b03

Page 3: Encrypted password storage

“We want to make you aware thatmedia of ours that contained a

backup of a portion of the redditdatabase was stolen recently.

We wanted to alert you to thepossibility that your username,password, and – in some cases– e-mail address may have been

compromised.”

Steve Huffman, reddit.com

Page 4: Encrypted password storage

Lesson for site owners:

Don't storepasswords in

plain text

Page 5: Encrypted password storage

Do we really needto know user's

passwords?

Page 6: Encrypted password storage

No, we need toknow if they

know it!

Page 7: Encrypted password storage

This is your password:

hammer

Page 8: Encrypted password storage

This is your password on hash:

d58a27b9f79eb702e1e514b0cdb4e254

Page 9: Encrypted password storage

A “hashingalgorithm” is

a one-waycalculation

Page 10: Encrypted password storage
Page 11: Encrypted password storage

Store the hashedvalue, not the

plaintext

Page 12: Encrypted password storage

On login: hashthe supplied

value andcompare hashes

Page 13: Encrypted password storage

User-submitted value:“hammer”

Page 14: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Page 15: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“d58a27b9f7..”

Page 16: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“d58a27b9f7..”

Pre-stored hash value:“d58a27b9f7..”

Querydatabase

Page 17: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“d58a27b9f7..”

Pre-stored hash value:“d58a27b9f7..”

Compare

Querydatabase

Page 18: Encrypted password storage

Dictionary attack:pre-compute hashvalues for every

possible password

Page 19: Encrypted password storage

echo “hammer” | md5sumalways equals

d58a27b9f79eb702e1e514b0cdb4e254

Page 20: Encrypted password storage

So the input value for

d58a27b9f79eb702e1e514b0cdb4e254

must have been 'hammer'

Page 21: Encrypted password storage

Dictionary attackspre-compute a

hash table for everypossible input value

Page 22: Encrypted password storage

Solution: “salt”the plaintext

with a randomvalue first

Page 23: Encrypted password storage

Store the saltvalue for later usewhen validating

users

Page 24: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“d58a27b9f7..”

Pre-stored hash value:“d58a27b9f7..”

Compare

Querydatabase

Page 25: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Page 26: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Querydatabase

Pre-stored salt value:“nceoter8oa”

Page 27: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“4aeb7d7b...”

Querydatabase

Pre-stored salt value:“nceoter8oa”

Page 28: Encrypted password storage

User-submitted value:“hammer”

Hashfunction

Calculated hash value:“4aeb7d7b...”

Pre-stored hash value:“4aeb7d7b...”

Compare

Querydatabase

Pre-stored salt value:“nceoter8oa”

Page 29: Encrypted password storage

An attacker thenhas to re-compute

their dictionaryfor every attack

Page 30: Encrypted password storage

SiteBuilder usestwo fields:

`Password` and`PasswordSalt`

Page 31: Encrypted password storage

On a login requestSB checks for a stored salt value

Page 32: Encrypted password storage

If salt found thesupplied value

is hashedand comparedwith password

Page 33: Encrypted password storage

If salt not foundplaintext value is

compared directlywith stored

password value

Page 34: Encrypted password storage

Then a salt isgenerated, thepassword is

hashed and bothvalues stored

Page 35: Encrypted password storage

Then a salt isgenerated, thepassword is

hashed and bothvalues stored

Page 36: Encrypted password storage

Next time the saltwill exist so pw

will be treated asa hashed value

Page 37: Encrypted password storage

Progressiveencryption of

existingpasswords

Page 38: Encrypted password storage

Nice side effect:update passwordby simply writing

plaintext anddeleting salt

Page 39: Encrypted password storage

UPDATE contactsSET `Password` = 'hammer',

`PasswordSalt` = ''WHERE UserId = 123;

Page 40: Encrypted password storage

On next login itwill be hashedautomatically

Page 41: Encrypted password storage

Thankyou :-)Questions? Comments? Insults?

Slides: jon.oxer.com.au/talksInsults: >/dev/nullQuestions: Jonathan Oxer [email protected]