Hello, great article! Thanks for sharing this valuable example.
I have a doubt about how can you avoid replay attacks with just a nonce?
Let's set an example: Another website makes you sign an exact message as the one you are using to login to the original website, utilizing and saving a random fake nonce. Then the attacker (the another website owner) could utilize this signature plus the saved fake nonce, and be able to login to your account.
In the presented code, the only server-side check is that the cookie "auth-nonce" sent by the user it's the same as the one in the message, which absolutely will be in the scenario I'm mentioning.
Unless I'm missing something here, it doesn't sound like a secure solution.
Thanks in advance, and again, great article. Looking forward to implement this on our dApp.
Pablo is an internationally recognized expert and entrepreneur with more than 22 years of experience in designing and implementing large distributed systems in different stacks.
Hi there! I'm still not sure I understand how this is secure.
If an attacker has managed to get you to sign the same message with a random nonce, what prevents them from going to your site, manually setting their auth-nonce cookie to that random value and then passing the acquired user's signature to your API in order to log in as them?
Thanks!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello, great article! Thanks for sharing this valuable example.
I have a doubt about how can you avoid replay attacks with just a nonce?
Let's set an example: Another website makes you sign an exact message as the one you are using to login to the original website, utilizing and saving a random fake nonce. Then the attacker (the another website owner) could utilize this signature plus the saved fake nonce, and be able to login to your account.
In the presented code, the only server-side check is that the cookie "auth-nonce" sent by the user it's the same as the one in the message, which absolutely will be in the scenario I'm mentioning.
Unless I'm missing something here, it doesn't sound like a secure solution.
Thanks in advance, and again, great article. Looking forward to implement this on our dApp.
The nonce is generated server side and set in a cookie valid only for that website. The browser won't pass that cookie for any other random website.
Hi there! I'm still not sure I understand how this is secure.
If an attacker has managed to get you to sign the same message with a random nonce, what prevents them from going to your site, manually setting their
auth-nonce
cookie to that random value and then passing the acquired user's signature to your API in order to log in as them?Thanks!