Boost _ Folks Finance 33675 - [Smart Contract - Low] PythNodeprocess can revert because of incorrect casting
Submitted on Fri Jul 26 2024 06:49:20 GMT-0400 (Atlantic Standard Time) by @OxAnmol for Boost | Folks Finance
Report ID: #33675
Report type: Smart Contract
Report severity: Low
Target: https://testnet.snowtrace.io/address/0xA758c321DF6Cd949A8E074B22362a4366DB1b725
Impacts:
Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
If the pyth
oracle returns the exponent < -18 then the factor.toUint256()
will revert due to the incorrect casting.
Vulnerability Details
Here the code expects the factor to be ≥0, but in case the pythData.expo
is < -18 in that case the factor will be negative, and if it is negative the toUint256
of SafeCast
will revert as you can see in the code.
Here is how the original implementation from the synthetic that handles this issue. https://github.com/Synthetixio/synthetix-v3/blob/8aff01938913983b97faa5ce082c15b86db32e0d/protocol/oracle-manager/contracts/nodes/pyth/PythNode.sol#L32
Impact Details
The pyth priceFeed where the exponent is < -18 can cause the malfunctioning of the protocol.
References
https://github.com/Folks-Finance/folks-finance-xchain-contracts/blob/fb92deccd27359ea4f0cf0bc41394c86448c7abb/contracts/oracle/nodes/PythNode.sol#L36
Proof of concept
This is a test from PythNode.test.ts
, here you can see that the test reverts if we override decimals
from 8 to 20.
Last updated