Forgeries contest - Apocalypto's results

A protocol for on-chain games with NFT prizes on Ethereum.

General Information

Platform: Code4rena

Start Date: 13/12/2022

Pot Size: $36,500 USDC

Total HM: 5

Participants: 77

Period: 3 days

Judge: gzeon

Total Solo HM: 1

Id: 191

League: ETH

Forgeries

Findings Distribution

Researcher Performance

Rank: 18/77

Findings: 2

Award: $129.49

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

19.2206 USDC - $19.22

Labels

bug
3 (High Risk)
satisfactory
upgraded by judge
edited-by-warden
duplicate-146

External Links

Lines of code

https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L83-L88 https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L159 https://github.com/code-423n4/2022-12-forgeries/blob/main/src/VRFNFTRandomDraw.sol#L314-L317

Vulnerability details

Impact

Settings variable drawBufferTime represents the buffer time that forbids owner to trigger redraw and thus allows winner to claim the reward NFT via winnerClaimNFT function. There is also another recoverTimelock settings variable that defines time when the owner can reclaim the reward NFT via lastResortTimelockOwnerClaimNFT. The issue is that drawBufferTime and recoverTimelock are not correctly checked which leads to situation that both triggering winnerClaimNFT and lastResortTimelockOwnerClaimNFT is possible.

Example 1:

  1. Draw is initialized with:
    • drawBufferTime 1 month
    • recoverTimeLock 1 week
  2. startDraw() is called by the owner
    • drawTimeLock is set to the next month
    • recoverTimeLock is always set to 1 week
  3. Winner thinks that he has 1 month to claim the reward NFT, but after 1 week owner withdraws NFT not letting the winner to claim the reward.

The issue is also present in case there are multiple redraws (via redraw function) that lead to expiration of recoverTimeLock which allows owner to trigger lastResortTimelockOwnerClaimNFT function.

Proof of Concept

It is recommended to set drawBufferTime and recoverTimeLock to values that will hold relationship recoverTimeLock = block.timestamp + drawBufferTime + X. In addition value of recoverTimeLock should be set properly in every _requestRoll function execution. Disallow owner to withdraw the NFT before the drawTimelock is expired.

#0 - c4-judge

2022-12-17T16:09:24Z

gzeon-c4 marked the issue as duplicate of #146

#1 - c4-judge

2023-01-23T16:53:11Z

gzeon-c4 marked the issue as satisfactory

#2 - c4-judge

2023-01-23T17:09:34Z

gzeon-c4 changed the severity to 3 (High Risk)

Findings Information

Labels

bug
2 (Med Risk)
satisfactory
duplicate-273

Awards

110.2711 USDC - $110.27

External Links

Lines of code

https://github.com/code-423n4/2022-12-forgeries/blob/fc271cf20c05ce857d967728edfb368c58881d85/src/VRFNFTRandomDraw.sol#L33

Vulnerability details

Impact

Immutable variable MONTH_IN_SECONDS is assigned with incorrect value. It is expected to represent 30 days but it is set to 30 weeks:

uint256 immutable MONTH_IN_SECONDS = (3600 * 24 * 7) * 30;

Proof of Concept

VRFNFTRandomDraw.sol:

Tools Used

Manual Review

It is recommended to assign correct value of 30 days to MONTH_IN_SECONDS variable:

uint256 immutable MONTH_IN_SECONDS = (3600 * 24) * 30;

#0 - c4-judge

2022-12-17T12:53:28Z

gzeon-c4 marked the issue as duplicate of #273

#1 - c4-judge

2022-12-17T12:53:56Z

gzeon-c4 marked the issue as satisfactory

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