Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pablo - User can seize most incentives without participating in activity for protocol. #1010

Open
sherlock-admin2 opened this issue Nov 25, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link

sherlock-admin2 commented Nov 25, 2024

Pablo

High

User can seize most incentives without participating in activity for protocol.

Summary

Attacker can seize most incentives, when acts as both borrower and lender. When attacker makes lend offer with large amount and borrow it, can seize most incentives.

Root Cause

In the DebitaV3Aggregator.sol:274 function, anyone can invoke this funciton. Also borrower and lender can invoke this function. The vulnerability is there is no check for borrower should not be same as lender.

In case of lender acts borrower with large amount, he can seize the most incentives. However, this is profitable when incentives is larger than fee.

In this case, attacker should pay fee at least: 0.2% * (1 - 15%) = 0.17%. Also it is profitable, when attacker can get more incentives than 0.17% of the large amount of token and he can seize most incentives.

All things attacker should do is to make lend offer with 0 day as _minDuration and make borrow offer with 1 day, and then invoke the DebitaV3Aggregator.matchOffersV3() to match borrow offer and lend offer in one transaction.

Internal pre-conditions

When total incentives is high and it is much greater than 0.17% of attacker's collateral.

External pre-conditions

No response

Attack Path

Assume that total incentives is high and it is much greater than 0.17% of attacker's collateral.

  1. Attacker makes a lend offer with large amount of collateral with 0 day of _minDuration and 100% of LTV.
  2. Makes a borrow offer with certain amount of his collateral lent.
  3. Invoke DebitaV3Aggregator.matchOffersV3() function with borrow offer and lend offer. Step 1,2,3 should be excuted in same transaction.
  4. Claim incentive.

Impact

Malicious user can seize most incentives without participating certainly in activity of protocol and protocol can't distribute correct amount of incentives to users.

PoC

No response

Mitigation

Add restriction which borrower should not be same as lender and _minDuration of lendOffer.

     function matchOffersV3(
        address[] memory lendOrders,
        uint[] memory lendAmountPerOrder,
        uint[] memory porcentageOfRatioPerLendOrder,
        address borrowOrder,
        address[] memory principles,
        uint[] memory indexForPrinciple_BorrowOrder,
        uint[] memory indexForCollateral_LendOrder,
        uint[] memory indexPrinciple_LendOrder
    ) external nonReentrant returns (address) {

        ...

    for (uint i = 0; i < lendOrders.length; i++) {
        ...
+       require(borrowInfo.owner != lendInfo.owner, "borrower and lender can't be same")     
        ...
    }

        ...
    }
    function createLendOrder(
        bool _perpetual,
        bool[] memory _oraclesActivated,
        bool _lonelyLender,
        uint[] memory _LTVs,
        uint _apr,
        uint _maxDuration,
        uint _minDuration,
        address[] memory _acceptedCollaterals,
        address _principle,
        address[] memory _oracles_Collateral,
        uint[] memory _ratio,
        address _oracleID_Principle,
        uint _startedLendingAmount
    ) external returns (address) {
        ...
+            require(_minDuration > 86400 * 5, "minDuration is too short");
        ...
    }
@sherlock-admin3 sherlock-admin3 changed the title Original Chili Hare - User can seize most incentives without participating in activity for protocol. Pablo - User can seize most incentives without participating in activity for protocol. Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant