Skip to content
Smart contracts Audit finding Intermediate

Eth may get stuck in contract

The contract uses `transfer()` to send Ether, which forwards a fixed 2300 gas. After the Istanbul hardfork increased the gas cost of SLOAD, this fixed amount may be insufficient if the recipient is a contract, causing Ether to become stuck.

FairSide contest

Originally disclosed on Code4rena

The Istanbul hardfork increases the gas cost of the SLOAD operation and therefore breaks some existing smart contracts.

In file withdrawable.sol, contract uses transfer() to send eth from contract to EOA due which eth can get stuck.

The reason behind this is that, after the Istanbul hardfork, any smart contract that uses transfer() or send() is taking a hard dependency on gas costs by forwarding a fixed amount of gas (2300). This forwards 2300 gas, which may not be enough if the recipient is a contract and the cost of gas changes.

Recommend using call() to send eth.

fairside-core (FairSide) confirmed (separately in issue #67):

Although I am fine with the severity, perhaps it may not be applicable given that even after EIP-3074, transfers will not fail with proper access lists, and I highly doubt the transfer method will fail to work altogether anytime soon.

Fixed in PR#8.

The original report as published on Code4rena. 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

The contract uses `transfer()` which forwards a fixed 2300 gas, and this amount may be insufficient after gas cost changes.

Impact

Ether sent by the contract could become stuck if the recipient is a contract that requires more than 2300 gas to accept the transfer.

What the attacker needed

Recipient is a contract; recipient's fallback needs >2300 gas

The fix

The contract should be fixed by using `call()` to send Ether instead of `transfer()`.

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 also gives that contract a small amount of gas to run code. The `transfer()` function always gives exactly 2300 gas. After a network upgrade called Istanbul, some basic operations became more expensive, so 2300 gas might not be enough. If the recipient runs out of gas, the transfer fails and the Ether stays stuck in the sender contract.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from FairSide contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.