WithdrawFacet’s withdraw calls native payable.transfer , which can be unusable for DiamondStorage owner contract
The withdraw function in WithdrawFacet uses payable.transfer() to send native tokens, which has a fixed gas limit of 2300 and can fail if the recipient is a contract with a costly fallback. This could cause native token withdrawals to fail, freezing funds if the contract owner is a smart contract.
Submitted by hyh, also found by Dravee, JMukesh, Jujic, peritoflores, shw, sorrynotsorry, and wuwe1
When withdraw function is used with native token it is being handled with a payable.transfer() call.
This is unsafe as transfer has hard coded gas budget and can fail when the user is a smart contract. This way any programmatical usage of WithdrawFacet is at risk. Whenever the user either fails to implement the payable fallback function or cumulative gas cost of the function sequence invoked on a native token transfer exceeds 2300 gas consumption limit the native tokens sent end up undelivered and the corresponding user funds return functionality will fail each time.
WithdrawFacet is a core helper contracts that provides basic withdraw functionality to the system, and this way the impact includes principal funds freeze scenario if the described aspect be violated in the DiamondStorage.contractOwner code.
Marking the issue as a medium severity as this is a fund freeze case, but limited to the incorrect contractOwner implementation.
Proof of Concept
When WithdrawFacet’s withdraw is called with _assetAddress being equal to NATIVE_ASSET, the native transfer is handled with payable.transfer() mechanics:
WithdrawFacet is a part of EIP-2535 setup:
Li.Fi Diamond Helper Contracts
References
The issues with transfer() are outlined here:
Stop Using Solidity’s transfer() Now
Recommended Mitigation Steps
As withdraw is runnable by the DiamondStorage.contractOwner only the reentrancy isn’t an issue and transfer() can be just replaced.
Using low-level call.value(amount) with the corresponding result check or using the OpenZeppelin’s Address.sendValue is advised:
H3xept (Li.Fi) resolved and commented:
Fixed in lifinance/lifi-contracts@274a41b047b3863d9ae232eefea04896dc32d853
Sponsor confirmed with fix.
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() method, which forwards a fixed 2300 gas stipend, instead of a low-level call with gas forwarding.
Impact
Native token withdrawals could fail and freeze principal funds if the contract owner is a smart contract that cannot accept transfers with 2300 gas.
What the attacker needed
Contract owner is a smart contract; owner's fallback needs >2300 gas or is missing
The fix
The transfer() call should be replaced with a low-level call.value(amount) with a result check or OpenZeppelin's Address.sendValue; the report states it was fixed.
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 cryptocurrency to another contract, it uses a function called transfer that only provides a small, fixed amount of gas (the fee for computation). If the receiving contract needs more gas to accept the payment, the transfer fails and the money is not sent. Here, the withdraw function uses this risky method, so if the owner is a contract that needs more gas, withdrawals could get 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.