Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

Rhythmic Bone Boa - Frontrunning permit to DoS repayBorrowWithPermit() #140

Closed
sherlock-admin2 opened this issue Jul 13, 2024 · 3 comments
Closed
Labels
Low/Info A Low/Info severity issue Non-Reward This issue will not receive a payout

Comments

@sherlock-admin2
Copy link
Contributor

Rhythmic Bone Boa

Low/Info

Frontrunning permit to DoS repayBorrowWithPermit()

Summary

An attacker can force the UDai::repayBorrowWithPermit() logic to intentionally fails, causing a temporary DoS.

Root Cause

Its due to permit function is used in conjunction with repay borrow logic(UDai::repayBorrowWithPermit()), since the permit function is permissionless, anyone can call the permit() with given arguments before the repayBorrowWithPermit() function. This cause the second permit txn to fail in repayBorrow logic, as a result, the entire txn reverts.

    function repayBorrowWithPermit(
        address borrower,
        uint256 amount,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external whenNotPaused {
        IDai erc20Token = IDai(underlying);
        erc20Token.permit(msg.sender, address(this), nonce, expiry, true, v, r, s);   // <@ second permit txn . 

        if (!accrueInterest()) revert AccrueInterestFailed();
        uint256 interest = calculatingInterest(borrower);
        _repayBorrowFresh(msg.sender, borrower, decimalScaling(amount, underlyingDecimal), interest);
    }

Impact

Since there are also other way to repay borrowed amount, its not that severe. the user only has to pay extra gas for the revert txn.

PoC

https://github.com/sherlock-audit/2024-06-union-finance-update-2/blob/7ffe43f68a1b8e8de1dfd9de5a4d89c90fd6f710/union-v2-contracts/contracts/market/UDai.sol#L19

Mitigation

Use the external permit call in try/catch to avoid failures.

@ghost
Copy link

ghost commented Jul 20, 2024

Escalate
I submitted as low, should be duplicate of #65

@sherlock-admin4 sherlock-admin4 added the Escalated This issue contains a pending escalation label Jul 20, 2024
@mystery0x
Copy link
Collaborator

This report has been automatically excluded by the bot and did appear in my judging repo.

@WangSecurity
Copy link

Issues that were submitted as low/info initially cannot be Medium or high in any case.

@WangSecurity WangSecurity added Low/Info A Low/Info severity issue and removed Low/Info A Low/Info severity issue labels Jul 27, 2024
@rcstanciu rcstanciu removed the Escalated This issue contains a pending escalation label Jul 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Low/Info A Low/Info severity issue Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

6 participants