buyoutLien() will cause the vault to fail to processEpoch()
The buyoutLien function transfers a lien to a new owner but fails to decrement the vault's liensOpenForEpoch counter. This can cause processEpoch to fail because it expects the counter to be zero.
Source: https://github.com/sherlock-audit/2022-10-astaria-judging/issues/245
Found by
bin2chen
Summary
LienToken#buyoutLien() did not reduce vault#liensOpenForEpoch when vault#processEpoch()will check vault#liensOpenForEpoch[currentEpoch] == uint256(0) so processEpoch() will fail
Vulnerability Detail
when create LienToken , vault#liensOpenForEpoch[currentEpoch] will ++ when repay or liquidate , vault#liensOpenForEpoch[currentEpoch] will -- and LienToken#buyoutLien() will transfer from vault to to other receiver,so liensOpenForEpoch need reduce
function buyoutLien(ILienToken.LienActionBuyout calldata params) external {
....
/**** tranfer but not liensOpenForEpoch-- *****/
_transfer(ownerOf(lienId), address(params.receiver), lienId);
}
Impact
processEpoch() maybe fail
Code Snippet
https://github.com/sherlock-audit/2022-10-astaria/blob/main/src/LienToken.sol#L121
Tool used
Manual Review
Recommendation
function buyoutLien(ILienToken.LienActionBuyout calldata params) external {
....
+ //do decreaseEpochLienCount()
+ address lienOwner = ownerOf(lienId);
+ bool isPublicVault = IPublicVault(lienOwner).supportsInterface(
+ type(IPublicVault).interfaceId
+ );
+ if (isPublicVault && !AUCTION_HOUSE.auctionExists(collateralId)) {
+ IPublicVault(lienOwner).decreaseEpochLienCount(
+ IPublicVault(lienOwner).getLienEpoch(lienData[lienId].start + lienData[lienId].duration)
+ );
+ }
lienData[lienId].last = block.timestamp.safeCastTo32();
lienData[lienId].start = block.timestamp.safeCastTo32();
lienData[lienId].rate = ld.rate.safeCastTo240();
lienData[lienId].duration = ld.duration.safeCastTo32();
_transfer(ownerOf(lienId), address(params.receiver), lienId);
}
Discussion
IAmTurnipBoy
Escalate for 1 USDC
Duplicate of #194, two sides of the same coin. One points out it that buyout doesn't decrement correctly on one side and the other points out it doesn't increment correctly on the other side
sherlock-admin
Escalate for 1 USDC
Duplicate of #194, two sides of the same coin. One points out it that buyout doesn't decrement correctly on one side and the other points out it doesn't increment correctly on the other side
You've created a valid escalation for 1 USDC!
To remove the escalation from consideration: Delete your comment. To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Evert0x
Escalation rejected.
The argument is not giving us full conviction this should be tagged as a duplicate.
sherlock-admin
Escalation rejected.
The argument is not giving us full conviction this should be tagged as a duplicate.
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
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 buyoutLien function transfers the lien without calling decreaseEpochLienCount to update the vault's liensOpenForEpoch counter.
Impact
processEpoch() may fail, preventing the vault from processing the epoch.
What the attacker needed
A lien exists in a public vault; buyoutLien is called
The fix
The buyoutLien function should be modified to call decreaseEpochLienCount on the vault when a lien is bought out, as shown in the recommendation.
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 keeps a count of how many liens are open in each epoch. When a lien is bought out, ownership changes but the count is not reduced. Later, when the vault tries to process the epoch, it checks that the count is zero and fails because the count is too high.
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.