Boost _ Folks Finance 33454 - [Smart Contract - Low] unsafe casting will lead to break of PythNode Oracle
Submitted on Sat Jul 20 2024 20:46:30 GMT-0400 (Atlantic Standard Time) by @Tripathi for Boost | Folks Finance
Report ID: #33454
Report type: Smart Contract
Report severity: Low
Target: https://testnet.snowtrace.io/address/0xA758c321DF6Cd949A8E074B22362a4366DB1b725
Impacts:
Protocol insolvency
Temporary freezing of funds of at least 24h
Description
Brief/Intro
PythNode
tries to cast a negative number to uint256 . Which is not possible
Vulnerability Details
https://github.com/Folks-Finance/folks-finance-xchain-contracts/blob/main/contracts/oracle/nodes/PythNode.sol#L23
factor is calculated as PRECISION + pythData.expo
. Since pythData.expo can be both positive and negative. WHenever factor = PRECISION + pythData.expo < 0
in second line it calls factor.toUint256()
{using SafeCast for int256} which will revert with SafeCastOverflowedIntToUint()
error
Impact Details
Price mechanism breaks if factor<0. which renders most of protocol function useless
References
Proof of concept
Proof of Concept
copy and paste above code in remix . deploy and call process()
function with a expo param which makes factor = PRECISION + expo<0
eg process(-19) or process(-20) etc
Last updated