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

Make ECDSA.recover revert on error. #2114

Merged
merged 6 commits into from
Mar 10, 2020

Conversation

nventuro
Copy link
Contributor

@nventuro nventuro commented Mar 9, 2020

Fixes #1978.

ECDSA.recover used to return the 0 address on error. This PR changes its behavior to the following:

  1. it reverts if the signature size is incorrect
  2. it reverts if the signature is malleable (non-unique)
  3. it reverts if the signature is invalid (it recovers to the zero address)

I believe 1. and 2. are useful for debugging and error diagnosing, but I'm unsure about whether we should have 3. The scenario feels different from a situation where a signer was recovered, but it was not the one the system expected to warrant special handling.

I'll update the changelog with the changes once we decide whether or not we want to include 3.

@nventuro nventuro requested a review from frangio March 9, 2020 22:10
@frangio
Copy link
Contributor

frangio commented Mar 10, 2020

I would argue that it is a different scenario because the address zero is not random. In all other cases you can essentially consider the result of recover to be "random", or at least not such that an attacker can choose the specific result. On the other hand it's quite easy to generate a signature that would recover to the address zero. With this argument I would revert to be on the safe side.

@nventuro
Copy link
Contributor Author

I agree with that reasoning, yes. Thank you!

@nventuro nventuro merged commit 65e4ffd into OpenZeppelin:master Mar 10, 2020
@nventuro nventuro deleted the ecdsa-recover-revert branch March 10, 2020 23:13
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

Successfully merging this pull request may close these issues.

Make ECDSA.recover revert on failure
2 participants