Wenwin contest - martin's results

The next generation of chance-based gaming.

General Information

Platform: Code4rena

Start Date: 06/03/2023

Pot Size: $36,500 USDC

Total HM: 8

Participants: 93

Period: 3 days

Judge: cccz

Total Solo HM: 3

Id: 218

League: ETH

Wenwin

Findings Distribution

Researcher Performance

Rank: 57/93

Findings: 1

Award: $21.70

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

21.7018 USDC - $21.70

Labels

bug
grade-b
QA (Quality Assurance)
sponsor confirmed
Q-19

External Links

Introduction

Wenwin QA report was done by martin, with a main focus on the low severity and non-critical security aspects of the implementaion and logic of the project.

Findings Summary

The following issues were found, categorized by their severity:

L-01 _safeMint() should be used rather than _mint() wherever possible

When minting NFTs, the code uses _safeMint function of the OZ reference implementation. This function is safe because it checks whether the receiver can receive ERC721 tokens. The can prevent the case that a NFT will be minted to a contract that cannot handle ERC721 tokens. However, this external function call creates a security loophole. Specifically, the attacker can perform a reentrant call inside the onERC721Received callback. More detailed information why a reeentrancy can occur - https://blocksecteam.medium.com/when-safemint-becomes-unsafe-lessons-from-the-hypebears-security-incident-2965209bda2a.

74: _mint(msg.sender, amount);

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/staking/Staking.sol

19:  _mint(msg.sender, INITIAL_SUPPLY);

26: _mint(account, amount);

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/LotteryToken.sol

L-02 revert() should be used instead of assert()

The comment above clarifies that it must hold after this call, in such case it's better to add the check and revert providing a description of necessary.

147: assert(initialPot > 0);

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/LotterySetup.sol

L-03 ClaimedRewards event is called early

Event is actually emit before the action, event emits should be moved after the action. Otherwise it might cause incorrectly emitted event.

155: emit ClaimedRewards(beneficiary, claimedAmount, rewardType);

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/Lottery.sol

L-04 Misleading function

Should be a modifier instead.

279: function requireFinishedDraw(uint128 drawId) internal view override {

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/Lottery.sol

N-01 Use a more recent version of solidity

Using a floating pragma statement is discouraged as code can compile to different bytecodes with different compiler versions. Use a stable pragma statement to get a deterministic bytecode. Also use the latest Solidity version in all files if possible to get all compiler features, bugfixes, and optimizations.

N-02 Not using the named return variables anywhere in the function is confusing

Consider changing the variable to be an unnamed one

120: function fixedReward(uint8 winTier) public view override returns (uint256 amount) {

https://github.com/code-423n4/2023-03-wenwin/blob/main/src/LotterySetup.sol

N-03 Missing NatSpec

Add NatSpec docs for all external functions so their intentions are clear.

#0 - thereksfour

2023-03-12T09:41:53Z

1 L 2 INFO 4 NC

#1 - c4-judge

2023-03-12T09:42:03Z

thereksfour marked the issue as grade-c

#2 - c4-judge

2023-03-12T11:45:46Z

thereksfour marked the issue as grade-b

#3 - c4-sponsor

2023-03-14T10:26:05Z

0xluckydev marked the issue as sponsor confirmed

#4 - 0xluckydev

2023-03-14T10:26:09Z

Low

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