Open code423n4 opened 2 years ago
https://github.com/code-423n4/2022-04-jpegd/blob/e72861a9ccb707ced9015166fbded5c97c6991b6/contracts/vaults/FungibleAssetVaultForDAO.sol#L105
Price can be stale and can lead to wrong answer return value.
answer
Oracle data feed is insufficiently validated. There is no check for stale price and round completeness. Price can be stale and can lead to wrong answer return value.
function _collateralPriceUsd() internal view returns (uint256) { int256 answer = oracle.latestAnswer(); uint8 decimals = oracle.decimals(); require(answer > 0, "invalid_oracle_answer"); ...
Manual review
Validate data feed
function _collateralPriceUsd() internal view returns (uint256) { (uint80 roundID, int256 answer, , uint256 timestamp, uint80 answeredInRound) = oracle.latestRoundData(); require(answer > 0, "invalid_oracle_answer"); require(answeredInRound >= roundID, "ChainLink: Stale price"); require(timestamp > 0, "ChainLink: Round not complete"); ...
Can add validation for round not being complete yet and potentially for stale pricing. This should be med risk, as shown in past contests [1] [2] [3]
Fixed in https://github.com/jpegd/core/pull/9
Agree with sponsor on the medium risk rating. An oracle with a bad value is by definition an external requirement.
Lines of code
https://github.com/code-423n4/2022-04-jpegd/blob/e72861a9ccb707ced9015166fbded5c97c6991b6/contracts/vaults/FungibleAssetVaultForDAO.sol#L105
Vulnerability details
Impact
Price can be stale and can lead to wrong
answer
return value.Proof of Concept
Oracle data feed is insufficiently validated. There is no check for stale price and round completeness. Price can be stale and can lead to wrong
answer
return value.https://github.com/code-423n4/2022-04-jpegd/blob/e72861a9ccb707ced9015166fbded5c97c6991b6/contracts/vaults/FungibleAssetVaultForDAO.sol#L105
Tools Used
Manual review
Recommended Mitigation Steps
Validate data feed