Admin can unrestrictedly affect the odds of a raffle by setting themselves up with role(1) in WinnablesTicket
Summary
A core invariant defined in the contest README is that:
Admins cannot affect the odds of a raffle
While the centralization risk of admin self-minting tickets is noted, the following assumption is noted:
The existence of max ticket supply and max holdings however guarantees a minimum level of fairness
By setting themselves up with role(1) directly in the WinnablesTicket token contract, the admin can bypass all these assumptions (max ticket supply, max holdings), and affect the winning odds with no limit.
Root Cause
First of all, let's look at mint() in WinnablesTickets contract:
function mint(address to, uint256 id, uint256 amount) external onlyRole(1) {It is clear that role(1) can mint unlimited tickets. Furthermore, the admin can also grant themselves the role, bypassing any restrictions in buyTicket(). We now investigate the impact (how the results are affected by the admin minting tickets to themselves)
When the raffle results are created, the winner is calculated using the supply from the ticket storage.
function _getWinnerByRequestId(uint256 requestId) internal view returns(address) {
RequestStatus storage request = _chainlinkRequests[requestId];
uint256 supply = IWinnablesTicket(TICKETS_CONTRACT).supplyOf(request.raffleId); // @audit supplyOf is taken from the ticket
uint256 winningTicketNumber = request.randomWord % supply;
return IWinnablesTicket(TICKETS_CONTRACT).ownerOf(request.raffleId, winningTicketNumber);
}By minting (virtually) unlimited tickets to themselves, the admin bypasses all restrictions imposed in ticket purchase, granting themselves victory odds far exceeding the restrictions imposed.
Attack Path
- The admin locks a prize, and starts a raffle as normal. People starts buying tickets to enter the raffle.
- Admin grants themselves role(1) on the
WinnablesTickets(not the ticket manager), and mints themselves (or any related party) almost unlimited tickets. - Admin bypasses all max ticket restrictions, and said party is virtually guaranteed to be the winner.
Impact
Admin can unrestrictedly affect the odds of a raffle, breaking protocol invariant