Skip to content
DoS Audit finding Intermediate

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.

peritoflores Follow

Originally disclosed on Code4rena

Submitted by peritoflores, also found by JC and StyxRave

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

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

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 reverts

For this reason I agree with Med Severity.


The original report as published on Code4rena, by peritoflores. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by peritoflores

View all

4 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.