I am using the following line of code to create a reset password code sent to the user in her/his email. when scanned with brakeman
to my ruby code, this line of code is catched and describes it as it is vulnerable.
this is the line of code I'm talking about:
reset_pass_code = Digest::SHA1.hexdigest(
"#{u.email}#{Time.now.to_s.split(//).sort_by {rand}.join}"
)
so my question is how can this be exploited as it is applied and sorted in rand
and it is possible that an attacker could exploit this and if yes how? I needed some explanations to contribute to my knowledge.
I understand all of the suggestions that it is good to use other alternatives of generating reset token but this despite SHA1's weakness. given attacker knowing user email. in this scenario is it possible for the attacker to reconstruct the generated token from this?