Issue
The claimAllRewards function allows users to claim all their accumulated rewards in a single transaction:
Problematic Scenario:
High Number of Rewards: If a user has accumulated a large number of rewards, the loop that sums up the total reward value (for loop) can consume a significant amount of gas.
Exceeding Block Gas Limit: The Ethereum network imposes a maximum gas limit per block. If the gas required to process the transaction exceeds this limit, the transaction will fail.
Unclaimable Rewards: Users are unable to claim their rewards, leading to them being effectively locked.
Linear Gas Consumption: The gas cost of the claimAllRewards function increases linearly with the number of rewards a user has.
No Mechanism to Prevent Accumulation: The contract does not limit the number of rewards a user can hold, allowing them to accumulate an unbounded number of rewards.
Transaction Failure: Users with a large number of rewards cannot successfully execute claimAllRewards due to gas limitations.
Locked Rewards: Users are unable to access their rewards, leading to potential financial loss and decreased trust in the platform.
User Frustration: The inability to claim rewards can cause dissatisfaction and harm the platform's reputation.
Denial of Service Attack Vector: Malicious users could intentionally accumulate excessive rewards to create a DoS condition, although this is less likely due to associated costs.
Manual Code Review: Analyzed the claimAllRewards function to understand its behavior with large datasets.
To mitigate this issue, the following strategies are recommended:
** Implement Batched Claims**
Allow users to claim rewards in smaller, manageable batches instead of all at once.
Implementation Details
Modify claimAllRewards to Accept a Batch Size:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.