DEV Community

Discussion on: Sign-In with Solana

Collapse
 
morgansson profile image
morgansson • Edited

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.

Collapse
 
cibrax profile image
Cibrax

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.

Collapse
 
t4t5 profile image
Tristan

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!