Public vault depositors will receive fewer vault shares until the first payment
The public vault's total asset calculation is incorrect until the first payment, causing depositors to receive fewer vault shares than expected. This happens because the total assets are based on the current ERC-20 balance, which is reduced by borrowed amounts.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/173
Found by
0xRajeev
Summary
Public vault total asset calculation is incorrect until the first payment, leading to depositors receiving fewer vault shares than expected.
Vulnerability Detail
As long as PublicVault.last is set to 0, the PublicVault.totalAssets function returns the actual ERC-20 token balance (WETH) of the public vault. Due to borrowing, this balance is reduced by the borrowed amount. Therefore, as there is no payment, this leads to depositors receiving fewer vault shares than expected.
Impact
PoC: https://gist.github.com/berndartmueller/8a71ff76c7eb8207e1f01a154a873b2c
Public vault depositors will receive fewer vault shares until the first payment.
Code Snippet
Tool used
Manual Review
Recommendation
Revisit the logic behind updating last when yIntercept and/or slope are updated.
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 total assets calculation uses the vault's current token balance instead of accounting for outstanding loans when the last payment timestamp is zero.
What the attacker needed
Public vault with no payments yet; borrowed funds reduce vault balance
The fix
The logic behind updating `last` when `yIntercept` and/or `slope` are updated should be revisited.
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.
When you deposit money into a vault, you get shares representing your portion. The vault's total value is used to decide how many shares you get. Here, the vault's value was calculated wrongly because it didn't account for money that had been lent out, so new depositors got fewer shares than they should.
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.