The claimAllRewards function is vulnerable to reentrancy attacks because it performs an external call to send Ether before updating the user's rewards, allowing attackers to exploit the contract and drain funds.
The function sends Ether to the user before clearing their rewards:
An attacker could re-enter the function during the external call and claim rewards multiple times.
Fund Drainage: Attackers can repeatedly withdraw funds, potentially emptying the contract's balance.
Denial of Service: Legitimate users may be unable to claim rewards due to drained funds.
Security Breach: The contract's integrity and user trust are compromised.
Manual Code Review: Identifying the sequence of state changes and external calls.
Follow the Checks-Effects-Interactions pattern by updating state variables before making external calls:
Additionally, consider using the ReentrancyGuard modifier from OpenZeppelin:
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.