Usage of deprecated transfer to send ETH
The contract uses the deprecated transfer function to send ETH, which forwards a fixed gas stipend of 2300. If the recipient is a contract that needs more gas to process the payment, the transfer reverts, causing the swap to fail.
Originally disclosed on Code4rena
Submitted by peritoflores, also found by JC and StyxRave
Impact
Usage of deprecated transfer Swap can revert.
Proof of Concept
The original transfer used to send eth uses a fixed stipend 2300 gas. This was used to prevent reentrancy. However this limit your protocol to interact with others contracts that need more than that to process the transaction.
A good article about that: https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/.
Recommended Mitigation Steps
Used call instead. For example
(bool success, ) = msg.sender.call{amount}("");
require(success, "Transfer failed.");
chase-manning (Backd) confirmed
Alex the Entreprenerd (judge) commented:
While submission is lazy in that it doesn’t show the ways in which it could revert, (for example most of the times even a transfer to a gnosis-safe will not revert as the gas stipend is sufficient)
It’s true that
transfers gas stipend may run out, causing revertsFor this reason I agree with Med Severity.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the use of Solidity's transfer function, which forwards a fixed 2300 gas stipend, instead of call which allows specifying gas.
Impact
Swaps could revert when sending ETH to contracts that require more than 2300 gas, though the judge noted that most transfers, even to a Gnosis Safe, would not revert because the stipend is often sufficient.
What the attacker needed
Recipient is a contract needing >2300 gas
The fix
The transfer should be replaced with a call that forwards sufficient gas and checks the success flag.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a smart contract sends Ether to another contract, it can use a method called transfer. This method only gives the receiving contract a small, fixed amount of gas (a unit of computational effort) to run its code. If the receiver needs more gas than that, the payment fails and the whole transaction is undone.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.