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

Updated mitigation in section on arithmetic overflows #10

Merged
merged 4 commits into from
Mar 17, 2023

Conversation

fegge
Copy link
Contributor

@fegge fegge commented Mar 17, 2023

Describe your changes

The mitigation described in the section on arithmetic overflows is insufficient as it currently stands. Since LessThan only restricts the size of the difference |in[0] - in[1]| between the two inputs, a malicious user try to withdraw p - 1. As long as the current balance is non-negative this would satisfy the circuit, even though p - 1 is huge when viewed as an unsigned value.

The correct mitigation is to use LessThan, together with constraints restricting the size of the inputs to ensure that they are non-negative. This can be done using the Num2Bits template from Circomlib.

Common Vulnerabilities Addition Checklist

  • Added example code of the vulnerability
  • Gave an explanation of how the vulnerability works
  • Added attack scenario section if applicable
  • Added preventative techniques section if applicable

@kcharbo3 kcharbo3 merged commit 7a7b31c into 0xPARC:main Mar 17, 2023
@kcharbo3
Copy link
Collaborator

Great catch, thanks for making the PR! Looks good to me.

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.

2 participants