code-423n4 / 2024-04-panoptic-findings

2 stars 2 forks source link

Return values of `approve()` not checked #565

Open c4-bot-4 opened 2 months ago

c4-bot-4 commented 2 months ago

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/libraries/InteractionHelper.sol#L32-L37

Vulnerability details

Impact

By not checking the return value, operations that should have marked as failed, may potentially go through without actually approving anything.

Proof of Concept

Not all IERC20 implementations revert() when there's a failure in approve(). The function signature has a boolean return value and they indicate errors that way instead.

There are 4 instance of this issue: ```solidity File: libraries/InteractionHelper.sol 32: IERC20Partial(token0).approve(address(sfpm), type(uint256).max); 33: IERC20Partial(token1).approve(address(sfpm), type(uint256).max); 36: IERC20Partial(token0).approve(address(ct0), type(uint256).max); 37: IERC20Partial(token1).approve(address(ct1), type(uint256).max); ``` [32](https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/libraries/InteractionHelper.sol#L32), [33](https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/libraries/InteractionHelper.sol#L33), [36](https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/libraries/InteractionHelper.sol#L36), [37](https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/libraries/InteractionHelper.sol#L37).

Tools Used

Bot

Recommended Mitigation Steps

Make sure the return value is true.

Assessed type

ERC20

Picodes commented 2 months ago

The worst scenario is that the deployment won't work

c4-judge commented 2 months ago

Picodes changed the severity to QA (Quality Assurance)