Part of the EllisLab Network
   
2 of 2
2
Best way to handle passwords using CI library?
Posted: 15 February 2008 09:28 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  271
Joined  03-26-2006

If you consider yourself a hacker and you are writing a zombie script that will try to guess someones password

First of all, this isn’t how a hacker will work.
They will first and foremost discover everything possible about the application, server environment, and use this to discover possible vulnerabilities.

A ‘zombie’ script is always the last resort, as it takes an almost infinitely large amount of time, it’s intensive, and the hacker will get blacklisted by iptables before they’re even close to getting a password.

A sha1 salted hash can only be cracked with brute force…
To crack a sha1 hash with brute force, you may have to try 2 to the power 80 attempts. Way too much for any hacker to attempt.

Whereas, in the event of your encryption key being discovered (due to the ‘clever’ hacker probing your server environment, php version, ci version, and finding a vulnerability), a hacker could use the encryption key to get your passwords with no effort at all.

It’s much much more likely you’ll be hacked after an extensive recon task and research rather than through blind luck or brute force.

 Signature 

On the first day, God created CodeIgniter… Then he could really get some work done!

Elliot Haughin CodeIgniter Blog | FilePanda - Free File Sharing | Web Development Screencasts
Twitter | Flickr

Profile
 
 
Posted: 15 February 2008 09:48 AM   [ Ignore ]   [ # 17 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

What i do using decodable passwords is to add a value to the password and cut it off when i display the password. So they have to find that second value too before decoding.

Profile
 
 
Posted: 15 February 2008 12:29 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  175
Joined  08-11-2006

@Elliot

looking at the hashing algorithm does not grant access.

Let me give you an example.
I use MD5 both on the client (javascript) and on the server


1. My server creates a key at random (i.e. qwer) and both stores it in the server and sends it to the client
2. User enters “mypass” on the browser and hits “Send”
3. javascript sends md5(“mypass”+“qwer”) to the server for validation
4. server recieves a weird hash. retrieves the real password for the user, (decrypts it if encrypted) and then appends “qwer” to the end and calculates its md5.
5. If it matches the weird hash sent then login worked fine.
6. Otherwise, the key is discarded and a new one is sent to the browser i.e. “zdrtfxc”

Now, the idea behind this is that on every request, the password sent will look different on each request even when its always the same. So if someone steals it from he packages being sent, it will be useless because the server will already be waiting for a different hash

 Signature 

Security Code Review

Profile
 
 
Posted: 15 February 2008 01:22 PM   [ Ignore ]   [ # 19 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  271
Joined  03-26-2006

The whole process seems pretty secure… the only vulnerability is that the password stored in the database uses a 2-way encryption method, which is possible to decrypt… remove this vulnerability, and then it’s properly secured.

 Signature 

On the first day, God created CodeIgniter… Then he could really get some work done!

Elliot Haughin CodeIgniter Blog | FilePanda - Free File Sharing | Web Development Screencasts
Twitter | Flickr

Profile
 
 
Posted: 16 February 2008 12:17 AM   [ Ignore ]   [ # 20 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  01-10-2008

Instead of using $config[‘encryption_key’] for the encryption salt, just randomly generate a new salt for each new password. But be sure of also inserting the salt in the database smile

 Signature 

Go PHP5

Profile
 
 
Posted: 16 February 2008 12:32 AM   [ Ignore ]   [ # 21 ]  
Grad Student
Avatar
Rank
Total Posts:  45
Joined  03-29-2007

I am glad I sparked such huge debate, and got great discussion out of this. I learned a lot and will defiantly implement some of the ideas here into my project, when I read the thread more throughly I may have some questions. This should possibly be stickied as it is a very important topic.

 Signature 

Code is poetry.

Profile
 
 
Posted: 16 February 2008 02:33 AM   [ Ignore ]   [ # 22 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006
fdog - 16 February 2008 12:17 AM

Instead of using $config[‘encryption_key’] for the encryption salt, just randomly generate a new salt for each new password. But be sure of also inserting the salt in the database smile

Storing the salt in the database is less safe than putting it into a php file because a clever hacker will see the connection.

I agree with Elliot decodable passwords can be a security risk but if they can see the passwords they can also see the data they are really after. The only thing they can’t crack is the password which isn’t always the main target for a hacker.

If you are paranoid you will encrypt all hacker valuable data but it will reduce performance.

Profile
 
 
Posted: 16 February 2008 03:15 AM   [ Ignore ]   [ # 23 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  773
Joined  09-01-2007

Let me just throw my view in. I have done a cryptography course at degree level. let me just say one thing, if you have a two way encryption algorithm it can be broken very easily. You don’t even need the key, if you know how it works (the algorithm) most can be broken by simple processes.

If someone really wants some data you store they will be able to get it, doesn’t matter how much you encrypt it. The only way you can stop it is to make the process so hard the data isn’t worth it to decrypt it.

I store my passwords using a SHA-1 with salt method. I would advice you all to do the same. DO NOT use two way encryption just so the password can be made into ****‘s. This is crazy, just say to the client NO. Your the expert they should listen to you, and if they still refuse print out a random length string of **‘s or something.

So just to clarify, use SHA-1 with salt, its the best there is at the moment. I know SHA-1 has been broken but unless your a crypto-geek its probably the best and easiest to use.

 Signature 

Kaydoo - A day in the life of a developer
BackendPro Control Panel

Profile
 
 
Posted: 16 February 2008 03:31 AM   [ Ignore ]   [ # 24 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  4839
Joined  07-14-2006

So you are saying encryption is useless?

Profile
 
 
Posted: 16 February 2008 03:37 AM   [ Ignore ]   [ # 25 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  773
Joined  09-01-2007

No I’m saying its useless if you use basic methods. As said before even the SHA-1 with salt can be broken, its just very HARD. So don’t think there’s no point then to using encryption, there is, I just don’t want anyone here thinking anything is safe. Because its not, make sure you use a clever method thats all, and don’t do silly things.

How many hackers will want to brute force crack a SHA-1 string just to gain access to a small website? None, if you have more important data I would go talk to someone with the latest knowhow of cryptography.

 Signature 

Kaydoo - A day in the life of a developer
BackendPro Control Panel

Profile
 
 
Posted: 06 March 2008 09:50 PM   [ Ignore ]   [ # 26 ]  
Grad Student
Rank
Total Posts:  34
Joined  11-15-2007
adamp1 - 16 February 2008 03:15 AM

Let me just throw my view in. I have done a cryptography course at degree level. let me just say one thing, if you have a two way encryption algorithm it can be broken very easily. You don’t even need the key, if you know how it works (the algorithm) most can be broken by simple processes.

If someone really wants some data you store they will be able to get it, doesn’t matter how much you encrypt it. The only way you can stop it is to make the process so hard the data isn’t worth it to decrypt it.

I store my passwords using a SHA-1 with salt method. I would advice you all to do the same. DO NOT use two way encryption just so the password can be made into ****‘s. This is crazy, just say to the client NO. Your the expert they should listen to you, and if they still refuse print out a random length string of **‘s or something.

So just to clarify, use SHA-1 with salt, its the best there is at the moment. I know SHA-1 has been broken but unless your a crypto-geek its probably the best and easiest to use.

I’m sorry, but this bugs me. Not that you aren’t right (well, except for SHA-1 being the best there is, there’s SHA-256, SHA-512 raspberry), but two-way encryption is redundant. Just like how Microsoft says reversible encryption. Encryption is, by its very definition, reversible. (A)Symmetric ciphers, block ciphers (eg. Fiestel Network), they are all encryption and are two-way in definition.

Hashing on the other hand is one-way. It cannot be reversed. Sure, you can get collisions, run birthday attacks, brute force it, and various other attacks, but you cannot reverse it. At the end of the day, you get a string, compare it to the hash you are trying to find, and keep going. Contrast that to the Level 7 Cisco passwords which can be broken in under a minute because they used sorry encryption algorithms instead of hashing (ala Level 5).

As for handling passwords, phpBB (my favorite bb software) [disclaimer: I used to be on the team, handling support and security] uses a slightly modified version of this: http://www.openwall.com/phpass/, which came highly recommended from SektionEins (http://www.sektioneins.de/). I would suggest you too look at it.

Profile
 
 
   
2 of 2
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120527 Total Logged-in Users: 34
Total Topics: 126592 Total Anonymous Users: 6
Total Replies: 665524 Total Guests: 378
Total Posts: 792116    
Members ( View Memberlist )
Newest Members:  andrewknightKittx77AmityBetbulJahhnvicrussell@gmail.comdefrtymusclesseownikaiyu