sherlock-audit / 2023-10-looksrare-judging

6 stars 6 forks source link

syahirAmali - Fairness of Randomness is threatened and possibilities for gaming the jackpot. #131

Closed sherlock-admin2 closed 1 year ago

sherlock-admin2 commented 1 year ago

syahirAmali

medium

Fairness of Randomness is threatened and possibilities for gaming the jackpot.

Summary

Re-requesting randomness from VRF is a security pattern anti-pattern. This issue will show how the current implementation of startGame() goes directly against Chainlink's security Security Consideration of not re-requesting randomness (https://docs.chain.link/vrf/v2/security#do-not-re-request-randomness).

Vulnerability Detail

The fulfillRandomWords function calls internal functions _healRequestFulfilled , _woundRequestFulfilled, and _killWoundedAgents, which loops over the healingAgentIdsCount, woundedAgentsCount and woundedAgentIdsCount. This is a problem as the code might require a lot of gas and make the fulfillRandomWords revert it's execution, which is problem for the integration of VRF as listed in the docs, since it should not be reverting.

Code Snippet

We can see that from the startGame function, _requestForRandomness is can be re ran in the case of a revert.

https://github.com/sherlock-audit/2023-10-looksrare/blob/main/contracts-infiltration/contracts/Infiltration.sol#L522

Impact

Re-requesting randomness is achieved when there is a possible revert on the fulfillRandomWords function. Fairness of protocol is undermined.

Tool used

Manual Review

Recommendation

Duplicate of #64