The index check in claimSingleReward() is off by one, potentially allowing out-of-bounds access.
Affected Code:
Issue: Arrays are zero-indexed; the valid indices are from 0 to length - 1.
Consequence: If _index == length, it exceeds the array bounds.
User Action:
Calls claimSingleReward() with _index equal to rewardsOwned[msg.sender].length.
Result:
The function attempts to access an element beyond the array's end.
May cause a runtime error or unexpected behavior and might revert the transaction potentially giving bad UX for a user.
We can write a test to demonstrate this issue:
Even if the user has rewards, passing an index equal to length should fail.
Runtime Errors: Potential for contract execution failures.
Security Risks: May expose unintended data or cause unexpected behavior.
Manual Code Review: Identified the incorrect index condition.
Testing Framework (Foundry): Wrote Tests to confirm the vulnerability.
Correct the index check:
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.