Boost _ Folks Finance 33950 - [Smart Contract - Low] pythnode oracle unexpected revert

Submitted on Fri Aug 02 2024 12:45:49 GMT-0400 (Atlantic Standard Time) by @seesnap for Boost | Folks Finance

Report ID: #33950

Report type: Smart Contract

Report severity: Low

Target: https://immunefi.com/

Impacts:

  • Protocol insolvency

Description

Within PythNode.sol on line 32 it acknowledges line33 variable factor can be less than 0 therefore negative on line 33 when pythData.expo is less than 18 then factor will be less than 0. This causes line 36 to revert due to "factor.toUint256" in which the safeCast.sol function "toUint256" revers when input value is less than 0

function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); }

Proof of concept

pragma solidity 0.8.23;

import "../contracts/oracle/nodes/PythNode.sol"; import "../lib/forge-std/src/Test.sol"; import "../contracts/spoke/SpokeGasToken.sol"; import "../contracts/bridge/test/MockBridgeRouter.sol"; import "../contracts/bridge/libraries/Messages.sol"; import "../contracts/spoke/RateLimited.sol"; import "../contracts/spoke/interfaces/IAddressOracle.sol";

contract getit is Test{

function setUp() public {
}

function testdis() public {
    othereg pythAddress = new othereg();
    bytes32 priceFeedId;
    bool useEma = 1> 0;
    vm.expectRevert();
    PythNode.process(abi.encode(address(pythAddress), priceFeedId, useEma));

}

}

contract othereg is IPyth{ using Math for uint256; using SafeCast for int64; using SafeCast for int256; constructor(){

function getEmaPriceUnsafe(bytes32 priceFeedId) view external override returns(PythStructs.Price memory ) { PythStructs.Price memory nah; nah.price = 1;

} function getPriceUnsafe(bytes32 priceFeedId) view external override returns(PythStructs.Price memory ) { PythStructs.Price memory nah; nah.price = 1;

}

Last updated

Was this helpful?