Golom contest - Noah3o6's results

An NFT marketplace that offers the lowest industry fee, a publicly available order-book along with analytical tools.

General Information

Platform: Code4rena

Start Date: 26/07/2022

Pot Size: $75,000 USDC

Total HM: 29

Participants: 179

Period: 6 days

Judge: LSDan

Total Solo HM: 6

Id: 148

League: ETH

Golom

Findings Distribution

Researcher Performance

Rank: 167/179

Findings: 2

Award: $21.32

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Lines of code

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L154

Vulnerability details

Impact

The use of the deprecated transfer() function for an address will inevitably make the transaction fail when:

-The claimer smart contract does not implement a payable function. -The claimer smart contract does implement a payable fallback which uses more than 2300 gas unit. -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.

Proof of Concept

I am not 100% clear about this, but i saw it in an other report from a contest before https://code4rena.com/reports/2022-04-backd/#m-01-call-should-be-used-instead-of-transfer-on-an-address-payable

Tools Used

No tools used for this

I recommend using call() instead of transfer().

#0 - KenzoAgada

2022-08-03T14:06:25Z

Duplicate of #343

-> X = X + Y IS CHEAPER THAN X += Y (Same for X = X - Y is cheaper than X -= Y)

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/TokenUriHelper.sol#:~:text=digits-,%2D%3D,-1%3B

->STATE VARIABLES ONLY SET IN THE CONSTRUCTOR SHOULD BE DECLARED IMMUTABLE Avoids a Gsset (20000 gas) in the constructor, and replaces each Gwarmacces (100 gas) with a PUSH32 (3 gas)

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=bytes32%20public-,immutable,-EIP712_DOMAIN_TYPEHASH%3B

-> COMPARISON OPERATORS Problem

In the EVM, there is no opcode for >= or <=. When using greater than or equal, two operations are performed: > and =. Using strict comparison operators hence saves gas

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/governance/GolomToken.sol#:~:text=require(minterEnableDate-,%3C%3D,-block.timestamp

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowDelegation.sol#:~:text=1%5D.fromBlock-,%3C%3D,-blockNumber)%20%7B

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=require(-,o.totalAmt%20%3E%3D%20o.exchange.paymentAmt,-%2B%20o.prePayment.paymentAmt%20%2B%20o.refererrAmt%20%2B

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=msg.value-,%3E%3D,-o.totalAmt%20*

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=require(amountRemaining-,%3E%3D,-amount%2C%20%27order

-> ++i costs less gas compared to i++ or i += 1 (Also --i costs less gas compared to i--- or i -= 1)

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowDelegation.sol#:~:text=delegatednft.length%3B-,index%2B%2B,-)%20%7B

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowDelegation.sol#:~:text=_array.length%3B-,i%2B%2B,-)%20%7B

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=proof.length%3B-,i%2B%2B),-%7B

->SPLITTING REQUIRE() STATEMENTS THAT USE && SAVES GAS

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowDelegation.sol#:~:text=require(attachments%5B_tokenId%5D%20%3D%3D%200%20%26%26%20!voted%5B_tokenId%5D%2C%20%27attached%27)%3B

-> require()/revert() strings longer than 32 bytes cost extra gas

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/governance/GolomToken.sol#:~:text=%27GolomToken%3A%20only%20reward%20distributor%20can%20enable%27

-> Usage of Units/Uints smaller than 32Byte (256Bits) incurs overhead

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#:~:text=timestamp%20in%20secs-,uint8%20v%3B,-bytes32%20r%3B

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowCore.sol#:~:text=dev%20reentrancy%20guard-,uint8,-internal%20constant%20_not_entered

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowCore.sol#:~:text=%3D%201%3B-,uint8,-internal%20constant%20_entered

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/vote-escrow/VoteEscrowCore.sol#:~:text=%3D%202%3B-,uint8,-internal%20_entered_state%20%3D

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter