Incorrect function call in LybraRETHVault ’s getAssetPrice
The LybraRETHVault contract calls a non-existent function getExchangeRatio() on the rETH contract, so the asset price cannot be calculated. This would halt all operations that depend on asset pricing.
bytes032 Follow with MrPotatoMagic, Arz and 36 others
Originally disclosed on Code4rena
Submitted by bytes032, also found by MrPotatoMagic, Arz, HE1M, devival, 0xMAKEOUTHILL, Toshii, qpzm, qpzm, a3yip6, Iurii3, LokiThe5th, Cryptor, LaScaloneta, Qeew, Qeew, bart1e, azhar, pep7siup, pep7siup, 0xnacho, 0xnacho, Co0nan, Co0nan, Musaka, hl_, 0xgrbr, 0xkazim, SovaSlava, RedTiger, RedTiger, CrypticShepherd, CrypticShepherd, LuchoLeonel1, Vagner, kutugu, peanuts, smaul, and jnrlouis
The incorrect function call in the code results in the inability to calculate the asset price properly. This will halt all operations associated with the asset pricing, disrupting the functioning of the entire system.
Proof of Concept
LybraRETHVault’s getAssetPrice method currently makes a call to a non-existent function in the rETH contract, getExchangeRatio(). The issue appears to be a misunderstanding or miscommunication, as the rETH contract does not provide a getExchangeRatio() function. This leads to a failure in the asset price calculation.
function getAssetPrice() public override returns (uint256) {
return (_etherPrice() * IRETH(address(collateralAsset)).getExchangeRatio()) / 1e18;
}
The correct function to call is getExchangeRate(), which exists in the rETH contract and provides the exchange rate necessary to determine the asset price.
https://etherscan.deth.net/address/0xae78736Cd615f374D3085123A210448E74Fc6393
https://etherscan.deth.net/address/0xae78736Cd615f374D3085123A210448E74Fc6393
Tools Used
Manual review
Recommended Mitigation Steps
To resolve this issue, it is recommended to replace the non-existent function call getExchangeRatio() with the correct function getExchangeRate(). This correction will ensure that the getAssetPrice() method retrieves the correct exchange rate from the rETH contract, allowing the system to calculate the asset price accurately.
function getAssetPrice() public override returns (uint256) {
return (_etherPrice() * IRETH(address(collateralAsset)).getExchangeRate()) / 1e18;
}
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a typo or misunderstanding: the code calls getExchangeRatio() instead of the existing getExchangeRate() on the rETH contract.
Impact
All operations associated with asset pricing would be disrupted, halting the functioning of the entire system.
What the attacker needed
None
The fix
The non-existent function call should be replaced with the correct getExchangeRate() function.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract tried to ask another contract for a value using a function name that does not exist. Because the call fails, the price of the asset cannot be worked out, and anything that needs that price stops working.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.