Winners cannot claim Prizes until all winners have been drawn in Raffle::claimPrize
The claimPrize function in the Raffle contract reverts if the number of winners drawn is less than the prize quantity, so a winner cannot claim until all winners for that prize have been selected. This delays individual claims and breaks the documented invariant that each winner's claim status is independent.
Plume Network
Originally disclosed on Immunefi
50721 sc low winners cannot claim prizes until all winners have been drawn in raffle claimprize
- Report ID: #50721
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/spin/Raffle.sol
- Submitted on: Jul 27th 2025 at 21:14:40 UTC by @blackgrease for Attackathon | Plume Network (https://immunefi.com/audit-competition/plume-network-attackathon)
#50721 [SC-Low] Winners cannot claim Prizes until all winners have been drawn in Raffle::claimPrize
Summary
- The
Raffle::claimPrizefunction contains a check that prevents individual winners from claiming their prize when a prize has more than one winner. This makes individual claims dependent on all winners being drawn, which contradicts the documented invariant that each winner’s claim status is independent.
Hint: severity/impact note
{% hint style="info" %} The reporter states the official severity as Low but argues the practical impact and broken invariant justify a Medium severity rating. This note is preserved from the original report. {% endhint %}
Description
The Raffle documentation states the contract is "Multi-winner aware" and tracks winner claims independently:
"Independent Status: Each winner's claim status is tracked independently. One user claiming their prize has no effect on the ability of other winners to claim theirs." — Plume Raffle Documentation
However, Raffle::claimPrize contains the following check that partially breaks this promise:
Problematic check in claimPrize
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn(); //@audit-medium: winners cannot claim until all winners have been selected
//--snip---
}
This requires the total number of winners drawn to equal the number of possible winners (prize quantity) before any winner can claim. For prizes with multiple winners, earlier winners cannot claim until all winners have been drawn, making claims dependent on the admin-driven drawing process and introducing unpredictable waiting times.
Impact
The reporter preserved their severity note but recommends Medium; the original report labels the finding Low. The practical impacts are summarized below as individual items:
{% stepper %} {% step %}
Impact item 1
Partially broken invariant: The contract can behave outside documented expectations, creating a conflict between protocol promises and executed logic. {% endstep %}
{% step %}
Impact item 2
Inconvenience: For prizes with many winners, early winners must wait until all winners are drawn (an admin-initiated action) to claim, causing unpredictable delays. {% endstep %}
{% step %}
Impact item 3
User experience: Long waiting times may cause negative feedback and decreased engagement in the Raffle game. {% endstep %} {% endstepper %}
Likelihood: High — this will occur whenever a prize has more than one winner.
Mitigation
Change the check so it only reverts when no winners have yet been drawn for that prize (i.e., winnersDrawn[prizeId] == 0), instead of requiring that all winners have already been drawn.
Suggested fix (diff)
// User claims their prize, we mark it as claimed and deactivate the prize
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
- if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
+ if (prizes[prizeId].isActive && winnersDrawn[prizeId] == 0) { //Only check if there are 0 winners meaning `requestWinner` has yet to be called.
revert WinnerNotDrawn();
}
Winner storage individualWin = prizeWinners[prizeId][winnerIndex];
//---snip---
Proof of Concept
Private Gist: https://gist.github.com/blackgrease/3af095c20d2604f14141bb5a74b80a3a
Run with:
forge test --mt testCannotClaimUntillAllWinnersDrawn --via-ir -vvvv
Walk-through (PoC)
{% stepper %} {% step %}
Step 1
An admin creates a Prize with 4 possible winners. {% endstep %}
{% step %}
Step 2
6 different players join the raffle pool with different amounts of raffle tickets. {% endstep %}
{% step %}
Step 3
The Admin initiates the winner selection and the Supra Router calls back and selects winners. {% endstep %}
{% step %}
Step 4
One winner is announced and multiple (3) remaining winners are pending. {% endstep %}
{% step %}
Step 5
The announced winner tries to claim their prize by calling Raffle::claimPrize but the call reverts with WinnerNotDrawn.
{% endstep %}
{% step %}
Step 6
The winner must wait until all winners have been drawn before being able to successfully claim their prize. {% endstep %} {% endstepper %}
Notes
- The reporter validated that applying the suggested check (
winnersDrawn[prizeId] == 0) allows winners to claim once they are drawn even if not all winners for the prize have been selected, thus resolving the issue described. - All links and the Gist URL are kept as provided.
Context
The target is the Raffle contract of the Plume Network codebase, at plume/src/spin/Raffle.sol. The Raffle is a game in which players join a pool with raffle tickets, an admin creates a prize with a given quantity of possible winners, and winners are selected through a callback from the Supra Router. The contract is documented as "Multi-winner aware" and as tracking winner claims independently:
"Independent Status: Each winner's claim status is tracked independently. One user claiming their prize has no effect on the ability of other winners to claim theirs.", Plume Raffle Documentation
The feature under review is Raffle::claimPrize, the function through which a drawn winner collects their prize.
Setup
The report does not describe any accounts, roles, tooling versions or deployment preconditions beyond what the proof of concept needs: an admin who creates a prize and initiates the drawing, a Supra Router callback that selects winners, and several players who join the pool. The proof of concept is a Foundry test, run with the command shown below.
Finding it
The researcher compared the documented invariant with the code of claimPrize and found a check that contradicts it. The problematic check is:
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn(); //@audit-medium: winners cannot claim until all winners have been selected
//--snip---
}
The condition reverts while the number of winners drawn for the prize (winnersDrawn[prizeId]) is smaller than the prize quantity. For any prize with more than one possible winner, that means no winner can claim until every winner has been drawn, so an individual claim depends on the admin-driven drawing process finishing. The researcher notes that this partially breaks the promise that each winner's claim status is independent.
The reporter recorded the official severity as Low but argued that the practical impact and the broken invariant justify a Medium rating.
Exploitation
The proof of concept is a private Gist, referenced in the report as https://gist.github.com/blackgrease/[redacted]. It is run with:
forge test --mt testCannotClaimUntillAllWinnersDrawn --via-ir -vvvv
The test name, testCannotClaimUntillAllWinnersDrawn, reflects the behaviour being demonstrated. The walk-through proceeds as follows.
Step 1
An admin creates a prize with 4 possible winners.
Step 2
6 different players join the raffle pool with different amounts of raffle tickets.
Step 3
The admin initiates the winner selection and the Supra Router calls back and selects winners.
Step 4
One winner is announced and multiple (3) remaining winners are pending.
Step 5
The announced winner tries to claim their prize by calling Raffle::claimPrize, but the call reverts with WinnerNotDrawn.
Step 6
The winner must wait until all winners have been drawn before being able to successfully claim their prize.
The report does not include the test source, the transaction traces or the exact revert output beyond the error name WinnerNotDrawn.
Root cause
The guard in claimPrize uses the wrong threshold. It compares the number of drawn winners against the full prize quantity, so it treats "not all winners drawn yet" as "no winner can claim yet". The intended meaning, per the mitigation, is only to block claims before the drawing has started at all, that is, while winnersDrawn[prizeId] is zero. Because the check is evaluated on every claim, the contract's behaviour diverges from the documented independent claim status for every multi-winner prize.
Impact
The report lists three practical impacts:
- Partially broken invariant: the contract behaves outside documented expectations, creating a conflict between protocol promises and executed logic.
- Inconvenience: for prizes with many winners, early winners must wait until all winners are drawn, an admin-initiated action, causing unpredictable delays.
- User experience: long waiting times may cause negative feedback and decreased engagement in the Raffle game.
Likelihood is stated as high, because the condition occurs whenever a prize has more than one winner. The report does not describe loss of funds or a way for an attacker to profit.
Fix
The suggested mitigation is to change the check so it only reverts when no winners have yet been drawn for that prize, that is, winnersDrawn[prizeId] == 0, instead of requiring that all winners have already been drawn. The proposed diff is:
// User claims their prize, we mark it as claimed and deactivate the prize
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
- if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
+ if (prizes[prizeId].isActive && winnersDrawn[prizeId] == 0) { //Only check if there are 0 winners meaning `requestWinner` has yet to be called.
revert WinnerNotDrawn();
}
Winner storage individualWin = prizeWinners[prizeId][winnerIndex];
//---snip---
The researcher validated that applying the suggested check allows winners to claim once they are drawn, even if not all winners for the prize have been selected, which resolves the issue described.
Variants to test
- Multi-winner prize contracts with a per-prize drawing counter: check whether the claim guard compares the counter to the prize quantity rather than to zero. A positive result is a claim that reverts with the "not drawn" error while other winners for the same prize are still pending.
- Batch drawing flows driven by an external callback (oracle or router): look for claim functions gated on the completion of the whole batch. A positive result is an early drawn winner who cannot claim until the final callback lands.
- Pause or active-flag combinations: check whether the
isActivecondition interacts with the counter so that a prize can be deactivated or left unclaimable in intermediate states. A positive result is a prize that cannot be claimed in a state the documentation says should be claimable. - Documentation-versus-code checks on "independent" claim status: for each documented independence promise, find the corresponding storage and guard. A positive result is any guard that makes one user's claim depend on another user's or the admin's action.
Hunting notes
This kind of bug hides in claim and settlement functions of games, lotteries and reward distributors, especially where winners are drawn in batches by an external callback. The signal during review is a guard that compares a progress counter against a total quantity instead of against zero or against the specific winner's state. Reading the project's own documentation for words such as "independent" and then locating the code that implements that promise is a cheap way to find the mismatch. The researcher showed impact by walking through a concrete scenario with a prize of 4 winners and 6 players, tying it to the documented invariant.
What happened, in plain words
A raffle is a game of chance. Players buy or receive tickets, join a pool, and later some of them are picked as winners and get a prize. The Plume Network codebase contains a smart contract called Raffle that runs this game. A smart contract is a program that lives on a blockchain: it runs exactly as written, anyone can read its code, and nobody can quietly change its behaviour after the fact.
The researcher read the Raffle's own documentation, which promises that each winner's claim is independent: one winner collecting their prize should have no effect on whether the other winners can collect theirs. Then the researcher read the code of claimPrize, the function a winner calls to collect their prize, and found a check that breaks that promise. For any prize with more than one possible winner, the check refuses every claim until all winners have been drawn. So the first winner to be announced has to sit and wait for the organiser to finish drawing the rest, even though their own prize is already decided.
This is not a way to steal money. It is a logic bug: the code does something the documentation says it will not do, and it makes winners wait for an admin action that may take an unpredictable amount of time. The report rates it Low officially, while the researcher argues the broken promise and the practical delay justify Medium.
Background you need first
A few ideas come up again and again below, so here they are from zero.
Smart contract. A small program deployed to a blockchain. It has functions (named actions you can call) and storage (data it remembers between calls). Because the code is public and the blockchain records every call, a bug in a contract is visible to everyone and behaves the same way for everyone.
Solidity. The programming language most smart contracts are written in. It looks a bit like JavaScript. A function is a named block of code. A uint256 is a whole number that cannot be negative. external means the function can be called from outside the contract. revert means "stop and undo everything, and report an error".
Invariant. A rule the project promises always holds, usually written down in documentation. Think of a shop sign saying "each customer may collect their own order at any time". If the till software instead waits until every order of the day is packed before handing out the first one, the sign and the software disagree: that disagreement is a broken invariant.
Admin. A privileged account that can perform special actions, here creating prizes and starting the drawing of winners.
Callback. When one program asks another program to do something and then calls back with the answer. Here an external service called the Supra Router is asked to pick winners and calls back into the Raffle contract with the result. Think of phoning a restaurant, placing an order, and the restaurant ringing you back when the food is ready.
Foundry and forge test. Foundry is a toolkit for writing and running tests against smart contracts on your own computer, without touching the real blockchain. forge test is the command that runs those tests. A test is a small program that sets up a situation, performs actions, and checks the result.
Proof of concept (PoC). A concrete demonstration that a bug is real, usually a test or a script that reproduces it.
Severity. How serious a finding is judged to be, typically Low, Medium, High or Critical. Severity often weighs impact (what goes wrong) against likelihood (how often it can happen).
Context: the product and the feature
The target is the Raffle contract of the Plume Network codebase, at plume/src/spin/Raffle.sol. The Raffle is a game in which players join a pool with raffle tickets, an admin creates a prize with a given quantity of possible winners, and winners are selected through a callback from the Supra Router. The contract is documented as "Multi-winner aware" and as tracking winner claims independently:
"Independent Status: Each winner's claim status is tracked independently. One user claiming their prize has no effect on the ability of other winners to claim theirs.", Plume Raffle Documentation
The feature under review is Raffle::claimPrize, the function through which a drawn winner collects their prize. The :: notation simply means "the claimPrize function inside the Raffle contract".
Setup
The report does not describe any accounts, roles, tooling versions or deployment preconditions beyond what the proof of concept needs: an admin who creates a prize and initiates the drawing, a Supra Router callback that selects winners, and several players who join the pool. The proof of concept is a Foundry test, run with the command shown below.
Finding it
The researcher compared the documented invariant with the code of claimPrize and found a check that contradicts it. The problematic check is:
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
revert WinnerNotDrawn(); //@audit-medium: winners cannot claim until all winners have been selected
//--snip---
}
Line by line:
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {declares a function calledclaimPrizethat anyone outside the contract can call. It takes two numbers:prizeId, which prize the caller is claiming, andwinnerIndex, which of the winners for that prize the caller is.if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {is the guard.prizes[prizeId]looks up the prize record..isActiveis a true/false flag saying the prize is still open.winnersDrawn[prizeId]is a counter of how many winners have been drawn so far for that prize..quantityis how many winners the prize is supposed to have. The&&means both conditions must be true. So the guard fires when the prize is active and fewer winners have been drawn than the prize allows.revert WinnerNotDrawn();stops the call and undoes any changes, reporting the errorWinnerNotDrawn. The comment next to it records the researcher's note that winners cannot claim until all winners have been selected.//--snip---marks code the report left out.
The condition reverts while the number of winners drawn for the prize (winnersDrawn[prizeId]) is smaller than the prize quantity. For any prize with more than one possible winner, that means no winner can claim until every winner has been drawn, so an individual claim depends on the admin-driven drawing process finishing. The researcher notes that this partially breaks the promise that each winner's claim status is independent.
The reporter recorded the official severity as Low but argued that the practical impact and the broken invariant justify a Medium rating.
Exploitation
The proof of concept is a private Gist, referenced in the report as https://gist.github.com/blackgrease/[redacted]. A Gist is a small code-sharing page. It is run with:
forge test --mt testCannotClaimUntillAllWinnersDrawn --via-ir -vvvv
What each part does:
forgeis the Foundry command-line tool.testtells it to run tests.--mt testCannotClaimUntillAllWinnersDrawnfilters the run to the single test whose name matchestestCannotClaimUntillAllWinnersDrawn(the spelling, includingUntill, is as written in the report).--via-irasks the compiler to use its intermediate-representation pipeline, a different compilation route that can change how code is generated.-vvvvsets the highest verbosity, so the output includes detailed traces of what happened during the test.
The test name, testCannotClaimUntillAllWinnersDrawn, reflects the behaviour being demonstrated. The walk-through proceeds as follows.
Step 1
An admin creates a prize with 4 possible winners. This sets the prize quantity to 4, so the guard above will compare the drawn counter against 4.
Step 2
6 different players join the raffle pool with different amounts of raffle tickets. More players than prize slots is normal for a raffle: not everyone can win.
Step 3
The admin initiates the winner selection and the Supra Router calls back and selects winners. This is the callback described earlier: the contract asks an outside service to pick, and the service calls back with the picks.
Step 4
One winner is announced and multiple (3) remaining winners are pending. At this moment the drawn counter is 1 and the quantity is 4, so the guard's second condition (1 < 4) is true.
Step 5
The announced winner tries to claim their prize by calling Raffle::claimPrize, but the call reverts with WinnerNotDrawn. The winner did nothing wrong; the guard simply refuses because the drawing is not finished.
Step 6
The winner must wait until all winners have been drawn before being able to successfully claim their prize. Only when the counter reaches 4 does the guard stop firing.
The report does not include the test source, the transaction traces or the exact revert output beyond the error name WinnerNotDrawn.
Root cause
The guard in claimPrize uses the wrong threshold. It compares the number of drawn winners against the full prize quantity, so it treats "not all winners drawn yet" as "no winner can claim yet". The intended meaning, per the mitigation, is only to block claims before the drawing has started at all, that is, while winnersDrawn[prizeId] is zero. Because the check is evaluated on every claim, the contract's behaviour diverges from the documented independent claim status for every multi-winner prize.
A useful comparison: a restaurant that will not serve any guest until every table in the building has ordered. The kitchen only needs to know that your order exists, not that everyone else has ordered too.
Impact
The report lists three practical impacts:
- Partially broken invariant: the contract behaves outside documented expectations, creating a conflict between protocol promises and executed logic.
- Inconvenience: for prizes with many winners, early winners must wait until all winners are drawn, an admin-initiated action, causing unpredictable delays.
- User experience: long waiting times may cause negative feedback and decreased engagement in the Raffle game.
Likelihood is stated as high, because the condition occurs whenever a prize has more than one winner. The report does not describe loss of funds or a way for an attacker to profit.
Fix
The suggested mitigation is to change the check so it only reverts when no winners have yet been drawn for that prize, that is, winnersDrawn[prizeId] == 0, instead of requiring that all winners have already been drawn. The proposed diff is:
// User claims their prize, we mark it as claimed and deactivate the prize
function claimPrize(uint256 prizeId, uint256 winnerIndex) external {
- if (prizes[prizeId].isActive && winnersDrawn[prizeId] < prizes[prizeId].quantity) {
+ if (prizes[prizeId].isActive && winnersDrawn[prizeId] == 0) { //Only check if there are 0 winners meaning `requestWinner` has yet to be called.
revert WinnerNotDrawn();
}
Winner storage individualWin = prizeWinners[prizeId][winnerIndex];
//---snip---
Reading the diff:
- Lines starting with
-are the old code being removed; lines starting with+are the new code being added. Unmarked lines are context that stays the same. - The first line is a comment describing what the function does: a user claims their prize, the contract marks it as claimed and deactivates the prize.
- The removed line is the old guard: active prize and drawn count below quantity.
- The added line replaces
< prizes[prizeId].quantitywith== 0. Now the guard fires only when the drawn count is exactly zero, meaning no winner has been picked yet. The trailing comment explains that this meansrequestWinnerhas yet to be called. revert WinnerNotDrawn();stays as it was.Winner storage individualWin = prizeWinners[prizeId][winnerIndex];looks up the record for this particular winner of this particular prize.storagemeans it refers to the data saved on the blockchain rather than a temporary copy.//---snip---marks the rest of the function, left out of the report.
The researcher validated that applying the suggested check allows winners to claim once they are drawn, even if not all winners for the prize have been selected, which resolves the issue described.
Variants to test
These are the same kinds of places to look for the same mistake in other code:
- Multi-winner prize contracts with a per-prize drawing counter: check whether the claim guard compares the counter to the prize quantity rather than to zero. A positive result is a claim that reverts with the "not drawn" error while other winners for the same prize are still pending.
- Batch drawing flows driven by an external callback (oracle or router): look for claim functions gated on the completion of the whole batch. A positive result is an early drawn winner who cannot claim until the final callback lands.
- Pause or active-flag combinations: check whether the
isActivecondition interacts with the counter so that a prize can be deactivated or left unclaimable in intermediate states. A positive result is a prize that cannot be claimed in a state the documentation says should be claimable. - Documentation-versus-code checks on "independent" claim status: for each documented independence promise, find the corresponding storage and guard. A positive result is any guard that makes one user's claim depend on another user's or the admin's action.
Hunting notes
This kind of bug hides in claim and settlement functions of games, lotteries and reward distributors, especially where winners are drawn in batches by an external callback. The signal during review is a guard that compares a progress counter against a total quantity instead of against zero or against the specific winner's state. Reading the project's own documentation for words such as "independent" and then locating the code that implements that promise is a cheap way to find the mismatch. The researcher showed impact by walking through a concrete scenario with a prize of 4 winners and 6 players, tying it to the documented invariant.
Glossary
- Admin: a privileged account allowed to perform special actions, here creating prizes and starting the drawing of winners.
- Blockchain: a shared, append-only record of transactions that many computers keep in sync, so entries cannot be quietly altered.
- Callback: a call from one program back into another after an earlier request, here the Supra Router reporting the selected winners.
- Counter: a number stored by a contract that is increased as events happen, here the count of winners drawn for a prize.
- Diff: a side-by-side style listing of code changes, with
-for removed lines and+for added lines. - Foundry: a toolkit for building and testing smart contracts locally.
forge test: the Foundry command that runs contract tests.- Function: a named block of code in a program that performs an action when called.
- Gist: a small code-sharing page used to publish snippets.
- Guard: a condition at the start of a function that decides whether the rest of the function is allowed to run.
- Invariant: a rule the project promises always holds, usually stated in documentation.
- Likelihood: how often a problem can realistically occur.
- Multi-winner prize: a prize that several participants can win, rather than a single winner.
- Oracle or router: an outside service that supplies information or performs a task on behalf of a contract, here picking winners.
- Proof of concept (PoC): a concrete demonstration, usually a test or script, that reproduces a bug.
revert: a Solidity instruction that stops execution, undoes changes and reports an error.- Severity: the seriousness rating of a finding, such as Low, Medium, High or Critical.
- Smart contract: a program deployed to a blockchain that runs as written and whose code is public.
- Solidity: the programming language used to write most smart contracts.
- Storage: data a contract keeps on the blockchain between calls.
- Supra Router: the external service in this report that selects raffle winners and calls back into the contract.
- Test: a small program that sets up a situation, performs actions and checks the outcome.
- Threshold: the value a comparison uses as its cut-off, here the prize quantity versus zero.
uint256: a Solidity whole number that cannot be negative.- Verbosity flag (
-vvvv): an option that makes a test run print detailed traces of what happened. --via-ir: a compiler option that uses the intermediate-representation pipeline when generating code.