In the documentation of mulWad
function in MathMasters
, the result of the calculation should be rounded down for whatever x and y pair.
The result of mulWad is equivalent to the following function:
Solidity will automatically do the rounding for the calculation. However, there exists some x and y such that the result is inconsistent to mulWadCorrectVersion
function.
Add the following test in MathMasters.t.sol
The error message shows that there is arithmetic overflow, which means the data validation in the previous step is invalid:
Modify the test case testMulWadFuzz
in MathMaster.t.sol:
After the unchecked statement that filter the possibility of overflow in multiplication, the mulWad
function should always success, but the test fails for certain test case.
Inconsistency in rounding might lead to severe consequence and multiple historic attack event originates in these types of vulnerability. The most famous one including the Balancer V2 Incident.
Foundry
Update the condition of overflow, and compare with the mulWadCorrectVersion using fuzzing tools.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.