Claiming liquidationAccountant will reduce vault y-intercept by more than the correct amount
The liquidation accountant contract calculates the vault's y-intercept decrease using its balance after funds have already been distributed, so the balance is always zero. This causes the y-intercept to be reduced by the full expected amount instead of the actual shortfall, diluting user shares and siphoning funds.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/48
Found by
obront
Summary
When claim() is called on the Liquidation Accountant, it decreases the y-intercept based on the balance of the contract after funds have been distributed, rather than before. The result is that the y-intercept will be decreased more than it should be, siphoning funds from all users.
Vulnerability Detail
When LiquidationAccountant.sol:claim() is called, it uses its withdrawRatio to send some portion of its earnings to the WITHDRAW_PROXY and the rest to the vault.
After performing these transfers, it updates the vault's y-intercept, decreasing it by the gap between the expected return from the auction, and the reality of how much was sent back to the vault:
PublicVault(VAULT()).decreaseYIntercept(
(expected - ERC20(underlying()).balanceOf(address(this))).mulDivDown(
1e18 - withdrawRatio,
1e18
)
);
This rebalancing uses the balance of the liquidationAccountant to perform its calculation, but it is done after the balance has already been distributed, so it will always be 0.
Looking at an example:
expected = 1 ether(meaning the y-intercept is currently based on this value)withdrawRatio = 0(meaning all funds will go back to the vault)- The auction sells for exactly 1 ether
- 1 ether is therefore sent directly to the vault
- In this case, the y-intercept should not be updated, as the outcome was equal to the expected outcome
- However, because the calculation above happens after the funds are distributed, the decrease equals
(expected - 0) * 1e18 / 1e18, which equalsexpected
That decrease should not happen, and causing problems for the protocol's accounting. For example, when withdraw() is called, it uses the y-intercept in its calculation of the totalAssets() held by the vault, creating artificially low asset values for a given number of shares.
Impact
Every time the liquidation accountant is used, the vault's math will be thrown off and user shares will be falsely diluted.
Code Snippet
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LiquidationAccountant.sol#L62-L97
Tool used
Manual Review
Recommendation
The amount of assets sent to the vault has already been calculated, as we've already sent it. Therefore, rather than the full existing formula, we can simply call:
PublicVault(VAULT()).decreaseYIntercept(expected - balance)
Alternatively, we can move the current code above the block of code that transfers funds out (L73).
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 y-intercept adjustment reads the contract's token balance after the funds have already been transferred out, so the balance is always zero and the decrease is overstated.
Impact
Every time the liquidation accountant is used, the vault's accounting is thrown off and user shares are falsely diluted, siphoning funds from all users.
What the attacker needed
Liquidation accountant is used; claim() is called
The fix
The y-intercept should be decreased by the expected amount minus the balance actually sent to the vault, or the calculation should be moved before the funds are transferred out.
How it was found
- Call claim() on the LiquidationAccountant, which distributes earnings to the withdraw proxy and the vault.
- After the transfers, the contract reads its own token balance, which is now zero.
- It decreases the vault's y-intercept by the full expected amount minus zero, instead of the actual shortfall.
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 vault tracks how much each share is worth using a number called the y-intercept. When an auction sells assets, a separate contract is supposed to adjust that number only if the sale brought back less money than expected. Because it checks the contract's balance after sending the money away, it always sees zero and reduces the value too much, making everyone's shares worth less.
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.