AaveVault does not update TVL on deposit/withdraw
The AaveVault contract caches its total value locked (TVL) and does not update it when depositing or withdrawing. An attacker can deposit tokens, get LP tokens based on the old TVL, then trigger a TVL update that includes accrued interest, and withdraw to receive a larger share, profiting from the interest.
Submitted by cmichel, also found by WatchPug
Aave uses rebasing tokens which means the token balance aToken.balanceOf(this) increases over time with the accrued interest.
The AaveVault.tvl uses a cached value that needs to be updated using a updateTvls call.
This call is not done when depositing tokens which allows an attacker to deposit tokens, get a fair share of the old tvl, update the tvl to include the interest, and then withdraw the LP tokens receiving a larger share of the new tvl, receiving back their initial deposit + the share of the interest. This can be done risk-free in a single transaction.
Proof Of Concept
- Imagine an Aave Vault with a single vault token, and current TVL =
1,000 aTokens - Attacker calls
LPIssuer.push([1000]). This loads the old, cachedtvl. NoupdateTvlis called. - The
1000underlying tokens are already balanced as there’s only one aToken, then the entire amount is pushed:aaveVault.transferAndPush([1000]). This deposists1000underlying tokens to the Aave lending pool and returnsactualTokenAmounts = [1000]. After that the internal_tvlsvariable is updated with the latest aTokens. This includes the 1000 aTokens just deposited but also the new rebased aToken amounts, the interest the vault received from supplying the tokens since lastupdateTvlscall._tvls = _tvls + interest + 1000 - The LP amount to mint
amountToMintis still calculated on the old cachedtvlmemory variable, i.e., attacker receivesamount / oldTvl = 1000/1000 = 100%of existing LP supply - Attacker withdraws the LP tokens for 50% of the new TVL (it has been updated in
deposit’stransferAndPushcall). Attacker receives50% * _newTvl = 50% * (2,000 + interest) = 1000 + 0.5 * interest. - Attacker makes a profit of
0.5 * interest
Impact
The interest since the last TVL storage update can be stolen as Aave uses rebasing tokens but the tvl is not first recomputed when depositing. If the vaults experience low activity a significant amount of interest can accrue which can all be captured by taking a flashloan and depositing and withdrawing a large amount to capture a large share of this interest
Recommended Mitigation Steps
Update the tvl when depositing and withdrawing before doing anything else.
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
The vault's cached TVL is not updated before calculating LP tokens on deposit, so the deposit uses an outdated value that excludes accrued interest.
Impact
The interest accrued since the last TVL update can be stolen; if the vault has low activity, a significant amount of interest could be captured by using a flashloan to deposit and withdraw a large amount.
What the attacker needed
Vault with accrued interest; attacker can deposit and withdraw; flashloan for large amount
The fix
The TVL should be updated when depositing and withdrawing before any other calculations.
How it was found
- Attacker calls LPIssuer.push with an amount, which loads the old cached TVL without updating it.
- The deposit transfers tokens to Aave and then updates the internal TVL to include the new deposit and accrued interest.
- The LP tokens to mint are calculated using the old cached TVL, giving the attacker a large share of the LP supply.
- Attacker withdraws the LP tokens, receiving a share of the new TVL that includes the interest, resulting in a profit.
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.
The vault keeps a stored number for its total value, but this number is not refreshed when someone puts money in or takes it out. Because the underlying token grows in value over time (interest), an attacker can put money in, force the number to update to include that interest, and then take their money out with extra profit. This is like a bank that forgets to update its balance sheet when you deposit, letting you claim more than you put in.
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.