Withdraw from AaveVault will receive less than actual share
The AaveVault caches its total value locked (tvl) and only updates it at the end of each push and pull. When a user withdraws from LpIssuer, the token amounts are calculated using this stale cached tvl, so the user receives less than their actual share of accrued interest or donations.
Submitted by gzeon
Impact
AaveVault cache tvl and update it at the end of each _push and _pull. When withdrawing from LpIssuer, tokenAmounts is calculated using the cached tvl to be pulled from AaveVault. This will lead to user missing out their share of the accrued interest / donations to Aave since the last updateTvls.
Proof of Concept
- https://github.com/code-423n4/2021-12-mellow/blob/6679e2dd118b33481ee81ad013ece4ea723327b5/mellow-vaults/contracts/LpIssuer.sol#L150
- https://github.com/code-423n4/2021-12-mellow/blob/6679e2dd118b33481ee81ad013ece4ea723327b5/mellow-vaults/contracts/AaveVault.sol#L13
Recommended Mitigation Steps
Call updateTvls at the beginning of withdraw function if the _subvault will cache tvl
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 the vault's cached total value is not updated before withdrawal calculations, so stale data is used.
Impact
A user withdrawing could receive less than their fair share of interest or donations accrued since the last tvl update.
What the attacker needed
User has funds in AaveVault; interest or donations accrued since last update
The fix
The withdraw function should call updateTvls at the beginning if the subvault caches tvl.
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 keeps a saved number for how much money is in a vault. That number is only refreshed at certain times. If you take your money out before it is refreshed, the contract uses the old, lower number to decide how much you get, so you lose some of the interest you earned.
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.