code-423n4 / 2022-06-nibbl-findings

1 stars 0 forks source link

Division by 0 #232

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-06-nibbl/tree/main/contracts/Test/UpgradedNibblVault.sol#L484

Vulnerability details

Division by 0 can lead to accidentally revert, (An example of a similar issue - https://github.com/code-423n4/2021-10-defiprotocol-findings/issues/84)

Code instances:

    https://github.com/code-423n4/2022-06-nibbl/tree/main/contracts/NibblVault.sol#L183 _initialTokenSupply, _initialTokenPrice might be 0
HardlyDifficult commented 2 years ago

The link provided is incorrect. However the instance listed has the correct source for this report.

Although technically correct, the issue occurs on the first line of the initialize function. If 0 was provided for one of the fields mentioned then the transaction reverts and it could be retried with correct inputs.

There's no recommendation provided here. Adding a require statement for example would have the same effect, only providing a more clear revert reason.