Skip to content
Smart contracts Audit finding Intermediate

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

The smart contract uses the deprecated transfer() function to send Ether, which forwards only 2300 gas. If the recipient is a smart contract with a fallback that needs more gas, the transfer fails, potentially locking funds or breaking the protocol.

BowTiedWardens Follow

Originally disclosed on Code4rena

Submitted by BowTiedWardens, also found by leastwood and sorrynotsorry

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

CEther.sol:167:        to.transfer(amount);

Recommended Mitigation Steps

Use call() instead of transfer(), but be sure to implement CEI patterns in CEther and add a global state lock on the comptroller as per Rari.

THIS HAS REKT COMPOUND FORKS BEFORE!!!

Relevant links: https://twitter.com/hacxyk/status/1520715516490379264?s=21&t=fnhDkcC3KpE_kJE8eLiE2A https://twitter.com/hacxyk/status/1520715536325218304?s=21&t=fnhDkcC3KpE_kJE8eLiE2A https://twitter.com/hacxyk/status/1520370441705037824?s=21&t=fnhDkcC3KpE_kJE8eLiE2A https://twitter.com/Hacxyk/status/1521949933380595712

bunkerfinance-dev (bunker.finance) acknowledged and commented:

We agree that this can make the protocol hard to use if the claimer is a smart contract. This bug needs to be fixed with great care, so we will hold off on fixing this for now.


The original report as published on Code4rena, by BowTiedWardens. 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 the deprecated transfer() function, which forwards a fixed 2300 gas stipend, instead of call() which allows specifying gas.

What the attacker needed

Recipient is a smart contract; fallback needs >2300 gas or uses proxy

The fix

Use call() instead of transfer(), and implement checks-effects-interactions and a global state lock to prevent reentrancy.

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 using transfer(), it only gives the recipient a tiny fixed amount of gas (2300). If the recipient is another contract that needs more gas to accept the payment, the whole transaction fails. This can trap funds or stop the protocol from working for certain users.

What is Smart contracts?

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

More by BowTiedWardens

View all

3 more disclosed reports, best first.

More from bunker.finance 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.