When the tournament owner sets a winner, the contract later calculates each participant’s reward proportionally to their shares using the formula:
Here, totalWinnerShares represents the total shares of users who selected the winning option.
However, if the owner sets a winner that no user has selected, then totalWinnerShares becomes 0.
Any subsequent call to withdraw() or other reward-claiming functions will revert with a division-by-zero error inside Math.mulDiv, permanently preventing anyone from claiming or withdrawing funds.
This leads to a complete vault lockup — no participants can withdraw, and the event’s assets remain frozen.
Likelihood: Medium
The owner can accidentally (or maliciously) set a winner that no one chose.
The condition is rare but trivial to trigger intentionally.
Impact: High
Causes a global denial of service: all withdrawals revert.
Locks all user funds in the vault permanently.
No user or admin can recover assets unless a separate rescue mechanism exists.
Add this test to your test/briVault.t.sol suite:
Run with:
Add a guard clause to handle the edge case where no one picked the winning option:
When no one bet on the winning team, making totalWinnerShares = 0, causing division by zero in withdraw and preventing any withdrawals.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.