Platform: Code4rena
Start Date: 18/10/2022
Pot Size: $75,000 USDC
Total HM: 27
Participants: 144
Period: 7 days
Judge: gzeon
Total Solo HM: 13
Id: 170
League: ETH
Rank: 108/144
Findings: 1
Award: $0.00
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Rolezn
Also found by: 0x1f8b, 0x52, 0x5rings, 0xNazgul, 0xSmartContract, 0xZaharina, 0xhunter, 0xzh, 8olidity, Amithuddar, Aymen0909, B2, Bnke0x0, Chom, Deivitto, Diana, Diraco, Dravee, Franfran, JC, Jeiwan, Josiah, JrNet, Jujic, KingNFT, KoKo, Lambda, Margaret, Migue, Ocean_Sky, PaludoX0, Picodes, Rahoz, RaoulSchaffranek, RaymondFam, RedOneN, ReyAdmirado, Shinchan, Tagir2003, Trust, Waze, Yiko, __141345__, a12jmx, adriro, ajtra, arcoun, aysha, ballx, bin2chen, bobirichman, brgltd, bulej93, catchup, catwhiskeys, caventa, cccz, cdahlheimer, ch0bu, chaduke, chrisdior4, cloudjunky, cryptostellar5, cryptphi, csanuragjain, cylzxje, d3e4, delfin454000, djxploit, durianSausage, erictee, fatherOfBlocks, francoHacker, gianganhnguyen, gogo, hansfriese, i_got_hacked, ignacio, imare, karanctf, kv, leosathya, louhk, lukris02, lyncurion, m_Rassska, malinariy, martin, mcwildy, mics, minhtrng, nicobevi, oyc_109, pashov, peanuts, pedr02b2, peiw, rbserver, ret2basic, rotcivegaf, rvierdiiev, ryshaw, sakman, sakshamguruji, saneryee, securerodd, seyni, sikorico, svskaushik, teawaterwire, tnevler, w0Lfrum
0 USDC - $0.00
https://github.com/code-423n4/2022-10-holograph/blob/main/contracts/HolographOperator.sol#L596
The transfer()
function only provides a stipend for the recipient to use of 2300 gas. If the recipient uses more than that, transfers will fail. For longevity, and especially for a project of Holograph’s nature it is better to use call()
rather than transfer()
to ensure that future gas increases won’t affect ETH transfers.
The transfer()
function can fail for a number of reasons;
Additionally, using higher than 2300 gas might be mandatory for some multi-sig wallets.
The following git diff demonstrates how call()
can be used instead of transfer()
;
--- a/contracts/HolographOperator.sol +++ b/contracts/HolographOperator.sol @@ -593,7 +593,8 @@ contract HolographOperator is Admin, Initializable, HolographOperatorInterface { uint256 hlgFee = messagingModule.getHlgFee(toChain, gasLimit, gasPrice); address hToken = _registry().getHToken(_holograph().getHolographChainId()); require(hlgFee < msg.value, "HOLOGRAPH: not enough value"); - payable(hToken).transfer(hlgFee); + (bool success, ) = payable(hToken).call{value: hlgFee}(""); + require(success, "ETH Transfer failed.");
Note call()
introduces the potential for re-entrancy but future proofs ETH transfers into the future in the even that gas usage changes. Functions including call
should follow the Check, Effects, Interactions pattern and or Openzeppelin’s ReentrancyGuard.
#0 - gzeoneth
2022-10-28T09:24:42Z
Duplicate of #33
#1 - gzeoneth
2022-11-21T07:20:30Z
As QA report