Boost _ Folks Finance 33258 - [Smart Contract - Insight] Usage of floating pragma
Submitted on Tue Jul 16 2024 10:36:19 GMT-0400 (Atlantic Standard Time) by @chista0x for Boost | Folks Finance
Report ID: #33258
Report type: Smart Contract
Report severity: Insight
Target: https://github.com/Folks-Finance/folks-finance-xchain-contracts/blob/main/contracts/oracle/storage/NodeDefinition.sol
Impacts:
Primacy of Impact
Description
Brief/Intro
The problem lies in the inconsistent usage of Solidity compiler versions in the project’s contracts and libraries. While the main contracts are compiled with Solidity version 0.8.23, two libraries use a floating version pragma (>=0.8.11 <0.9.0). This inconsistency could lead to unexpected behavior and potential security vulnerabilities if the floating versions compile to a version with known issues.
Vulnerability Details
In the project, the main contracts use a fixed version pragma:
However, two libraries use a floating version pragma:
This discrepancy can lead to compilation with different versions of the Solidity compiler, which might introduce subtle bugs or security issues. For example, using a version above 0.8.23 might introduce changes not supported by all EVM-compatible chains, potentially causing runtime errors or unexpected behavior. Given that the rest of the libraries adhere to the fixed version 0.8.23, it’s likely that the floating pragma in these two libraries was unintended.
Impact Details
The primary risk is that using different compiler versions could introduce incompatibilities and potential security vulnerabilities. If a floating version resolves to a newer compiler that includes breaking changes or deprecated features, it could result in runtime errors or unexpected behavior on EVM-compatible chains that do not support those changes. This inconsistency may lead to loss of funds, failed transactions, or exploit opportunities for attackers targeting these discrepancies.
The reason I did submit this low issue is because all contracts and libraries besides two had a fixed pragma. So I thought that it was an oversight on your part, since if it was a coding style choice there would have been consistency. Anyways it is true that the impact is non existent and is considered a best practice, but in most audit contest it is still a valid low.
References
https://github.com/Folks-Finance/folks-finance-xchain-contracts/blob/fb92deccd27359ea4f0cf0bc41394c86448c7abb/contracts/oracle/storage/NodeDefinition.sol#L2
https://github.com/Folks-Finance/folks-finance-xchain-contracts/blob/fb92deccd27359ea4f0cf0bc41394c86448c7abb/contracts/oracle/storage/NodeOutput.sol#L2
Proof of concept
Proof of Concept
If we have this codes:
NodeDefinition.sol
OpCodeZero.sol
the bytecode of OpCodeZero.sol
is:
if you test this bytecode in https://www.evm.codes/playground
with cancun
the code run without any error. but if you run with paris
evm version you will sea the error. because we have INVALID
opcodes.
Last updated