views:

117

answers:

6

I was wondering - is there any disadvantages in using the hash of something as a salt of itself?

E.g. hashAlgorithm(data + hashAlgorithm(data))

This prevents the usage of lookup tables, and does not require the storage of a salt in the database. If the attacker does not have access to the source code, he would not be able to obtain the algorithm, which would make brute-forcing significantly harder.

Thoughts? (I have a gut feeling that this is bad - but I wanted to check if it really is, and if so, why.)

+6  A: 

If the attacker does not have access to the source code

This is called "security through obscurity", which is always considered bad. An inherently safe method is always better, even if the only difference lies in the fact that you don't feel save "because they don't know how". Someone can and will always find the algorithm -- through careful analysis, trial-and-error, or because they found the source by SSH-ing to your shared hosting service, or any of a hundred other methods.

Wim
+1. The hacker will have access to the binaries. You have to assume the bad guy can read the assembly as easy as we can read the original source.
Mark Wilkins
People can view your source data in a shared hosting environment using SSH?!
Sam152
It depends how you set the permissions to your home directory, but if your hosting company uses 755 by default (and some really do), you can...
Wim
Makes sense, if the attacker obtains the source, he could once again generate a lookup table. Totally forgot about security through obscurity. (Other answers were useful as well, but I felt that this was the most crucial factor, sorry!)
gamers2000
A: 

You need to make sure the hash itself is strong or else this salting technique will fail.

Woot4Moo
any particular reason for the downvote?
Woot4Moo
I suspect the reason is irrelevance. The use of the hash was incorrect, which compromises security even with the best of hashes.
Steven Sudit
A: 

It is always better to use true random data as salt. Imagine an implementation where the username ist taken as salt value. This would lead to reduced security for common names like "root" or "admin".

I you don't want to create and manage a salt value for each hash, you could use a strong application wide salt. In most cases this would be absolutely sufficient and many other things would be more vulnerable than the hashes.

deamon
+5  A: 

Using a hash of the data as salt for the data is not secure.

The purpose of salt is to produce unpredictable results from inputs that are otherwise the same. For example, even if many users select the same input (as a password, for example), after applying a good salt, you (or an attacker) won't be able to tell.

When the salt is a function of the data, an attacker can pre-compute a lookup table, because the salt for every password is predictable.

The best salts are chosen from a cryptographic pseudo-random number generator initialized with a random seed. If you really cannot store an extra salt, consider using something that varies per user (like a user name), together with something application specific (like a domain name). This isn't as good as a random salt, but it isn't fatally flawed.

Remember, a salt doesn't need to be secret, but it cannot be a function of the data being salted.

erickson
I read that as "If you really cannot store extra salt" lol
Cyclone
That reminds me of the Puerto Rico board game http://www.boardgamegeek.com/boardgame/3076/puerto-rico . Should have built that warehouse...
Wim
+1  A: 

This offers no improvement over just hashing. Use a randomly generated salt.

The point of salting is to make it so two chronologically distinct values' hashes differ, and by so doing breaks pre-calculated lookup tables.

Consider:

data = "test"
hash = hash("test"+hash("test"))

Hash will be constant whenever data = "test". Thus, if the attacker has the algorithm (and the attacker always has the algorithm) they can pre-calculate hash values for a dictionary of data entries.

Kevin Montrose
You never used `data` in the second statement, was that intentional?
Cyclone
I guess; think of it as given statement 1, statement 2 becomes...
Kevin Montrose
+2  A: 

This is not salt - you have just modified the hash function. Instead of using lookup table for the original hashAlgorithm, attacker can just get the table for your modified one; this does not prevent the usage of lookup tables.

Messa