49768 sc insight missing input validation in raffle editprize breaks functionality
Submitted on Jul 19th 2025 at 09:43:06 UTC by @blackgrease for Attackathon | Plume Network
Report ID: #49768
Report Type: Smart Contract
Report severity: Insight
Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/spin/Raffle.sol
Impacts:
Contract fails to deliver promised returns, but doesn't lose value
Summary
During prize creation, prizes can exist with the same name. Raffle::addPrize validates quantity input while Raffle::editPrize does not, allowing an admin to edit a prize to have 0 winners. Both functions also do not validate name (allowing duplicate prize names) or value (allowing 0-value prizes).
Description
Issue #1
addPrizedoes not validate thenameparameter, allowing multiple prizes with the same name which can confuse users.
Issue #2
editPrizedoes not validatequantity,value, orname.quantitymust be > 0 per intended design; omitting this validation allows a prize to be set to 0 winners.addPrizevalidatesquantity, buteditPrizedoes not — inconsistent validation leads to incorrect states after edits.
Exploitation
Accidental misconfiguration by an admin may set
quantityto 0 causing users to lose raffle tickets for that prize (no winners will be selected).A malicious admin could create a valid prize and later edit it to 0 winners or duplicate names after users have joined.
High-level issue path: Admin creates prize -> Users join prize -> Admin edits prize to 0 winners -> requestWinner fails due to checks -> users wait indefinitely.
Affected functions
Raffle::addPrize()
Raffle::editPrize()
Impact
Logic error resulting in:
Prizes with
quantity = 0meaning no winners can be drawn and users who joined may effectively lose their raffle tickets.Duplicate prize names causing user confusion.
requestWinnerwill incorrectly revert withAllWinnersDrawn()whenquantityis 0 (sincewinnersDrawn[prizeId] >= prizes[prizeId].quantity), causing admin to assume prize completed while users wait indefinitely.Low severity overall since no funds are directly lost, but user experience and promised returns are broken. A malicious or mistaken admin can cause harm.
Mitigation (recommended)
Enforce the same checks in
editPrizeas inaddPrize.Validate
value > 0in both functions.Prevent duplicate prize names (e.g., mapping of name hash to existence), with appropriate handling for edits (allow editing the same prize name).
Consider checking that a prize is active in
requestWinnerbefore proceeding.
Suggested validation additions are shown below.
Improved Validation in Raffle::addPrize
Raffle::addPrizeImproved Validation in editPrize
editPrizeNote: The simple prizeNameExists approach requires careful handling during edits (allowing the same prize to keep its name, updating mapping on name changes, etc.). Implement logic to clear the old name hash and set the new one atomically when editing.
Proof of Concept
PoC (private gist): https://gist.github.com/blackgrease/d9d093be8f1b295122a2d3ae61eee305
Run test with:
Notes
Both
addPrizeandeditPrizedo not validatevalueallowing prizes of zero value.When implementing name-uniqueness checks, ensure edit flows allow retaining the same name for the same prize and properly update any name-existence mappings on name changes.
If you want, I can:
Propose a more complete, edit-safe implementation (with mapping updates on name change and proper checks),
Draft unit tests to cover these edge cases (adding duplicates, editing to zero quantity,
requestWinnerfailure), orProduce a minimal patch/PR diff ready to apply to the repo.
Was this helpful?