Skip to content
Access control Audit finding Intermediate

Users will lock raffle prizes on the `WinnablesPrizeManager` contract by calling `WinnablesTicketManager::propagateRaffleWinner` with wrong CCIP inputs

The propagateRaffleWinner function lacks validation for the prizeManager address and chainSelector, allowing anyone to call it with incorrect values. This causes the cross-chain message to fail, permanently locking the raffle prize in the WinnablesPrizeManager contract.

0rpse Follow with 0x0bserver, 0x73696d616f and 45 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-winnables-raffles-judging/issues/50

Found by

0rpse, 0x0bserver, 0x73696d616f, 0xAadi, 0xbrivan, 0xrex, CatchEmAll, DrasticWatermelon, Feder, Galturok, IMAFVCKINSTARRRRRR, KungFuPanda, Oblivionis, Offensive021, Oxsadeeq, PNS, PTolev, Paradox, Penaldo, PeterSR, S3v3ru5, SadBase, SovaSlava, Trooper, Waydou, akiro, araj, dany.armstrong90, dimulski, dinkras_, durov, dy, gajiknownnothing, iamnmt, irresponsible, jennifer37, joshuajee, matejdb, neko_nyaa, ogKapten, philmnds, rsam_eth, sakshamguruji, shaflow01, shikhar, tofunmi, turvec, utsav

Summary

The WinnablesTicketManager::propagateRaffleWinner function is vulnerable to misuse, where incorrect CCIP inputs can lead to assets being permanently locked in the WinnablesPrizeManager contract. The function does not have input validation for the address prizeManager and uint64 chainSelector parameters. If called with incorrect values, it will fail to send the message to WinnablesPrizeManager, resulting in the assets not being unlocked.

Root Cause

The root cause of the issue lies in the design of the propagateRaffleWinner function:

  1. The function is responsible for sending a message to WinnablesPrizeManager to unlock the raffle assets.
  2. The function is marked as external, so anyone can call it.
  3. The function receives address prizeManager and uint64 chainSelector as inputs, which are responsible for sending the message to the WinnablesPrizeManager contract for it to unlock the assets previously locked for the raffle.
  4. The inputs forementioned are not validated, meaning users can call the function with wrong values.
  5. This cannot be undone, as the function changes the state of the raffle in a way that prevents the function from being called again.

Internal pre-conditions

A raffle must have been won by a player.

External pre-conditions

A user must call WinnablesTicketManager::propagateRaffleWinner with incorrect input values.

Attack Path

  1. A user wins the raffle.
  2. Some user calls WinnablesTicketManager::propagateRaffleWinner and provides incorrect inputs for prizeManager and chainSelector.
  3. The propagateRaffleWinner function fails to send the correct message to WinnablesPrizeManager due to the parameter mismatch.
  4. As a result, the assets associated with the raffle remain locked and cannot be retrieved by the raffle winner.

Impact

This vulnerability completely disrupts the protocol, as it becomes impossible to retrieve the reward of the raffle.

PoC

The test below, which is an edited version of this existing test, shows that the function call will be successful with a random chainSelector

JavaScript
    it('Should be able to propagate when the winner is drawn', async () => {
@>    const { events } = await (await manager.propagateRaffleWinner(counterpartContractAddress, 9846, 1)).wait();
      expect(events).to.have.lengthOf(3);
      const ccipEvent = ccipRouter.interface.parseLog(events[0]);
      expect(ccipEvent.args.receiver).to.eq('0x' + counterpartContractAddress.toLowerCase().slice(-40).padStart(64, '0'));
      expect(ccipEvent.args.data).to.have.lengthOf(108);
      const drawnWinner = ethers.utils.getAddress('0x' + ccipEvent.args.data.slice(-40));
      expect(buyers.find(b => b.address === drawnWinner)).to.not.be.undefined;
      expect(ccipEvent.args.data.slice(0, 68)).to.eq('0x010000000000000000000000000000000000000000000000000000000000000001');
    });

Mitigation

Implement input validation to ensure that prizeManager and chainSelector are correct before proceeding with the propagation.

Discussion

matejdrazic

It does not make any sense to group lack of access control on cancelRaffle issues with this issue. It should be grouped with #57 .

Brivan-26

@matejdrazic I believe it does make sense. The same root cause (lack of the same inputs validation) and the same impact

matejdrazic

@Brivan-26 hey - but its 2 different functions. By following that logic you can group all same type issues into one. So if there were more access control issues on the contract they would be grouped here? That is not right.

Also they do not have the same root? They have the same type of root cause and thats lack of access control.

Brivan-26

@matejdrazic

So if there were more access control issues on the contract they would be grouped here?

Actually, yes, there were many contests before that had the same access control across multiple contracts even and they are grouped into one report because submitting multiple reports about the same break across different functions is kind of redundant.

Concerning this issue:

  • The root cause is a lack of input validation for prizeManager and chainSelector, not access control as anyone can call this function
  • the impact is the message will not reach the destination chain and loss of funds will occur

Concerning cancelRaffle:

  • The root cause is the same as the previous one, lack of input validation for prizeManager and chainSelector
  • The impact is the same, the message will not reach the destination chain and loss of funds will occur

It is still kind of subjective, it can be a separate report(and I'm okay with that) but it makes sense to group two issues into one single report given the above facts.

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/Winnables/public-contracts/pull/22

The original report as published on Sherlock, by 0rpse. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The propagateRaffleWinner function does not validate the prizeManager address and chainSelector inputs, and it changes the raffle state in a way that prevents retrying with correct values.

Impact

The raffle prize becomes permanently locked and cannot be retrieved by the winner, disrupting the protocol.

What the attacker needed

A raffle has been won by a player; Attacker can call propagateRaffleWinner

The fix

The protocol team fixed this issue by adding input validation for prizeManager and chainSelector.

How it was found

  1. A user wins the raffle.
  2. Some user calls propagateRaffleWinner with incorrect prizeManager and chainSelector values.
  3. The function fails to send the correct message to WinnablesPrizeManager.
  4. The raffle assets remain locked and cannot be retrieved by the winner.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A raffle contract lets anyone trigger the payout by sending a message to another contract that holds the prizes. The function that sends this message takes two inputs: the address of the prize contract and a chain identifier. Because these inputs are not checked, a caller can supply wrong values, so the message never reaches the prize contract. The raffle state is then marked as finished, so the function cannot be called again, and the prize stays locked forever.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0rpse

View all

23 more disclosed reports, best first.

More from Winnables Raffles

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.