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

Angry_Mustache_Man - Absence of Approval causes DOS/Revertion at all times #654

Closed
sherlock-admin opened this issue Aug 30, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Aug 30, 2023

Angry_Mustache_Man

high

Absence of Approval causes DOS/Revertion at all times

Summary

_performLiquidation function of LiquidationRow.sol is where the actual liquidation process happens and it involves a swapping of tokens using BaseAsyncSwapper.sol where "sell tokens" are swapped for "buy tokens". These "buy tokens" received by LiquidationRow.sol is further used to pay fees and for other purposes. But after the swapping , BaseAsyncSwapper.sol contract doesn't send back the "buy tokens" back to LiquidationRow.sol which it should, causing reverts at all times.

Vulnerability Detail

In _performLiquidation function of LiquidationRow.sol at :

        // the swapper checks that the amount received is greater or equal than the params.buyAmount
        uint256 amountReceived = IAsyncSwapper(asyncSwapper).swap(params);

swapping happens where "sell tokens" are swapped for "buy tokens". Now looking into BaseAsyncSwapper.sol contract (which is used for swapping) , we see :

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/liquidation/BaseAsyncSwapper.sol#L19-#L64

after swapping , the buy tokens are neither send back to nor any approval is given to LiquidationRow.sol .
In the next step after swapping in _performLiquidation function of LiquidationRow.sol , we can see that the function performs a transfer of "buy tokens"[transferring fees(which is in buy token) to feeReceiver ] , which will fail at almost all times causing DOS.

        if (feeReceiver != address(0) && feeBps > 0) {
            uint256 fee = calculateFee(amountReceived);
            emit FeesTransfered(feeReceiver, amountReceived, fee);

            // adjust the amount received after deducting the fee
            amountReceived -= fee;
            // transfer fee to the fee receiver
            IERC20(params.buyTokenAddress).safeTransfer(feeReceiver, fee);
        }

Impact

DOS/ Revertion at all times

Code Snippet

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/liquidation/LiquidationRow.sol#L251

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/liquidation/BaseAsyncSwapper.sol#L19-#L64

https://github.com/sherlock-audit/2023-06-tokemak/blob/main/v2-core-audit-2023-07-14/src/liquidation/LiquidationRow.sol#L254-#L262

Tool used

Manual Review

Recommendation

Either do an approval and have the "buy tokens" pulled to LiquidationRow.sol or do a delegatecall to swap contract.

Duplicate of #205

@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Sep 11, 2023
@sherlock-admin2 sherlock-admin2 changed the title Fresh Cornflower Ostrich - Absence of Approval causes DOS/Revertion at all times Angry_Mustache_Man - Absence of Approval causes DOS/Revertion at all times Oct 3, 2023
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants