Golom contest - rokinot'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: 59/179

Findings: 5

Award: $188.25

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Labels

bug
duplicate
3 (High Risk)
edited-by-warden

Awards

131.6127 USDC - $131.61

External Links

Lines of code

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L98-L103

Vulnerability details

Impact

The addFee() function will stop executing any meaningful action at the contract's final epoch, final epoch being when the supply hits 1 billion. This is done on purpose in order to allow the golom token to hit it's maximum supply. The traderClaim(), multiStakerClaim() and exchangeClaim() functions allow traders, stakers and exchanges to withdraw their rewards for any epoch save the current or future ones, which means any fee that is paid when the supply achieves the 1 billion mark is locked in the contract. Eth fees paid to the distributor contract will also be stuck as stakers will not be allowed to retrieve them.

Proof of Concept

  • The final epoch is achieved, addFee() does not execute any meaningful action.
  • Person A calls fillAsk(), the 50 basis fee is transferred to the distributor contract
  • The fees are received, but the epoch will not advance anymore.
  • Person B, who is a staker, attempts to claim the current staker reward deposited in the contract, but the transaction reverts due to this line

Tools Used

None

Allow the current epoch rewards to be withdrawn if and only if the supply is greater than one billion.

#0 - 0xsaruman

2022-09-02T11:30:46Z

this is more or less a duplicate of https://github.com/code-423n4/2022-07-golom-findings/issues/320 and gets resolved on fixing the above bug.

Lines of code

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

Vulnerability details

Impact

The transfer() function was introduced after The DAO hack with a hard limit of 2300 gas as a way to safely send ether while also preventing reentrancy attacks. However this limit will also prevent external contracts interacting with the protocol to execute more elaborate operations after filling a bid/ask order.

Proof of Concept

#L154

Tools Used

None

Use the call() function instead, the protocol is secured against reentrancy attacks already as the nonReentrant modifier is deployed at every function with a payEther() interaction.

#0 - KenzoAgada

2022-08-03T14:06:45Z

Duplicate of #343

Lines of code

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

Vulnerability details

Impact

The usage of transferFrom() is discouraged as it lacks some form of check to see if the receiving address, in case it's a smart contract, could properly receive the NFT, resulting in the loss of it.

Tools Used

None

Use the ERC721.safeTransferFrom() method instead.

#0 - KenzoAgada

2022-08-03T15:12:41Z

Duplicate of #342

Low Risk

No check to see if the amount value in fillAsk() or fillBid() is zero

Transactions do not revert with zero amount if they're for ERC1155 types

#L203

Same order can be cancelled multiple times

This can be fixed by adding a variable in the validateOrder() for the first value return, as well as adding a require() statement that the order isn't of type 2.

#L312

The issue can be fixed by changing the weth transfer to this line.

validateOrder() has an impossible to reach if statement

The require() statement on the following code reverts in case the signature is invalid, but the following code has an if statement which is only triggered when the signature is invalid #L177-L180

multiple require() statements have no revert string

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L220 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L285 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L293-L296 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L313 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/core/GolomTrader.sol#L342-L350 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L88 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L144 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L158

Non-critical

Typos

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

Unused mapping

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L66

Incomplete comment

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

require() message has an unclear revert message

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

key functions with missing dev parameters

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L141 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L155

Variables not used outside the scope of the contract should be reduced to private

#L41

Consider switching require() statements for custom errors

There are 32 instances in the code

Cache the epoch variable in order to save gas

#L144 #L158 #L184

++index loop increments are more efficient than index++

https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L180-L210 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L143 https://github.com/code-423n4/2022-07-golom/blob/7bbb55fca61e6bae29e57133c1e45806cbb17aa4/contracts/rewards/RewardDistributor.sol#L157

Variables only modified at the constructor should use the immutable keyword

#L69 #L68

External functions guaranteed to revert when called by invalid addresses should add the payable modifier in order to save gas

#L98 #L285-L311

Update the solidity version

By upgrading to v0.8.15, some small operations become more efficient compared to the 0.8.11 used, such as:

uint256 variable != 0 being cheaper than uint256 variable > 0 comparisons x += y being cheaper than x = x + y

The following operations can be left as unchecked{} as they have no risk of overflow

#L118 #L315 #L157 #L143 #L180-L183 #L226 #L258 #L273

public functions not called in the contract should be changed to external

#L312 #L279 #L203 #L341 #L141 #L155 #L172

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