OWASP / wrongsecrets

Vulnerable app with examples showing how to not use secrets
https://owasp.org/www-project-wrongsecrets/
GNU Affero General Public License v3.0
1.2k stars 339 forks source link

New Challenge: use weak KDF to protect a secret #713

Open commjoen opened 1 year ago

commjoen commented 1 year ago

Context

This is a Docker challenge focused on using the wrong KDF to protect a secret. In crypto-js there is an AES encryption mechanism, which uses MD5 as its KDF. This library is often used on mobile for encryption in hybrid apps. So what if we make a challenge in which the user has to find the right "pin"to be able to decrypt a secret offered on screen? (E.g. a 4-8 digit pin with md5 based KDF, and a secret fitting in 128 bytes. We need to relate it to the MSTG on how to use (P)KDF with additional entropy and contextual binding.

Did you encounter this in real life? Could you tell us more about the scenario?

See https://github.com/brix/crypto-js/blob/c8a2312474ae60c823f3c00b4d7aac2da460bbfc/test/config-test.js for test defaults.

EmperialX commented 1 year ago

Hello @commjoen , I came across this good first issue and I would like to work on fixing it and would appreciate your guidance as I work on this issue. Let me know if you have any suggestions. can you assign me on this.

commjoen commented 1 year ago

Hi @EmperialX sure, I will assign it to you :).

  1. Basically the steps are as follows: choose a number between 0 and 99999 of which you create the md-5 hash
  2. use the hash to encrypt "the answer"
  3. take the ciphertext of 2 and store it in the code
  4. now create the answer validation code that takes a string, test if it is a number, convert it to an int between 0 and 99999 and then takes the hash of it to decrypt the ciphertext you hardcoded in 3
  5. if the decrypted result of 4 matches "the answer" the user found the right "pin".
  6. explain in the challengetext that protecting keys is all about the keying material and why choosing a bad key derivation function (KDF) can be not so helpful (reference to https://github.com/brix/crypto-js/blob/c8a2312474ae60c823f3c00b4d7aac2da460bbfc/test/config-test.js) in combination with just only a plain number.
EmperialX commented 1 year ago

ok, thank you so much. I will give you the update as soon as possible.

On Sun, Apr 2, 2023 at 12:32 AM Jeroen Willemsen @.***> wrote:

Hi @EmperialX https://github.com/EmperialX sure, I will assign it to you :).

  1. Basically the steps are as follows: choose a number between 0 and 99999 of which you create the md-5 hash
  2. use the hash to encrypt "the answer"
  3. take the ciphertext of 2 and store it in the code
  4. now create the answer validation code that takes a string, test if it is a number, convert it to an int between 0 and 99999 and then takes the hash of it to decrypt the ciphertext you hardcoded in 3
  5. if the decrypted result of 4 matches "the answer" the user found the right "pin".
  6. explain in the challengetext that protecting keys is all about the keying material and why choosing a bad key derivation function (KDF) can be not so helpful (reference to https://github.com/brix/crypto-js/blob/c8a2312474ae60c823f3c00b4d7aac2da460bbfc/test/config-test.js) in combination with just only a plain number.

— Reply to this email directly, view it on GitHub https://github.com/OWASP/wrongsecrets/issues/713#issuecomment-1493077129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXSFQIEKYXC24OCBVDJZD63W7B3T5ANCNFSM6AAAAAAV7ECGHI . You are receiving this because you were mentioned.Message ID: @.***>

commjoen commented 1 year ago

No rush sir :) . Feel free to connect via Slack where you can find likeminded contributors :) . (See the readme for the links ;-) )

commjoen commented 11 months ago

Hi @EmperialX do you have any updates on this :) ?

CaduRoriz commented 10 months ago

/assign

commjoen commented 7 months ago

Hello @CaduRoriz ! How are you doing? Do you have any progress on this issue isr?

commjoen commented 3 months ago

Removed assignees based on inactivity. Feel free to have a go at it!