MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Lack of claim period check in claimCut() function

Summary

In the claimCut() function of the Pot contract, there is no enforcement of the 90-day claim period for players to claim their rewards. The function allows players to claim their rewards indefinitely, even after the claim period has expired, which violates the protocol's intended behavior.

Vulnerability Details

The claimCut() function is missing a check to verify whether the 90-day claim period has passed. According to the protocol description, players are only allowed to claim their rewards within 90 days. Once this period has passed, the manager should be able to close the pot, take a cut, and redistribute the remaining rewards to the eligible claimants. However, the current implementation does not prevent players from claiming their rewards after the claim period has expired.

Here’s the relevant portion of the code:

function claimCut() public {
address player = msg.sender;
uint256 reward = playersToRewards[player];
if (reward <= 0) {
revert Pot__RewardNotFound();
}
playersToRewards[player] = 0;
remainingRewards -= reward;
claimants.push(player);
_transferReward(player, reward);
}

Impact

The lack of a time-bound check can lead to the following issues:

  1. Unauthorized Claims Post-Expiration: Players can claim their rewards even after the 90-day claim period has elapsed, which goes against the protocol's intended behavior. This may cause conflicts, especially when the manager attempts to close the pot and redistribute the remaining rewards to claimants.

  2. Potential Manager Exploitation: If a player claims rewards after the claim period has ended, the pool’s remaining rewards calculation that is done in Pot::closePot() can be affected. This may cause inaccurate reward distributions when the manager attempts to take their cut and redistribute the rewards to claimants.

Tools Used

Manual Review

Recommendations

Add a new error:

error Pot__RewardNotFound();
+ error Pot__ClaimPeriodExpired();
error Pot__InsufficientFunds();
error Pot__StillOpenForClaim();

Update the claimCut() function to include the claim period check:

function claimCut() public {
// Check if the 90-day claim period has expired
+ if (block.timestamp - i_deployedAt > 90 days) {
+ revert Pot__ClaimPeriodExpired();
+ }
address player = msg.sender;
uint256 reward = playersToRewards[player];
if (reward <= 0) {
revert Pot__RewardNotFound();
}
playersToRewards[player] = 0;
remainingRewards -= reward;
claimants.push(player);
_transferReward(player, reward);
}
Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.