The transferReward function allows users to transfer a specific reward from their own rewards list to another address. It checks the validity of the index, performs the transfer, and deletes the original entry. However, it contains vulnerabilities that could be exploited.
The function does not properly manage the rewards array after deletion. When the reward is deleted using delete rewardsOwned[msg.sender][_index];, the array remains the same length, leaving a "hole" in the array that can be exploited. This allows malicious users to repeatedly call the function using the same index, potentially transferring rewards multiple times without reverting.
Exploitation of this vulnerability could lead to unauthorized transfers of rewards, allowing attackers to drain a user's rewards without proper consent or validation. This undermines the integrity of the rewards system and could lead to significant financial loss for users.
Slither
Remix IDE
Use Safe Array Manipulation: Instead of deleting the reward directly, consider shifting the last element of the array to the index being deleted, thus maintaining array integrity and avoiding "holes".
Implement Reentrancy Guards: Use the checks-effects-interactions pattern or the ReentrancyGuard from OpenZeppelin to prevent reentrant calls.
Comprehensive Testing: Conduct thorough testing, including unit tests and integration tests, to validate the function's behavior under various scenarios and potential attack vectors.
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.