Forum Moderators: coopster

Message Too Old, No Replies

Adding salt to my passwords

...have I got this right?

         

elgumbo

3:17 pm on Dec 15, 2005 (gmt 0)

10+ Year Member



Hi

I'm playing around with some php user authentication scripts and came across a number of sites saying that in order to help protect your database from a potential dictionary attack you should add a random string of characters to the password.

Sounds great :)

but I am unsure what to do with the salt once I have got it. I know the theory - I need to concatenate my user's password and the salt before checking authentication - but wouldn't that require me storing the salt in plain text in the database? and wouldn't that negate the reason for using it in the first place? or I have I got it totally wrong (again)?

Any pointers?

jatar_k

4:04 pm on Dec 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



for certain things I have used salts. Normally they actually lived in a file somewhere, outside of the web root with specific permissions.

I don't find it a huge problem as the server would need to be compromised to grab it and at that point losing my salt would be the least of my worries.

it is an acceptable risk.

victor

12:39 am on Dec 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If someone gets to your password file, the server is compromised, as jatar_k says. Or maybe your backups are compromised, or your local copy on your PC for development. Something, somewhere got compromised.

But perhaps not everything did.....

If the salt is saved somewhere else, then the bad guys need both the salt and the password file. So you may still be fairly safe if they have only one or the other.

One way would be to use the first and last couple of letters of the user name as salt plus the date they joined. The salt then would, in effect, be code in the logon CGI script. If your cgi-bin has not been compromised, and you haven't told people of your salt algorithm, then the salt remains secret.

The salt is an added safety check that buys you a little bit more safety. It alone cannot keep everything totally secure.

PSWorx

5:14 am on Dec 16, 2005 (gmt 0)

10+ Year Member



for certain things I have used salts. Normally they actually lived in a file somewhere, outside of the web root with specific permissions.

How exactly would i go about this so my script can access a config file below the root directory

TIA

elgumbo

8:58 am on Dec 16, 2005 (gmt 0)

10+ Year Member



Thanks for the advice. I think I need to look into this a bit more.

jatar_k

5:05 pm on Dec 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> so my script can access a config file below the root directory

you just put it above the root and then you can use include to have your script access it.

PSWorx

5:45 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



Cool, i didnt realise it was ok for scripts to go back beyond the root directory of the web site, much appreciated