Tutorial :Using a hash of data as a salt



Question:

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.)


Solution:1

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.


Solution:2

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.


Solution:3

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.


Solution:4

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.


Solution:5

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »