Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fake signature on client side #3

Open
ouato opened this issue Mar 13, 2023 · 1 comment
Open

Fake signature on client side #3

ouato opened this issue Mar 13, 2023 · 1 comment

Comments

@ouato
Copy link

ouato commented Mar 13, 2023

Hi,

I see a security issue in the current flow: if a man in the middle catches the message and the signature, he can reuse the same message and signature at will to fake he is the rightful owner of a wallet.

In order to prevent that, I am trying to sign random messages coming from the backend, and not any message "provided" by the client.
At this time, I don't see how to check that the message that was signed is the one I first provided from the backend (through prior call). I would need that onAuth has access to the message signed (no need for signature as it is checked by the lib already).

Thank you for your work!

For reference, I was trying to implement this good article: https://www.toptal.com/ethereum/one-click-login-flows-a-metamask-tutorial#how-the-login-flow-works

@coopermaruyama
Copy link
Owner

Hi,

you're totally right -- since making this library I have built a few systems that address this, but I'm not sure it should be part of this repo, I'll leave this issue open to add to README or something.

The way you'd do it is as follows:

  1. Create an endpoint /get-nonce that simply generates a random string and assigns it to their session, and returns it. so for the message to sign, 'some message' becomes 'some message' + nonce
  2. client needs to call /get-nonce before creating signature, append to message, and sign.
  3. server verifies the message then deletes the nonce from the session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants