code-423n4 / 2022-06-canto-findings

0 stars 0 forks source link

`call()` should be used instead of `transfer()` on an `address payable` #68

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/Plex-Engineer/lending-market/blob/b93e2867a64b420ce6ce317f01c7834a7b6b17ca/contracts/WETH.sol#L31

Vulnerability details

This is a classic Code4rena issue:

Impact

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

  1. The claimer smart contract does not implement a payable function.
  2. The claimer smart contract does implement a payable fallback which uses more than 2300 gas unit.
  3. 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.

Impacted lines:

lending-market/contracts/WETH.sol:31:        payable(msg.sender).transfer(wad);

Recommended Mitigation

I recommend using call() instead of transfer()

nivasan1 commented 2 years ago

duplicate of #14