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 Mar 3, 2024. It is now read-only.
sherlock-admin opened this issue
Aug 30, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
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.buyAmountuint256 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 :
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);
emitFeesTransfered(feeReceiver, amountReceived, fee);
// adjust the amount received after deducting the fee
amountReceived -= fee;
// transfer fee to the fee receiverIERC20(params.buyTokenAddress).safeTransfer(feeReceiver, fee);
}
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
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` labelHighA valid High severity issueRewardA payout will be made for this issue
Angry_Mustache_Man
high
Absence of Approval causes DOS/Revertion at all times
Summary
_performLiquidation
function ofLiquidationRow.sol
is where the actual liquidation process happens and it involves a swapping of tokens usingBaseAsyncSwapper.sol
where "sell tokens" are swapped for "buy tokens". These "buy tokens" received byLiquidationRow.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 toLiquidationRow.sol
which it should, causing reverts at all times.Vulnerability Detail
In
_performLiquidation
function ofLiquidationRow.sol
at :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 ofLiquidationRow.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.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
The text was updated successfully, but these errors were encountered: