instead of call() , transfer() is used to withdraw the ether
The withdraw function sends Ether using transfer(), which forwards a fixed 2300 gas stipend. A contract-based withdrawer whose fallback needs more gas, or is called through a proxy, cannot receive its funds, so the withdrawal reverts and the Ether stays locked.
Larva Labs Meebits
Originally disclosed on Code4rena
function withdraw(uint amount) external {
require(amount <= ethBalance[msg.sender]);
ethBalance[msg.sender] = ethBalance[msg.sender].sub(amount);
msg.sender.transfer(amount);
emit Withdraw(msg.sender, amount);
}
To withdraw ETH, it uses transfer(), this transaction will fail inevitably when:
- The withdrawer smart contract does not implement a payable function.
- Withdrawer smart contract does implement a payable fallback which uses more than 2300 gas unit.
- The withdrawer 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.
Recommend using call() to send ETH.
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 transfer(), which hard-codes a 2300 gas stipend, instead of call() with an explicit gas allowance.
Impact
Contract-based users whose fallback needs more than 2300 gas, or is reached through a proxy, cannot withdraw their Ether, so funds could become locked.
What the attacker needed
Withdrawer is a smart contract; fallback needs over 2300 gas or uses a proxy
The fix
It should be fixed by replacing transfer() with call() and handling the returned success value.
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, the receiving contract can run code to accept the payment. The transfer() function only gives that code a tiny fixed amount of gas, so if the receiver needs to do anything more than the simplest step, the payment fails. Here the sender's balance is reduced first, so the money is effectively stuck.
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.