The _currentExchangeRate of the Vault contract can’t increase and will always be lower than or equal to _assetUnit
The vault's exchange rate calculation caps withdrawable assets at the recorded supply-to-assets value, so the rate can never rise above the asset unit and cannot recover after a temporary under-collateralisation. This prevents further deposits when the vault is under-collateralised, though the team later stated the cap is intentional to stop users claiming accrued yield.
The _currentExchangeRate of the Vault contract can not increase and will always be lower than or equal to _assetUnit. Therefore, when the vault is under-collateralized (_currentExchangeRate < _assetUnit), it can’t be further collateralized.
The _totalSupplyAmount != 0 && _withdrawableAssets != 0, _currentExchangeRate function will return a value _withdrawableAssets * _assetUnit / _totalSupplyAmount. However, _withdrawableAssets can not exceed _totalSupplyToAssets, which is equal to _totalSupplyAmount * _lastRecordedExchangeRate / _assetUnit. Therefore, _currentExchangeRate will always be lower than or equal to _lastRecordedExchangeRate.
Add this assert line and run forge test; all tests will pass.
It seems to me that because of if (_withdrawableAssets > _convertToAssets(_totalSupplyAmount, _lastRecordedExchangeRate, Math.Rounding.Down)), the rate indeed can’t increase; which is a huge issue in case of a momentary undercollateralization.
@Picodes - Indeed, the exchange rate should not be greater than 1 because users should not be able to claim the yield that has accrued in the YieldVault.
We subtract the yield from the total amount, with the yield being the difference between _withdrawableAssets and _totalSupplyToAssets.
If the YieldVault becomes under-collateralized, users won’t be able to deposit anymore, but will be able to withdraw their share of the deposit. Any yield that as accrued and has not been claimed yet will be shared proportionally amongst users.
The original report as published on Code4rena, by KIntern_NA. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the code clamps withdrawable assets to the previously recorded supply-to-assets value, so the computed exchange rate can never exceed the last recorded rate.
Impact
During a temporary under-collateralisation the vault cannot be re-collateralised because deposits are blocked, although the team says the cap is intentional to prevent users claiming accrued yield.
What the attacker needed
Vault becomes temporarily under-collateralised
The fix
The team said the behaviour was intentional and only added comments to clarify it, so no functional fix was applied.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A vault tracks how much each share is worth using an exchange rate. The code deliberately caps the amount of assets counted so the rate can never go above one, which means if the vault briefly holds less than it should, it can never build back up and new deposits are blocked. The team said this cap is on purpose so people cannot take yield that has built up.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.