# Attacker will prevent any raffles by calling `WinnablesTicketManager::cancelRaffle` before admin starts raffle

Anyone can call cancelRaffle on a PRIZE_LOCKED raffle, letting an attacker repeatedly cancel raffles before the admin starts them, blocking the protocol and burning LINK fees.

- Payout: Audit contest
- Severity: high
- Program: Winnables Raffles
- Found by: 0rpse
- Disclosed: 2024-08-14
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-winnables-raffles-judging/issues/57
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-winnables-raffles%3AH-2
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic vuln:dos

**Target:** Solidity raffle manager contract (WinnablesTicketManager) with CCIP cross-chain messaging
**Root cause:** cancelRaffle is externally callable by anyone and _checkShouldCancel permits cancellation while raffle status is PRIZE_LOCKED, a transient state between prize lock and admin createRaffle.
**Steps:**
1. Admin locks prize in WinnablesPrizeManager; CCIP message sets raffle status to PRIZE_LOCKED in WinnablesTicketManager.
2. Attacker monitors for PRIZE_LOCKED raffleIds.
3. Attacker calls `WinnablesTicketManager.cancelRaffle(counterpartContractAddress, raffleId, chainSelector)` before admin calls createRaffle.
4. Raffle is cancelled; repeat for every new raffle to prevent any raffle from starting.
**How found:** Code review of cancelRaffle's access control and _checkShouldCancel status logic, noticing PRIZE_LOCKED is cancellable and precedes admin createRaffle, creating a front-runnable window.
**Exploitation:** Attacker watches the ticket manager for raffles entering PRIZE_LOCKED after the prize-lock CCIP message, then calls the permissionless cancelRaffle first, sending a CCIP cancel message and consuming LINK fees paid by the protocol; repeating indefinitely blocks all raffle creation.
**Escalation:** Repeated indefinitely across every raffle, draining LINK token balances used for CCIP fees and rendering the protocol unusable.
**Insight:** Look for permissionless cancel/refund/close functions that accept transient intermediate states (e.g. locked-but-not-started) — those windows let anyone grief state transitions and burn protocol-paid cross-chain fees.

## Proof of concept (copied exactly from the original report)

**Test showing random buyer cancels raffle**

```
describe('Buyer can cancel raffle', () => {
    before(async () => {
      snapshot = await helpers.takeSnapshot();
    });

    after(async () => {
      await snapshot.restore();
    });
    const buyers = [];

    it('Should be able to cancel a raffle', async () => {
      const now = await blockTime();
      const buyer = await getWalletWithEthers();
      await (await link.mint(manager.address, ethers.utils.parseEther('100'))).wait();
      const tx = await manager.connect(buyer).cancelRaffle(counterpartContractAddress, 1, 1);
      const { events } = await tx.wait();
      expect(events).to.have.lengthOf(3);
      const ccipMessageEvent = ccipRouter.interface.parseLog(events[0]);
      expect(ccipMessageEvent.name).to.eq('MockCCIPMessageEvent');
      expect(ccipMessageEvent.args.data).to.eq('0x000000000000000000000000000000000000000000000000000000000000000001');
      await expect(manager.getWinner(1)).to.be.revertedWithCustomError(manager, 'RaffleNotFulfilled');
```

