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

Memory Store to reserved slot

Summary

Using a reserved memory slot to store data.

Vulnerability Details

According to the following solidity documentation, the memory slot 0x40 is reserved for the currently allocated memory size and should not be used for other purposes.
However in MathMasters this slot is used in the following fashion. Which overwrites the current value, and could potentially lead to memory issues.

Impact

As the function reverts immediatly after this action the impact will only be that we'll not get the correct error message.

Tools Used

Manual review.

Recommendations

Make the following changes

- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
- revert(0x1c, 0x04)
+ let ptr := mload(0x40) //Get free memory pointer
+ mstore(ptr, 0xa56044f7) //store error selector `MathMasters__MulWadFailed.selector`
+ revert(ptr, 0x04)
Updates

Lead Judging Commences

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

Wrong error selector

Wrong error storage

Support

FAQs

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