You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
sherlock-admin opened this issue
Apr 30, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
Racing condition in between repaying and liquidating a debt when repay was not allowed
Summary
The selected fix to sherlock-audit/2023-02-blueberry-judging#290 was to prevent liquidation when repay is not allowed. This introduces a racing condition when repay is not allowed, positions become liquidateable, and repay is again allowed. Liquidators and position owners will race to repay / liquidate the position.
Vulnerability Detail
Both liquidation and repayment are not allowed when the admin of BlueBerryBank disables repayment:
function liquidate(
uint256positionId,
addressdebtToken,
uint256amountCall
) externaloverride lock poke(debtToken) {
if (!isRepayAllowed()) revert Errors.REPAY_NOT_ALLOWED();
...
}
function repay(
addresstoken,
uint256amountCall
) externaloverride inExec poke(token) onlyWhitelistedToken(token) {
if (!isRepayAllowed()) revert Errors.REPAY_NOT_ALLOWED();
...
}
There is no means to allow repayment and prevent liquidation for a time.
Impact
While repayment is not allowed, positions can become liquidateable. When admin re-enable repayments, the owner of the position risks liquidation without having a chance to repay its position if liquidator are faster to the chain than repayer. This is highly likely as liquidator are probably automated tools while repayers are human users.
Allow reactivation of repayments without activating liquidation to give time to users to repay their position and not be liquidated. Alternatively do not disable repayments.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
cducrest-brainbot
medium
Racing condition in between repaying and liquidating a debt when repay was not allowed
Summary
The selected fix to sherlock-audit/2023-02-blueberry-judging#290 was to prevent liquidation when repay is not allowed. This introduces a racing condition when repay is not allowed, positions become liquidateable, and repay is again allowed. Liquidators and position owners will race to repay / liquidate the position.
Vulnerability Detail
Both liquidation and repayment are not allowed when the admin of
BlueBerryBank
disables repayment:There is no means to allow repayment and prevent liquidation for a time.
Impact
While repayment is not allowed, positions can become liquidateable. When admin re-enable repayments, the owner of the position risks liquidation without having a chance to repay its position if liquidator are faster to the chain than repayer. This is highly likely as liquidator are probably automated tools while repayers are human users.
Code Snippet
https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/BlueBerryBank.sol#L487-L492
https://github.com/sherlock-audit/2023-04-blueberry/blob/96eb1829571dc46e1a387985bd56989702c5e1dc/blueberry-core/contracts/BlueBerryBank.sol#L718-L722
Tool used
Manual Review
Recommendation
Allow reactivation of repayments without activating liquidation to give time to users to repay their position and not be liquidated. Alternatively do not disable repayments.
Duplicate of #117
The text was updated successfully, but these errors were encountered: