Summary
The getNFTPrice function retrieves an NFT price from the oracle but fails to verify the lastUpdateTimestamp, leaving the protocol vulnerable to stale or outdated price data.
Vulnerability Details
In the getNFTPrice function we get nft price from oracle but we do not check lastUpdateTimestamp for stale prices
/contracts/core/pools/LendingPool/LendingPool.sol:605
605: function getNFTPrice(uint256 tokenId) public view returns (uint256) {
606: (uint256 price, uint256 lastUpdateTimestamp) = priceOracle.getLatestPrice(tokenId);
607: if (price == 0) revert InvalidNFTPrice();
608: return price;
609: }
Impact
If the oracle data becomes outdated, relying on a stale price could lead to incorrect valuations.
Tools Used
Manual Review
Recommendations
Add staleness check as follow:
error StalePrice();
uint256 public constant MAX_PRICE_AGE = 24 hours;
@@ -98,6 +98,8 @@ contract LendingPool is ILendingPool, Ownable, ReentrancyGuard, ERC721Holder, Pa
// Allow to pause withdrawals
bool public withdrawalsPaused = false;
+ error StalePrice();
+ uint256 public constant MAX_PRICE_AGE = 24 hours;
// MODIFIERS
@@ -606,6 +608,9 @@ contract LendingPool is ILendingPool, Ownable, ReentrancyGuard, ERC721Holder, Pa
(uint256 price, uint256 lastUpdateTimestamp) = priceOracle.getLatestPrice(tokenId);
if (price == 0) revert InvalidNFTPrice();
+ if (block.timestamp < (lastUpdateTimestamp + MAX_PRICE_AGE)) {
+ revert StalePrice();
+ }
return price;
}