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.
When WithdrawFacets withdraw is called with _assetAddress being equal to NATIVE_ASSET, the native transfer is handled with payable.transfer() mechanics:
WithdrawFacet.sol#L28-L31
WithdrawFacet is a part of EIP-2535 setup:
Li.Fi Diamond Helper Contracts
The issues with transfer() are outlined here:
Stop Using Soliditys transfer() Now
As withdraw is runnable by the DiamondStorage.contractOwner only the reentrancy isnt an issue and transfer() can be just replaced.
Using low-level call.value(amount) with the corresponding result check or using the OpenZeppelins Address.sendValue is advised:
Address.sol#L60
H3xept (Li.Fi) resolved and commented:
gzeon (judge) commented:
For this contest, 42 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by hake received the top score from the judge.
The following wardens also submitted reports: defsec, rayn, hyh, saian, CertoraInc, SolidityScan, 0xDjango, hickuphh3, 0v3rf10w, catchup, IllIllI, kenta, PPrieditis, BouSalman, sorrynotsorry, Dravee, Picodes, VAD37, dimitri, Hawkeye, robee, shenwilly, WatchPug, ych18, 0xkatana, obront, PranavG, aga7hokakological, Jujic, kirk-baird, csanuragjain, cthulhu_cult, hubble, JMukesh, Kenshin, peritoflores, Ruhum, samruna, shw, tchkvsky, and teryanarmen.
