Submitted by cccz, also found by Jeiwan, 0xbepresent, and chaduke
Vault A can call buyoutLien to buy out Vault Bs lien tokens, which calls LienToken.buyoutLien
In LienToken.buyoutLien, it will burn Vault Bs lien token and mint a new lien token for Vault A
And, when Vault B is a public vault, the handleBuyoutLien function of Vault B will be called to decrease liensOpenForEpoch.
However, when Vault A is a public vault, it does not increase the liensOpenForEpoch of Vault A.
Since the liensOpenForEpoch of the public vault decreases when the lien token is repaid, and since the liensOpenForEpoch of public vault A is not increased, then when that lien token is repaid, _payment will fail due to overflow when decreasing the liensOpenForEpoch.
Consider the following case.
As a result, the borrower cannot repay the loan and the borrowers collateral cannot be auctioned off, thus causing the depositor of the public vault to suffer a loss
https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/VaultImplementation.sol#L313-L351
https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/LienToken.sol#L835-L843
https://github.com/code-423n4/2023-01-astaria/blob/1bfc58b42109b839528ab1c21dc9803d663df898/src/PublicVault.sol#L640-L655
In LienToken.buyoutLien, when the caller is a public vault, increase the decreaseEpochLienCount of the public vault.
SantiagoGregory (Astaria) confirmed
