Sony FAIL : why it is absolutely necessary to encrypt passwords
Tags: cryptography, hashing, itsecuritypassword, nerdspeak
Published: 2021-10-16 02:11:31

---
title: Sony FAIL : why it is absolutely necessary to encrypt passwords
published: true
date: 2011-05-01 01:44:00 UTC
tags: cryptography,hashing,ITSecuritypassword,nerdSpeak
canonical_url: https://waiholiu.blogspot.com/2011/04/sony-fail-why-it-is-absolutely.html
---

As you may have read in the [news](http://www.telegraph.co.uk/technology/sony/8478404/PlayStation-hack-Sony-users-urged-to-change-passwords.html) lately, Sony is in a lot of hot water after it's network was [hacked](http://en.wikipedia.org/wiki/PlayStation_Network_outage).  
  
So far, Sony has admitted that personal account details of 77 million users were stolen. This would make it the greatest data theft in history.  
  
Sony is still investigating whether credit card information were stolen but apparently, user records containing information such as name, date of birth, email and passwords were.  
  
Whilst PS3 users seem [concerned](http://www.pcmag.com/article2/0,2817,2384702,00.asp) about their network being down for a week - the thing I was more fixated on was how the passwords could possibly be stolen. Well, apparently, Sony never bothered to encrypt them!  
  
Now, I'm by no means a IT security expert here but I've worked on enough IT systems and projects to understand that ** **  
  
**YOU NEVER STORE USER PASSWORDS IN PLAINTEXT!**  
  
Never, ever, ever!  
It doesn't matter how small or insignificant your site is. In fact, it always used to bug me whenever I registered a user account from a new site or forgotten my password, and I received an email with my password in it.  
  
I would be quick to either deregister myself or at the very least, change the password and hope that my normal password wasn't sitting  in some audit table somewhere.  
  
<u>Because the fact they could retrieve my password meant that they had it.</u>  
  
And it happens more than you think - not just on small sites, I've been surprised by a few relatively big players. I remember [Prometric ](http://prometric.com/) (they also have a really crap website) - the company that manages Microsoft certification exams emailed me my password. This is a company that makes its living testing and certificating IT professionals!  
  
Frankly, I think somebody should set up a Name and Shame list of any websites that store passwords in plain text.  
  
  
But for a company like Sony - a huge multinational, a company worth billions of dollars, a company that made the PS3 which for a long while, was considered the first unhackable console (until it [was](http://www.theregister.co.uk/2010/01/25/playstation_cracked_wide_open/)) , it's just utterly unbelievable that they did not follow such basic and rudimentary security measures.  
  
The reason you don't store passwords in the database is that most users, lacking an eidetic memory tend to re-use the same passwords over and over again. If they have their password stolen from your site, its likely the hackers will have access to other accounts they own.   
  
The other reason is that all staff members with production db access can see it. It takes one disgruntled employee.  
  
You should never store passwords in plain text cause you don't want the liability.  
  
**INSTEAD, STORE A HASH VALUE GENERATED BY THE PASSWORD.**  
  
  
[Hashing](http://en.wikipedia.org/wiki/Cryptographic_hash_function)is the process of running some plaintext (password) into an algorithm (eg. [MD5](http://en.wikipedia.org/wiki/MD5)) which returns a "hash" - basically an encrypted string value. It's a one way street - you can convert the plaintext to a hash, but you cannot use a hash to retrieve the original text. You compare the hash to verify when someone tries to log on.  
  
The fact is, implementing hashing is not even that hard. There's really no mathematical or cryptographic knowledge required. All major programming frameworks have class libraries of the hashing functions pre-installed. All you have to do is call the function.  
  
That's the absolute minimum you would expect of any website.  
  
Although these days, simply hashing is probably not enough as it will not protect you from [Rainbow attacks](http://en.wikipedia.org/wiki/Rainbow_attack). Now rainbow attacks sound cute and kind of a bit queer, but essentially, a rainbow attack uses a rainbow table - which is a prepopulated table containing hash codes for every possible password combination - to quickly look up your password.  
  
With the super fast processors and distributed computing options we have today, you would be surprised how entirely possible it is to get the hash for every combination of letters and numbers that a password could have. There are several freely [available](http://ophcrack.sourceforge.net/tables.php) on the net. This [page](http://www.lockdown.co.uk/?pg=combi) nicely illustrates how much time it would take based on the complexity and length of the password.  
  
IN ORDER TO COMBAT RAINBOW ATTACKS, YOU MUST ADD [SALT](http://en.wikipedia.org/wiki/Salt_%28cryptography%29).  
  
In layman's terms, this is the process of messing with the plaintext a bit before you hash it to order to ensure it is unique and will not appear in any pre-populated rainbow table.   
  
To illustrate, a hash without salt looks like this  
  
**cipher = hash(plaintext)**  
  
After salt, it should look like this  
  
  
**cipher = salt + hash(salt + plaintext)**  
  
The salt is typically a [GUID](http://en.wikipedia.org/wiki/Guid) as it guarantees uniqueness. You don't need to hide the salt - in fact, the salt is used when verifying if the user has entered the right user name by taking the value of the salt into account when comparing the hash values.  
  
A hacker cannot use a rainbow attack on you because the salt makes the plaintext unique. They will need to re-generate their rainbow tables again using your salt prefixed which will take as much time as a [brute force attack](http://en.wikipedia.org/wiki/Brute_force_attack).   
  
No encryption is unbreakable of course, it's all just a matter of how much time a hacker has to spend before he breaks it so there are additional measures such as adding multiple iterations of hashing to provide additional protection which I may discuss in another post.  
  
The point is, hashing and salting - these are not complicated concepts and they're really not that hard to implement. Somebody really dropped the ball at Sony and as a result, they're probably going to lose millions from a tarnished brand name and potential law suits.