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

Version compatibility issue prevents use of library for contracts using version `0.8.3` of Solidity

Summary

There are compatibility issues between the library and smart contracts using version 0.8.3 of Solidity.

Vulnerability Details

Custom errors were introduced in Solidity version 0.8.4. This prevents smart contracts using version 0.8.3 from using this library.

References: Solidity 0.8.4 Release Announcement

Impact

Smart contracts using version 0.8.3 of Solidity cannot use this library.

Proof of Concept (PoC)

If we attempt to compile a smart contract that uses version 0.8.3 of Solidity and includes the library, a compilation error will occur.

Let's create a new smart contract in src/MathMastersExposed.sol with a version0.8.3 of Solidity that will include the library:

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity 0.8.3;
import {MathMasters} from "src/MathMasters.sol";
contract MathMastersExposed {
using MathMasters for uint256;
}

If we attempt to compile this smart contract using forge build, we will encounter a compilation error:

Compiler run failed:
Error (2314): Expected ';' but got '('
--> src/CustomErrors.sol:5:36:
|
5 | error MathMasters__MulWadFailed();
| ^
Error (2314): Expected ';' but got '('
--> src/MathMasters.sol:14:41:
|
14 | error MathMasters__FactorialOverflow();
|

Tools Used

  • Manual review

  • Foundry

Recommendations

The library's pragma should not include version 0.8.3.

Recommended changes to the MathMasters.sol library:

- pragma solidity ^0.8.3;
+ pragma solidity ^0.8.4;

If we change the pragma from 0.8.3 to 0.8.4 in our previously created smart contract, we can now compile it successfully.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
stefanlatinovic Submitter
over 1 year ago
inallhonesty Lead Judge
over 1 year ago
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.