## User Driven Insecure Hash Algorithm

Critical

Low

#### Trust Level

High

Cryptographic hash algorithms take an input and produce fixed-size (such as 56 bit, 128 bit, etc.) output. The basic premise of cryptographic hash algorithms is that from the hash output, it’s not possible to restore the input. Another basic premise of hashing algorithms is that it shouldn’t be possible to find two different input values that can generate the same hash value. Moreover, it should be hard to find another input different than the original input of which the hash value is given. Here are the premise names in order;

• collision resistance
• preimage resistance
• second preimage resistance

Hash algorithms that were proven to be secure in early times are announced to be insecure with time passing. MD5 or SHA-1 are two examples of these broken cryptographic hash algorithms.

Using weak hash algorithms will create a false sense of security. We would think that our hashed data will never be transformed back into original input and stay hashed as long as we want, however that wouldn’t be true if we don’t use solid cryptographic hash algorithms.

The user who was given the ability to select the hash algorithm to be used may select a weak hash algorithm such as MD5 or SHA-1 for his advantage.

```            ```
string selectedHashAlgorithm= Request[“selected_hash”];
var hashAlgorithm = HashAlgorithm.Create(selectedHashAlgorithm);

```
```

The above code decides on the cryptographic hash algorithm that will be used by the input from the user, probably from a combo-box. The user might send a weak cryptographic hash algorithm that might not be on the list.

Cryptographic hash algorithms take an input and produce fixed-size (such as 56 bit, 128 bit, etc.) output. The basic premise of cryptographic hash algorithms is that from the hash output, it’s not possible to restore the input. Another basic premise of hashing algorithms is that it shouldn’t be possible to find two different input values that can generate the same hash value. Moreover, it should be hard to find another input different than the original input of which the hash value is given. Here are the premise names in order;

• collision resistance
• preimage resistance
• second preimage resistance

Hash algorithms that were proven to be secure in early times are announced to be insecure with time passing. MD5 or SHA-1 are two examples of these broken cryptographic hash algorithms.

Using weak hash algorithms will create a false sense of security. We would think that our hashed data will never be transformed back into original input and stay hashed as long as we want, however that wouldn’t be true if we don’t use solid cryptographic hash algorithms.

The user who was given the ability to select the hash algorithm to be used may select a weak hash algorithm such as MD5 or SHA-1 for his advantage.

```            ```
string selectedHashAlgorithm= request.getParameter(“selected_hash”);
MessageDigest mdaAlg = MessageDigest.getInstance(selectedHashAlgorithm);
byte[] hashBytes = mdaAlg.digest(text.getBytes("UTF-8"));
```
```

The above code decides on the cryptographic hash algorithm that will be used by the input from the user, probably from a combo-box. The user might send a weak cryptographic hash algorithm that might not be on the list.

### Finding A Way To Purchase AttackFlow Enterprise Edition?

If so, click to buy now for yearly subscriptions!