Unnecessary claiming restriction in raffle contract prevents winners from claiming prizes until all winners are drawn
The Raffle contract's claimPrize function blocks any recorded winner from claiming until every winner slot for that prize has been drawn. A winner of a multi-winner prize therefore cannot collect their prize until an admin completes all remaining draws, causing indefinite delays.
Plume Network
Originally disclosed on Immunefi
51882 sc low unnecessary claiming restriction in raffle contract prevents winners from claiming prizes until all winners are drawn
- Submitted on: Aug 6th 2025 at 12:46:33 UTC by @vivekd for Attackathon | Plume Network
- Report ID: #51882
- Report Type: Smart Contract
- Severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/spin/Raffle.sol
- Impact Summary: Contract fails to deliver promised returns in a timely manner (no direct fund loss)
Description
Brief / Intro
The Raffle contract's claimPrize function contains an overly restrictive check that prevents legitimate winners from claiming their prizes until all winner slots for a multi-winner prize have been drawn. This creates an unnecessary dependency on administrative actions and forces winners to wait indefinitely to claim their prizes, harming user experience.
Vulnerability Details
The problematic logic is in claimPrize (lines ~298-301):
// Lines 298-301 in Raffle.sol
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn();
}
// ... rest of claiming logic
}
What this does:
- It checks
prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity - If true, it reverts with
WinnerNotDrawn() - Thus ANY winner cannot claim until ALL winners for that prize have been selected
How prize state is managed elsewhere (relevant excerpt):
// Lines 278-281 in Raffle.sol
// Deactivate prize if all winners have been drawn
if (winnersDrawn[prizeId] == prizes[prizeId].quantity) {
prizes[prizeId].isActive = false;
}
Flaw summary:
- For prizes with
quantity > 1, once an individual winner is drawn and recorded inprizeWinners[prizeId], that winner still cannot callclaimPrizeuntilwinnersDrawn[prizeId] == quantity(i.e., all winners drawn and the prize deactivated). The ability to claim is incorrectly tied to completion of all drawings rather than to the caller being a recorded winner.
Impact Details
- No direct fund loss, but winners cannot claim their prizes until all winners are drawn. This can cause indefinite delays and breaks the promised timely delivery of prizes.
References
- Raffle.sol lines referenced: https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/spin/Raffle.sol#L297-L312
Proof of Concept
{% stepper %} {% step %}
Setup
- Admin creates a raffle prize with
quantity = 5(5 winners total). - Users enter the raffle by spending tickets via
spendRaffle(). {% endstep %}
{% step %}
First Winner Drawing
- Admin calls
requestWinner(prizeId). - VRF callback executes
handleWinnerSelection(). - Winner #1 is selected and stored at
prizeWinners[prizeId][0]. winnersDrawn[prizeId] = 1.- The prize remains active:
prizes[prizeId].isActive = true. {% endstep %}
{% step %}
Winner Attempts to Claim
- Winner #1 calls
claimPrize(prizeId, 0). - Contract evaluates:
prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity - Evaluates to:
true && (1 < 5) = true - Transaction reverts with
WinnerNotDrawn(). {% endstep %}
{% step %}
Verification
getWinner(prizeId, 0)returns Winner #1's address.getPrizeWinners(prizeId)shows Winner #1 in the array.- Winner #1 is confirmed but cannot claim. {% endstep %}
{% step %}
Waiting Period & Resolution
- If admin does not draw remaining winners, Winner #1 continues to be unable to claim.
- Only after admin draws winners 2–5, when
winnersDrawn[prizeId] == quantity, doesprizes[prizeId].isActivebecomefalseand Winner #1 can finally callclaimPrize(prizeId, 0)successfully. {% endstep %} {% endstepper %}
Suggested Fix (conceptual)
- The claim check should verify that the caller is a recorded winner (e.g., matches
prizeWinners[prizeId][winnerIndex]) and that the specific winner slot has been drawn, rather than requiring that all winner slots for the prize have been drawn and the prize deactivated. Ensure existing invariants and replay/claim protections remain intact.
(Note: The exact code change was not provided in the original report — keep behavior and state invariants in mind when implementing the fix.)
Context
The target is the Raffle contract in the Plume Network attackathon repository, at plume/src/spin/Raffle.sol. The contract runs a raffle: users enter by spending tickets through spendRaffle(), and an administrator requests winners through requestWinner(prizeId). Winner selection is completed asynchronously by a VRF callback that executes handleWinnerSelection(), which records the chosen address in prizeWinners[prizeId] and increments winnersDrawn[prizeId].
A prize can have more than one winner: prizes[prizeId].quantity is the number of winner slots. Once the drawn count reaches the quantity, the prize is deactivated. Winners then call claimPrize(prizeId, winnerIndex) to collect their prize.
The report is rated Low, with the impact summarised as the contract failing to deliver promised returns in a timely manner, with no direct fund loss.
Setup
The scenario needs only the normal roles and no special tooling:
- An administrator who creates a prize and requests winner drawings.
- Users who enter the raffle by spending tickets via
spendRaffle(). - The VRF callback that runs
handleWinnerSelection()and records each winner.
The precondition for the bug is a prize with quantity > 1, that is, a multi-winner prize.
Finding it
The researcher focused on the guard at the top of claimPrize, around lines 298 to 301 of Raffle.sol:
// Lines 298-301 in Raffle.sol
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn();
}
// ... rest of claiming logic
}
The condition combines two facts: the prize is still active, and fewer winners have been drawn than the prize quantity. When both hold, the call reverts with WinnerNotDrawn(). The consequence is that any winner is blocked from claiming until every winner slot for that prize has been selected.
The prize lifecycle elsewhere in the contract explains why this is wrong. The prize is deactivated only when the drawn count reaches the quantity:
// Lines 278-281 in Raffle.sol
// Deactivate prize if all winners have been drawn
if (winnersDrawn[prizeId] == prizes[prizeId].quantity) {
prizes[prizeId].isActive = false;
}
So for a prize with quantity > 1, a winner who has already been drawn and stored in prizeWinners[prizeId] still cannot call claimPrize until winnersDrawn[prizeId] == quantity. The right to claim is tied to the completion of all drawings rather than to the caller being a recorded winner. That dependency on further administrative action is what the researcher flagged as unnecessary and harmful to user experience.
Exploitation
Step 1: Setup
The administrator creates a raffle prize with quantity = 5, meaning five winners in total. Users enter the raffle by spending tickets via spendRaffle().
Step 2: First winner drawing
The administrator calls requestWinner(prizeId). The VRF callback executes handleWinnerSelection(). Winner #1 is selected and stored at prizeWinners[prizeId][0], and winnersDrawn[prizeId] becomes 1. The prize remains active: prizes[prizeId].isActive = true.
Step 3: Winner attempts to claim
Winner #1 calls claimPrize(prizeId, 0). The contract evaluates the guard:
prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity
With the state above this evaluates to true && (1 < 5) = true, and the transaction reverts with WinnerNotDrawn().
Step 4: Verification
getWinner(prizeId, 0) returns Winner #1's address, and getPrizeWinners(prizeId) shows Winner #1 in the array. The winner is confirmed on chain but cannot claim.
Step 5: Waiting period and resolution
If the administrator does not draw the remaining winners, Winner #1 stays unable to claim. Only after the administrator draws winners 2 to 5, when winnersDrawn[prizeId] == quantity, does prizes[prizeId].isActive become false, and only then can Winner #1 call claimPrize(prizeId, 0) successfully.
Root cause
The claim guard checks global progress of the drawing process instead of the caller's own entitlement. The two conditions it tests, prize still active and drawn count below quantity, are exactly the conditions that hold while a multi-winner prize is partially drawn, which is precisely when an already-recorded winner should be able to claim. The deactivation logic elsewhere in the contract (lines 278 to 281) means the guard only stops reverting once every slot is filled, so the claim path is gated on administrative completion rather than on the winner's presence in prizeWinners[prizeId].
Impact
There is no direct fund loss. The effect is that winners of a multi-winner prize cannot claim until all winners are drawn. If the administrator does not complete the remaining drawings, the delay can be indefinite, which breaks the promised timely delivery of prizes. The report frames this as a contract failing to deliver promised returns in a timely manner, and the program rated it Low.
Fix
The report gives a conceptual fix only, and notes that the exact code change was not provided. The claim check should verify that the caller is a recorded winner, for example by matching prizeWinners[prizeId][winnerIndex], and that the specific winner slot has been drawn, rather than requiring that all winner slots for the prize have been drawn and the prize deactivated. Any implementation should keep the existing invariants and the replay and claim protections intact.
Variants to test
- Multi-winner prizes with partial draws. Look for claim functions whose guard references a global counter (total drawn, total claimed, round completion) rather than the caller's own entry. A positive result is a recorded winner whose claim reverts while the counter is below the target.
- Prize or round deactivation as a claim precondition. Search for
isActivestyle flags used in claim paths. A positive result is a claim that only succeeds after an administrative state transition that is unrelated to the caller's entitlement. - Index-based winner lookups. Where claims take a
winnerIndex, check whether the function validates the caller against that index at all. A positive result is a claim that either reverts for the legitimate index holder or accepts an index the caller does not own. - Asynchronous callback flows. In VRF or oracle-driven selection, check what state the callback leaves behind between selections. A positive result is a window in which winners exist on chain but the claim path is closed.
Hunting notes
This class of bug hides in claim and withdrawal functions of contracts that distribute prizes or rewards to multiple recipients, especially where selection happens asynchronously over several transactions. During review, the signal is a guard that mixes a per-user entitlement with a contract-wide progress counter, or a claim path that depends on a flag flipped only at the end of a batch. Comparing the claim guard with the code that deactivates the prize usually makes the mismatch obvious.
The researcher demonstrated impact without any fund loss by walking the full lifecycle: a five-winner prize, one winner drawn, the claim reverting with WinnerNotDrawn(), the winner confirmed through getWinner and getPrizeWinners, and the claim succeeding only after all five drawings complete. That end-to-end sequence, tied to the exact lines in Raffle.sol, makes the availability problem concrete.
What happened, in plain words
A raffle is a draw where people buy or spend tickets for a chance to win a prize. This report is about a raffle that runs on a blockchain, inside a piece of code called a smart contract. A smart contract is a program that lives on the blockchain: it runs automatically, its rules are public, and nobody can quietly change the result after the fact.
The raffle in question lets an administrator create a prize that has several winners, for example five. People enter by spending tickets. The administrator then asks the contract to pick winners, and the picking is done by an outside service called a VRF (explained below). Each time a winner is picked, the contract writes that person's address into a list.
When a winner wants to collect their prize, they call a function called claimPrize. The problem the researcher found is in the check at the start of that function. The check does not ask "is this person a winner?". Instead it asks "has the prize finished drawing all of its winners?". So the first winner of a five-winner prize is told "you are not drawn yet" and is blocked, even though the contract itself has already recorded them as a winner. They can only claim once the administrator has drawn the other four winners too.
No money is stolen and no funds are lost. The harm is delay: if the administrator never finishes drawing the remaining winners, the first winner may never be able to collect. The program rated this Low severity, and the report describes the impact as the contract failing to deliver promised returns in a timely manner.
Background you need first
What a smart contract is
Think of a vending machine. It has fixed rules: insert a coin, press a button, get an item. A smart contract is the software version of that, running on a blockchain. Anyone can read its code, anyone can call its functions, and the outcome is the same for everyone. Because it handles things of value, a small mistake in a rule can block people from getting what they are owed.
What the Raffle contract does
The target is the Raffle contract in the Plume Network attackathon repository, at plume/src/spin/Raffle.sol. It runs a raffle with three moving parts:
- Entering. Users spend tickets by calling
spendRaffle(). - Drawing. An administrator asks for a winner by calling
requestWinner(prizeId). The actual choice is not made instantly; it is completed later by a callback (a function the outside service calls back into the contract) that runshandleWinnerSelection(). That callback records the chosen address inprizeWinners[prizeId]and increases the counterwinnersDrawn[prizeId]by one. - Claiming. Winners call
claimPrize(prizeId, winnerIndex)to collect their prize.
A prize can have more than one winner. The number of winner slots is stored in prizes[prizeId].quantity. When the number of drawn winners reaches that quantity, the prize is switched off (deactivated).
What a VRF is
A VRF, or verifiable random function, is a way to produce a random number that anyone can later check was genuinely random and not tampered with. Raffles need randomness, otherwise the person running the draw could pick favourites. The VRF here is an outside service: the contract asks for a random result, and the service calls back into the contract with it. That is why winner selection is asynchronous, meaning it happens in a later transaction rather than in the same instant as the request.
What a revert is
When a smart contract function decides it should not continue, it "reverts". This cancels the whole operation, undoes any changes made during that call, and returns an error. It is like a shop assistant refusing a return and handing the item back: nothing changes hands. Here the error is called WinnerNotDrawn().
What the vulnerability class means
This is not a break-in. It is a logic flaw: the code does what it was written to do, but the rule it enforces is the wrong rule. Specifically, a permission check looks at the wrong thing. Instead of checking whether the person asking is entitled, it checks whether some global process has finished. Security people call this kind of mistake an access-control or business-logic issue. The everyday comparison: a hotel that only hands out room keys once every room in the building has been cleaned, rather than when your own room is ready.
Setup
The scenario needs only the normal roles and no special tooling:
- An administrator who creates a prize and requests winner drawings.
- Users who enter the raffle by spending tickets via
spendRaffle(). - The VRF callback that runs
handleWinnerSelection()and records each winner.
The precondition for the bug is a prize with quantity > 1, that is, a multi-winner prize.
Finding it
The researcher focused on the guard at the top of claimPrize, around lines 298 to 301 of Raffle.sol:
// Lines 298-301 in Raffle.sol
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn();
}
// ... rest of claiming logic
}
Line by line:
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {declares the function a winner calls to collect. It takes two numbers: which prize (prizeId) and which winner slot that person occupies (winnerIndex).externalmeans it can be called from outside the contract, by a user.if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {is the guard.prizes[prizeId].isActiveis a true/false flag saying the prize is still running.winnersDrawn[prizeId]is how many winners have been drawn so far.prizes[prizeId].quantityis how many winners the prize is supposed to have. The&&means both parts must be true for the guard to fire.revert WinnerNotDrawn();cancels the call and reports the error "winner not drawn".- The comment marks where the rest of the claiming logic would follow, which is never reached when the guard fires.
The condition combines two facts: the prize is still active, and fewer winners have been drawn than the prize quantity. When both hold, the call reverts with WinnerNotDrawn(). The consequence is that any winner is blocked from claiming until every winner slot for that prize has been selected.
The prize lifecycle elsewhere in the contract explains why this is wrong. The prize is deactivated only when the drawn count reaches the quantity:
// Lines 278-281 in Raffle.sol
// Deactivate prize if all winners have been drawn
if (winnersDrawn[prizeId] == prizes[prizeId].quantity) {
prizes[prizeId].isActive = false;
}
Line by line:
- The comment states the intent: switch the prize off once all winners exist.
if (winnersDrawn[prizeId] == prizes[prizeId].quantity) {checks whether the number drawn equals the number of slots. The==is an equality test, not an assignment.prizes[prizeId].isActive = false;flips the flag to false, meaning the prize is no longer active.
Put the two pieces together. The claim guard only stops firing once isActive is false, and isActive only becomes false once every slot is filled. So for a prize with quantity > 1, a winner who has already been drawn and stored in prizeWinners[prizeId] still cannot call claimPrize until winnersDrawn[prizeId] == quantity. The right to claim is tied to the completion of all drawings rather than to the caller being a recorded winner. That dependency on further administrative action is what the researcher flagged as unnecessary and harmful to user experience.
Exploitation
Step 1: Setup
The administrator creates a raffle prize with quantity = 5, meaning five winners in total. Users enter the raffle by spending tickets via spendRaffle().
Why this step matters: the bug only shows up when a prize has more than one winner, because that is the only situation where a prize can be partly drawn. Five is simply a concrete number that makes the gap visible.
Step 2: First winner drawing
The administrator calls requestWinner(prizeId). The VRF callback executes handleWinnerSelection(). Winner #1 is selected and stored at prizeWinners[prizeId][0], and winnersDrawn[prizeId] becomes 1. The prize remains active: prizes[prizeId].isActive = true.
Why this step matters: at this point the contract already knows who the first winner is. The list entry and the counter are both updated. Nothing about the first winner is uncertain any more.
Step 3: Winner attempts to claim
Winner #1 calls claimPrize(prizeId, 0). The contract evaluates the guard:
prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity
With the state above this evaluates to true && (1 < 5) = true, and the transaction reverts with WinnerNotDrawn().
Why this step matters: this is the moment the flaw becomes visible. The prize is active (true), and one drawn winner is fewer than five slots (1 < 5 is true), so both halves of the guard hold and the claim is refused.
Step 4: Verification
getWinner(prizeId, 0) returns Winner #1's address, and getPrizeWinners(prizeId) shows Winner #1 in the array. The winner is confirmed on chain but cannot claim.
Why this step matters: these are read-only functions that anyone can call to inspect the contract's state. They prove the contradiction: the contract's own records say this person won, while the claim function refuses them. Without this check, someone might argue the winner simply was not recorded.
Step 5: Waiting period and resolution
If the administrator does not draw the remaining winners, Winner #1 stays unable to claim. Only after the administrator draws winners 2 to 5, when winnersDrawn[prizeId] == quantity, does prizes[prizeId].isActive become false, and only then can Winner #1 call claimPrize(prizeId, 0) successfully.
Why this step matters: it shows the dependency on someone else's future action. The winner's entitlement does not change between step 3 and this step; only the administrator's progress does. If the administrator stops, the winner waits indefinitely.
Root cause
The claim guard checks global progress of the drawing process instead of the caller's own entitlement. The two conditions it tests, prize still active and drawn count below quantity, are exactly the conditions that hold while a multi-winner prize is partially drawn, which is precisely when an already-recorded winner should be able to claim. The deactivation logic elsewhere in the contract (lines 278 to 281) means the guard only stops reverting once every slot is filled, so the claim path is gated on administrative completion rather than on the winner's presence in prizeWinners[prizeId].
In everyday terms: the door is locked until the whole building is finished, when it should open for anyone whose name is on the list.
Impact
There is no direct fund loss. The effect is that winners of a multi-winner prize cannot claim until all winners are drawn. If the administrator does not complete the remaining drawings, the delay can be indefinite, which breaks the promised timely delivery of prizes. The report frames this as a contract failing to deliver promised returns in a timely manner, and the program rated it Low.
Why Low rather than higher: nothing is stolen and the funds are not gone. The problem is availability, meaning people cannot get at what they are owed when they expect to.
Fix
The report gives a conceptual fix only, and notes that the exact code change was not provided. The claim check should verify that the caller is a recorded winner, for example by matching prizeWinners[prizeId][winnerIndex], and that the specific winner slot has been drawn, rather than requiring that all winner slots for the prize have been drawn and the prize deactivated. Any implementation should keep the existing invariants and the replay and claim protections intact.
Two ideas in that sentence need unpacking. An invariant is a rule that must always stay true, such as "a prize can only be paid out once". Replay protection means stopping the same claim from being used twice, for example by marking a slot as already claimed before sending the prize. A fix that opens the door earlier must not accidentally let someone walk through it twice.
Variants to test
These are patterns to look for in other contracts, not findings in this one.
- Multi-winner prizes with partial draws. Look for claim functions whose guard references a global counter (total drawn, total claimed, round completion) rather than the caller's own entry. A positive result is a recorded winner whose claim reverts while the counter is below the target.
- Prize or round deactivation as a claim precondition. Search for
isActivestyle flags used in claim paths. A positive result is a claim that only succeeds after an administrative state transition that is unrelated to the caller's entitlement. - Index-based winner lookups. Where claims take a
winnerIndex, check whether the function validates the caller against that index at all. A positive result is a claim that either reverts for the legitimate index holder or accepts an index the caller does not own. - Asynchronous callback flows. In VRF or oracle-driven selection, check what state the callback leaves behind between selections. A positive result is a window in which winners exist on chain but the claim path is closed.
Hunting notes
This class of bug hides in claim and withdrawal functions of contracts that distribute prizes or rewards to multiple recipients, especially where selection happens asynchronously over several transactions. During review, the signal is a guard that mixes a per-user entitlement with a contract-wide progress counter, or a claim path that depends on a flag flipped only at the end of a batch. Comparing the claim guard with the code that deactivates the prize usually makes the mismatch obvious.
The researcher demonstrated impact without any fund loss by walking the full lifecycle: a five-winner prize, one winner drawn, the claim reverting with WinnerNotDrawn(), the winner confirmed through getWinner and getPrizeWinners, and the claim succeeding only after all five drawings complete. That end-to-end sequence, tied to the exact lines in Raffle.sol, makes the availability problem concrete.
Glossary
- Smart contract: a program stored and run on a blockchain, whose rules are public and whose results cannot be quietly changed afterwards.
- Blockchain: a shared record of transactions kept by many computers, where entries are effectively permanent.
- Raffle: a draw in which people spend tickets for a chance to win a prize.
- Contract address: the identifier of a smart contract on the blockchain, used to call it.
- Function: a named block of code inside a contract that can be called to do something, such as claim a prize.
- Call: asking a contract function to run, usually by sending a transaction.
- Transaction: a signed instruction sent to the blockchain that runs code and can change stored data.
- Administrator: the account with permission to perform management actions, here creating prizes and requesting winner drawings.
- Ticket: the unit users spend to enter the raffle, handled by
spendRaffle(). spendRaffle(): the function users call to enter the raffle by spending tickets.requestWinner(prizeId): the function the administrator calls to ask for a winner to be drawn for a given prize.- VRF (verifiable random function): a way to produce a random number that can later be proven genuine and untampered, used so the draw cannot be rigged.
- Callback: a function that an outside service calls back into the contract later, here to deliver the random result.
handleWinnerSelection(): the callback function that records the chosen winner and increases the drawn-winner counter.- Asynchronous: happening in a later step rather than immediately, so the request and the result are separate transactions.
prizeId: the number identifying which prize is being referred to.winnerIndex: the number identifying which winner slot a person occupies for a prize.quantity: the number of winner slots a prize has.prizeWinners[prizeId]: the contract's stored list of winners for a prize.winnersDrawn[prizeId]: a counter of how many winners have been drawn so far for a prize.isActive: a true/false flag showing whether a prize is still running.claimPrize(prizeId, winnerIndex): the function a winner calls to collect their prize.- Guard: a check at the start of a function that decides whether to continue or refuse.
- Revert: cancelling a function call, undoing its changes and returning an error.
WinnerNotDrawn(): the error the contract returns when the claim guard refuses a call.getWinner(prizeId, 0): a read-only function that returns the address recorded in a winner slot.getPrizeWinners(prizeId): a read-only function that returns the list of winners for a prize.- Read-only function: a function that only reports stored data and changes nothing.
- Deactivate: switch a prize off so it is no longer active, done here once all winners are drawn.
- Logic flaw: a bug where the code runs as written but the rule it enforces is wrong.
- Access control: the rules deciding who is allowed to do what.
- Entitlement: a person's own right to something, here a recorded winner's right to claim.
- Availability: whether something can be used when it is needed; an availability problem means people are blocked rather than robbed.
- Invariant: a rule that must always remain true, such as a prize being paid out only once.
- Replay protection: measures that stop the same action, such as a claim, from being repeated or reused.
- Oracle: an outside service that feeds data into a contract; a VRF is one kind.
- Severity: the rating of how serious a finding is; this one is Low.
- Proof of concept: a step-by-step demonstration showing the bug actually happens.