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

[OZ: M-04] Math library is vulnerable to shadow overflow #71

Closed
ggviana opened this issue Oct 16, 2022 · 1 comment
Closed

[OZ: M-04] Math library is vulnerable to shadow overflow #71

ggviana opened this issue Oct 16, 2022 · 1 comment

Comments

@ggviana
Copy link
Collaborator

ggviana commented Oct 16, 2022

The AuxMath library is a custom auxiliary math library that performs multiplication and division with rounding specifications.

The implementation of mulDivUp and mulDivDown first compute the multiplication of a uint256 with a uint256 without taking into account the possibility of an overflow in the product. The product could overflow into a uint512 in the multiplication step even if the result were to fit into a uint256 after the subsequent division. Hence the current implementation will not give the right result in such a case.

Consider using OpenZeppelin's Math library which implements the mulDiv function that is developed especially considering these scenarios and is widely accepted in the ecosystem.

@ggviana ggviana changed the title M-04 Math library is vulnerable to shadow overflow [M-04] Math library is vulnerable to shadow overflow Oct 16, 2022
@ggviana
Copy link
Collaborator Author

ggviana commented Oct 16, 2022

Fixed @ 89869ad

Implemented OpenZeppelin's ERC4626, which takes into account multiplication overflow

@ggviana ggviana closed this as completed Oct 16, 2022
@Robsonsjre Robsonsjre changed the title [M-04] Math library is vulnerable to shadow overflow [OZ: M-04] Math library is vulnerable to shadow overflow Oct 16, 2022
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

1 participant