Skip to content
Audit finding Beginner

Redundant check for allwinnersdrawn error

The report identifies a redundant error check in the requestWinner function that duplicates existing protections, but does not introduce a security vulnerability. An attacker could not exploit this to cause incorrect behaviour; the only impact is slightly higher gas usage and code complexity.

Finlooz4 Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

52918 sc insight redundant check for allwinnersdrawn error

Submitted on Aug 14th 2025 at 09:45:35 UTC by @Finlooz4 for Attackathon | Plume Network

Description

This report identifies a redundant error check in the requestWinner function: an explicit AllWinnersDrawn check duplicates behavior already enforced by the prize deactivation mechanism and thus is unnecessary.

Brief / Intro

The raffle contract contains a redundant AllWinnersDrawn error check in requestWinner. The same restriction is enforced by deactivating the prize once all winners have been drawn and by checks that prevent reactivation of completed prizes. The redundant check increases code complexity and consumes small amounts of additional gas.

Vulnerability Details

The requestWinner function contains a redundant AllWinnersDrawn check:

Solidity
if (winnersDrawn[prizeId] >= prizes[prizeId].quantity) revert AllWinnersDrawn();

This is redundant because:

  • When the last winner is selected, handleWinnerSelection deactivates the prize:
Solidity
if (winnersDrawn[prizeId] == prizes[prizeId].quantity) {
    prizes[prizeId].isActive = false;
}
  • requestWinner already checks the prize active status:
Solidity
require(prizes[prizeId].isActive, "Prize not available");
  • setPrizeActive prevents reactivation of completed prizes:
Solidity
if (active) {
    require(winnersDrawn[prizeId] < prize.quantity, "All winners already selected");
}

Because of the deactivation and reactivation prevention, attempting to request another winner after all winners are drawn will already revert via the isActive check. The explicit AllWinnersDrawn check therefore adds no additional protection.

{% hint style="info" %} The redundant check does not introduce a security vulnerability that allows incorrect behavior — it only increases gas usage and code complexity. {% endhint %}

Impact Details

  • Unnecessary condition check consumes extra gas.
  • No change in functional behavior or security guarantees; both the redundant check and the active-check path correctly prevent additional winner requests.

Proof of Concept

{% stepper %} {% step %}

Create a prize with quantity = 1

Create a prize whose quantity is 1. {% endstep %}

{% step %}

Call requestWinner() and process VRF callback

  • winnersDrawn increments to 1.
  • Prize deactivated (isActive = false). {% endstep %}

{% step %}

Attempt to call requestWinner() again

  • With the redundant check: reverts with AllWinnersDrawn error.
  • Without the redundant check: reverts with "Prize not available". {% endstep %}

{% step %}

Both outcomes correctly prevent additional winner requests

Both revert conditions prevent drawing another winner after the prize is completed. {% endstep %}

{% step %}

Conclusion

The custom AllWinnersDrawn error provides no functional advantage over the existing active-status check and related reactivation prevention. {% endstep %} {% endstepper %}

References

<details> <summary>Related code snippets / links</summary>

(See the functions and checks quoted above in the Vulnerability Details section.)

</details>

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

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

Likely the developer added an explicit check for all winners drawn without realising that the prize deactivation and reactivation prevention already enforce the same condition.

Impact

The redundant check only consumes extra gas and adds code complexity; it does not change functional behaviour or security guarantees.

What the attacker needed

None

The fix

The redundant AllWinnersDrawn check should be removed to simplify the code and save gas.

How it was found

  1. Create a prize with quantity equal to 1.
  2. Call requestWinner and process the VRF callback so winnersDrawn becomes 1 and the prize is deactivated.
  3. Attempt to call requestWinner again; it reverts either with AllWinnersDrawn or with 'Prize not available'.
  4. Both outcomes correctly prevent drawing another 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.

This report is about a smart contract that runs a raffle. The author noticed that one safety check is unnecessary because other checks already stop the same thing from happening. It is not a security bug; it just makes the code slightly less efficient.

More by Finlooz4

View all

2 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.