Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Valid

Revert reason in multiplication methods returns wrong error identifier

Summary

The custom error identifier returned in case the condition is not met and execution reverts is not correct.

Vulnerability Details

The following are the custom error indentifiers present in MathMasters:

"MathMasters__DivWadFailed()": "d5c00fba",
"MathMasters__FactorialOverflow()": "e243bb9b",
"MathMasters__FullMulDivFailed()": "41672c55",
"MathMasters__MulWadFailed()": "a56044f7"

The current implementation of the mulWad and mulWadUp functions is using the wrong custom error, which actually does not match any of the available ones.

Impact

The impact is low, as it may not impact the protocols using the code, but it may confuse the users as the error identifier is not correct.

Tools Used

Manual review

Recommendations

The proper custom error indetifier should be passed, which for the MathMasters_MulWadFailed() is 0xa56044f7

function mulWadUp(uint256 x, uint256 y) public pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, div(not(0), y))) {
+ mstore(0x40, 0xa56044f7)
- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
revert(0x1c, 0x04)
}
...
function mulWad(uint256 x, uint256 y) public pure returns (uint256 z) {
// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, div(not(0), y))) {
+ mstore(0x40, 0xa56044f7)
- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
revert(0x1c, 0x04)
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Wrong error selector

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.