Submitted by fyamf, also found by Fassi_Security
Failure to store the fetched price from the oracle in the storage variables of the xRenzoDeposit contract can result in several important issues.
Price Fetching on Deposit: When a deposit is made in xRenzoDeposit, the getMintRate function fetches the price of ezETH.
https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L204
Oracle vs. Storage: If an oracle is defined, the function retrieves the price from the oracle. Otherwise, it reads the price from the storage variable lastPrice, which is updated by the updatePrice function.
https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L286-L301
https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L303-L359
First Issue - Inaccurate Price Usage: The first issue arises when the oracle is used to fetch the price but is not stored in the storage variables. Subsequent calls to getMintRate after the oracle is undefined may use the outdated price from storage instead of the most recent one fetched from the oracle. This leads to inaccurate pricing and potential financial losses. For example:
It shows that although the recent fetched price and timestamp is 1.02 ether and k + 3 hours, respectively, getMintRate returns the price of the time when they were stored in the storage variables during updating the price about 5 hours before.
Second Issue - Divergence Check: Another issue is that when the price is updated, the to-be-updated price is compared with the lastPrice. If, the oracle is used to fetch the price in between the updates, since the fetched price from the oracle is not stored in lastPrice variable, the to-be-updated price is compared with price stored in the storage variable before the oracle fetch. This undermines the trustworthiness of the divergence check mechanism.
https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L330C5-L359C6
Third Issue - Manual Price Updates: The third issue arises when the price update fails due to inaccurate divergence checks. For example:
In such cases, manual intervention is required by the admin to update the price, which adds complexity and overhead.
https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L320-L322
To address these issues, its recommended to modify the getMintRate function to store the fetched price from the oracle in the storage variables. This ensures that the most recent price is used for calculations.
Oracle
jatinj615 (Renzo) acknowledged and commented:
alcueca (judge) decreased severity to Medium and commented:
EV_om (warden) commented:
alcueca (judge) commented:
Note: For full discussion, see here.
