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

Contract incompatible with solidity 0.8.3

Summary

The codebase is intended to be used with any solidity version ^0.8.3, however, the codebase uses custom errors that were only introduced in a later version.

Vulnerability Details

This project uses custom errors which is a feature that was introduced in solidity version 0.8.4. Therefore an attempt to compile MathMasters.sol with solidity version 0.8.3 will result in a compilation error.

POC

Add the following line to foundry.toml:

[profile.default]
src = "src"
out = "out"
+solc_version = "0.8.3"
libs = ["lib"]

And run forge compile which will result in a compilation error.

Impact

Any project that is using solidity 0.8.3 will be unable to use this codebase.

Tools Used

Foundry

Recommendations

To fix this issue 2 suggestions are given:

  1. Update the documentation stating that the codebase can only be used in projects solidity version 0.8.4 or higher.

  2. If supporting solidity 0.8.3 is required then remove custom errors, and change:

- mstore(0x40, 0xbac65e5b) // `MathMasters__MulWadFailed()`.
- revert(0x1c, 0x04)
+ let ptrError := mload(0x40) // Get memory pointer
+ mstore(ptrError, 0x19) // Revert reason length
+ mstore(add(ptrError, 0x20), "MathMasters__MulWadFailed")
+ revert(ptrError, 0x40)
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Project that use pragma=0.8.3 won't be able to use the library due to custom errors not being supported in that Solidity version.

Support

FAQs

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