by cryptoquick · 6y ago · 0 comments
The hash of the answer is just a string that concatenates the answers, and the challenges always mixes them in different orders. One possible example:
1. Does Red combine with Yellow to make Green or Orange? 2. If the answer to the last question was reversed, what letter would it start with? 3. If you added that latter to the end of these words, which word would be most edible? Mac, Nam, Pi, Snak
answers: orange,e,pi
Of course, you'd want to design the interface to support multiple choice selection.
I would also recommend against using MD5, since, even if the hash weren't known to the end user, which should be sufficient even in this case, the attack MD5 is most known for is the fact that it's trivial to generate text that could match any given hash, regardless of what was used to originally make it. It seems like a potential attack vector somehow, depending on the case, and it's not terribly harder to just use one of the many tried-and-true, known-not-broken cryptographic hashing algorithms. SHA-256 would be adequate.
I'm not 100% certain of all the logic behind this, there's always cases I'm not rigorous to consider, but I'd be interested in seeing how others might improve this approach in similar ways.
Source on this?
Wikipedia states what I have heard before which is that MD5 collision attacks are pretty trivial now, but carrying out a preimage attack as you describe remains theoretical at this time.
Actually I don't know why there is some hash used at all. According to the example, answers are stored in a session. CRC32 would do the job as well. Or no hashing at all. You would need some better hash in case when user downloads it. I can imagine different flow where you would need some better hash: I.e. you have some secret token, hash it together with captcha answer, send question with good hash to a browser and user sends back answer together with a hash he got. In such flow there would be no need to store values in a session.