Lien buyout with new terms does not update the slope of public vaults
When a lien is bought out with new terms, the slope of the associated public vault is not updated to reflect the changed lien terms. This can cause liquidations involving the public vault to revert and lead to incorrect vault share calculations due to an outdated slope value.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/180
Found by
0xRajeev
Summary
Lien buyout with new terms does not update the slope of public vaults leading to reverts and potential insolvency of vaults.
Vulnerability Detail
In the VaultImplementation.buyoutLien function, a lien is bought out with new terms. Terms of a lien (last, start, rate, duration) will have changed after a buyout. This changes the slope calculation, however, after the buyout, the slope for the public vault is not updated.
Impact
There are multiple parts of the code affected by this.
-
When liquidating, the vault slope is adjusted by the liens slope (see https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/AstariaRouter.sol#L385-L387). In case of a single lien, the PublicVault.updateVaultAfterLiquidation function can revert if the lien terms have changed previously due to a buyout (https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/PublicVault.sol#L532). Hence, liquidations with a public vault involved, will revert.
-
The PublicVault contract calculates the implied value of a vault (ie. totalAssets) with the use of the slope value (see https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/PublicVault.sol#L412). As the slope value can be outdated, this leads to undervalue or overvalue of a public vault and thus vault share calculations will be incorrect.
Code Snippet
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/VaultImplementation.sol#L280-L304
- https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L150-L153
Tool used
Manual Review
Recommendation
Calculate the slope of the lien before the buyout in the VautImplementation.buyoutLien function, subtract the calculated slope value from PublicVault.slope, update lien terms, recalculate the slope and add the new updated slope value to PublicVault.slope.
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 buyout function updates the lien terms but fails to adjust the public vault's slope accordingly.
Impact
Liquidations involving a public vault can revert, and vault share calculations may be incorrect due to undervaluation or overvaluation, potentially leading to insolvency.
What the attacker needed
A lien exists; lien is bought out with new terms; public vault involved
The fix
The slope of the lien should be calculated before the buyout, subtracted from the public vault's slope, then after updating the lien terms, the new slope should be recalculated and added back.
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 public vault tracks how much interest it should earn over time using a number called the slope. When a loan (lien) is bought out with new terms, the slope should change, but the vault's stored slope is not updated. This means later calculations, like liquidations or share pricing, use the wrong number and can fail or give incorrect results.
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.