code-423n4 / 2022-05-backd-findings

0 stars 0 forks source link

call() should be used instead or transfer() on an address payable #177

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/swappers/SwapperRouter.sol#L280

Vulnerability details

This is a classic Code4rena issue:

https://github.com/code-423n4/2021-04-meebits-findings/issues/2 https://github.com/code-423n4/2021-10-tally-findings/issues/20 https://github.com/code-423n4/2022-01-openleverage-findings/issues/75

Impact

The use of the deprecated transfer() function for an address will inevitably make the transaction fail when:

The claimer smart contract does not implement a payable function. The claimer smart contract does implement a payable fallback which uses more than 2300 gas unit. The claimer smart contract implements a payable fallback function that needs less than 2300 gas units but is called through proxy, raising the call’s gas usage above 2300. Additionally, using higher than 2300 gas might be mandatory for some multisig wallets.

Proof of Concept

https://github.com/code-423n4/2022-01-openleverage-findings/issues/75

Tools Used

Recommended Mitigation Steps

/swappers/SwapperRouter.sol 140: payable(msg.sender).transfer(amountIn); 280: payable(msg.sender).transfer(amount);

I recommend using call() instead of transfer().

ps: this file is probably out of scope but I prefer to mention this issue nonetheless.

chase-manning commented 2 years ago

Duplicate of #180

GalloDaSballo commented 2 years ago

Dup of #180