Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

0x52 - Blacklisted creditor can block all repayment besides emergency closure #83

Open
sherlock-admin opened this issue Oct 23, 2023 · 2 comments
Assignees
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Oct 23, 2023

0x52

medium

Blacklisted creditor can block all repayment besides emergency closure

Summary

After liquidity is restored to the LP, accumulated fees are sent directly from the vault to the creditor. Some tokens, such as USDC and USDT, have blacklists the prevent users from sending or receiving tokens. If the creditor is blacklisted for the hold token then the fee transfer will always revert. This forces the borrower to defualt. LPs can recover their funds but only after the user has defaulted and they request emergency closure.

Vulnerability Detail

https://github.com/sherlock-audit/2023-10-real-wagmi/blob/main/wagmi-leverage/contracts/abstract/LiquidityManager.sol#L306-L315

        address creditor = underlyingPositionManager.ownerOf(loan.tokenId);
        // Increase liquidity and transfer liquidity owner reward
        _increaseLiquidity(cache.saleToken, cache.holdToken, loan, amount0, amount1);
        uint256 liquidityOwnerReward = FullMath.mulDiv(
            params.totalfeesOwed,
            cache.holdTokenDebt,
            params.totalBorrowedAmount
        ) / Constants.COLLATERAL_BALANCE_PRECISION;

        Vault(VAULT_ADDRESS).transferToken(cache.holdToken, creditor, liquidityOwnerReward);

The following code is executed for each loan when attempting to repay. Here we see that each creditor is directly transferred their tokens from the vault. If the creditor is blacklisted for holdToken, then the transfer will revert. This will cause all repayments to revert, preventing the user from ever repaying their loan and forcing them to default.

Impact

Borrowers with blacklisted creditors are forced to default

Code Snippet

LiquidityManager.sol#L223-L321

Tool used

Manual Review

Recommendation

Create an escrow to hold funds in the event that the creditor cannot receive their funds. Implement a try-catch block around the transfer to the creditor. If it fails then send the funds instead to an escrow account, allowing the creditor to claim their tokens later and for the transaction to complete.

@github-actions github-actions bot added Medium A valid Medium severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Oct 26, 2023
@fann95 fann95 added Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Oct 30, 2023
@fann95 fann95 self-assigned this Oct 30, 2023
@sherlock-admin sherlock-admin changed the title Ancient Malachite Jay - Blacklisted creditor can block all repayment besides emergency closure 0x52 - Blacklisted creditor can block all repayment besides emergency closure Oct 30, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Oct 30, 2023
@fann95
Copy link

fann95 commented Nov 2, 2023

Fixed: RealWagmi/wagmi-leverage@3c17a39

@IAm0x52
Copy link

IAm0x52 commented Nov 17, 2023

Fix looks good. Fee collection has been made generic instead of specific to protocol fees. Creditor fees are now cached and collected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

3 participants