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
Use of Deprecated .transfer() Method in Ether Transfers
Summary
The _transferEtherRewardToCaller function uses the .transfer() method to send Ether to the caller. This method is discouraged because it forwards a fixed amount of gas (2300 gas), which may not be sufficient for the recipient to execute necessary logic upon receiving Ether. This can lead to failed transactions and compatibility issues with smart contract wallets.
Root Cause
Using msg.sender.transfer(amount) imposes a fixed gas stipend, which can cause the Ether transfer to fail if the recipient is a contract that requires more gas to process the transaction. This practice is outdated and can lead to Denial-of-Service (DoS) vulnerabilities.
Handle Failures Gracefully: Ensure the contract handles failed transfers appropriately.
Conclusion
Using .transfer() is outdated and can lead to failed Ether transfers. Switching to .call{value: amount}("") ensures better compatibility and reliability, enhancing the contract's usability and security.
The text was updated successfully, but these errors were encountered:
sherlock-admin2
changed the title
Odd Hotpink Antelope - Use of Deprecated .transfer() Method in Ether Transfers
AdamSzymanski - Use of Deprecated .transfer() Method in Ether Transfers
Oct 28, 2024
AdamSzymanski
Medium
Use of Deprecated
.transfer()
Method in Ether TransfersSummary
The
_transferEtherRewardToCaller
function uses the.transfer()
method to send Ether to the caller. This method is discouraged because it forwards a fixed amount of gas (2300 gas), which may not be sufficient for the recipient to execute necessary logic upon receiving Ether. This can lead to failed transactions and compatibility issues with smart contract wallets.Root Cause
Using
msg.sender.transfer(amount)
imposes a fixed gas stipend, which can cause the Ether transfer to fail if the recipient is a contract that requires more gas to process the transaction. This practice is outdated and can lead to Denial-of-Service (DoS) vulnerabilities.Code Location
MorphoLeverageStrategyExtension.sol
_transferEtherRewardToCaller
Internal Pre-conditions
_transferEtherRewardToCaller
is called to reward the caller.External Pre-conditions
Attack Path
_transferEtherRewardToCaller
being called.Impact
Estimated Loss
No direct financial loss to the contract but potential loss of user trust and decreased usability.
Mitigation
Use
.call{value: amount}("")
: Replace.transfer()
with.call()
to send Ether, forwarding all available gas.Handle Failures Gracefully: Ensure the contract handles failed transfers appropriately.
Conclusion
Using
.transfer()
is outdated and can lead to failed Ether transfers. Switching to.call{value: amount}("")
ensures better compatibility and reliability, enhancing the contract's usability and security.The text was updated successfully, but these errors were encountered: