code-423n4 / 2024-05-predy-validation

0 stars 0 forks source link

approve()/safeApprove() may revert if the current approval is not zero #617

Closed c4-bot-1 closed 4 months ago

c4-bot-1 commented 4 months ago

Lines of code

https://github.com/code-423n4/2024-05-predy/tree/main/src/settlements/UniswapSettlement.sol#L31 https://github.com/code-423n4/2024-05-predy/tree/main/src/settlements/UniswapSettlement.sol#L47

Vulnerability details

Impact

Calling approve() without first calling approve(0) if the current approval is non-zero will revert with some tokens, such as Tether (USDT). While Tether is known to do this, it applies to other tokens as well, which are trying to protect against this attack vector..

Proof of Concept

File: src/settlements/UniswapSettlement.sol

31:         ERC20(baseToken).approve(address(_swapRouter), amountIn);

47:         ERC20(quoteToken).approve(address(_swapRouter), amountInMaximum);

31, 47

Tools Used

Recommended Mitigation Steps

Always reset the approval to zero before changing it to a new value.

Assessed type

ERC20