Skip to content
Business logic Audit finding Intermediate

Off by one error in jackpot eligibility check leads to denial of legitimate rewards

The Spin contract's jackpot eligibility check uses the pre-spin streak count instead of the post-spin streak, so a user who reaches the required streak exactly on the winning spin is incorrectly denied the jackpot. This causes legitimate winners to receive nothing and leaves jackpot funds undistributed.

OxPrince Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52286 sc high off by one error in jackpot eligibility check leads to denial of legitimate rewards

Submitted on Aug 9th 2025 at 14:04:30 UTC by @OxPrince for Attackathon | Plume Network

Description

Brief/Intro

The Spin contract contains a critical off-by-one error in its jackpot eligibility verification logic where it uses stale pre-spin streak data instead of the correctly computed post-spin streak value. This bug systematically denies jackpot rewards to users who achieve the required streak exactly through their winning spin, causing legitimate winners to receive "Nothing" instead of their earned jackpot prizes. In production, this would result in unfair denial of potentially thousands of dollars worth of jackpot rewards to qualifying users.

Vulnerability Details

The vulnerability exists in the handleRandomness function (Spin.sol:207-265) where there's an inconsistency between how the streak is calculated and how it's used for jackpot eligibility checks.

Problem flow summary:

  • Correct post-spin streak calculation: The function properly computes the updated streak that accounts for the current spin (Spin.sol:217).
  • Inconsistent jackpot eligibility check: The jackpot eligibility verification uses the stored pre-spin streak value instead of the computed post-spin value (Spin.sol:232).
  • Late streak update: The streak is only updated to the correct post-spin value after all reward logic completes (Spin.sol:253).
  • Inconsistent behavior with other rewards: Other rewards like raffle tickets correctly use the post-spin streak for their calculations (Spin.sol:298).

The _computeStreak function with justSpun = true correctly accounts for the current spin's contribution to the streak (Spin.sol:307-325), but this computed value is ignored for jackpot eligibility checks.

The required streak increases weekly (currentWeek + 2) as shown in the getWeeklyJackpot function (Spin.sol:430), making this edge case particularly impactful for users who are exactly one spin away from the requirement.

Impact Details

  • Users who legitimately qualify for jackpots through their winning spin are systematically denied their rewards.
  • The jackpot funds remain in the contract rather than being distributed to rightful winners.

References

Proof of Concept

{% stepper %} {% step %}

PoC — Step

User has streak count of 1. {% endstep %}

{% step %}

PoC — Step

User spins and gets jackpot-winning randomness (e.g., randomness = 0). {% endstep %}

{% step %}

PoC — Step

handleRandomness is called:

  • currentSpinStreak is correctly computed as 2 (accounting for current spin).
  • determineReward returns ("Jackpot", jackpotAmount) based on randomness.
  • Jackpot eligibility check uses userDataStorage.streakCount (value: 1) instead of currentSpinStreak (value: 2).
  • Check fails: 1 < (0 + 2) evaluates to true.
  • Reward is downgraded to "Nothing" and NotEnoughStreak event is emitted. {% endstep %}

{% step %}

PoC — Step

User's streak is updated to 2 after the reward logic, but it's too late.

Expected behavior: User should receive the jackpot since their post-spin streak (2) meets the requirement (2).

Actual behavior: User receives "Nothing" due to the stale pre-spin streak value being used in the eligibility check.

This edge case is not covered by the test testJackpotInsufficientThenSufficientStreak (Spin.t.sol:643-697), which checks multi-day progression but not the case where the qualifying streak is achieved on the same spin as the jackpot win. {% endstep %} {% endstepper %}

Recommendation

Replace the pre-spin streak reference with the computed post-spin streak in the jackpot eligibility check. Specifically, change the condition in handleRandomness to use currentSpinStreak instead of userDataStorage.streakCount:

{% code title="Spin.sol — suggested change" %}

Solidity
} else if (currentSpinStreak < (currentWeek + 2)) {

{% endcode %}

This ensures jackpot eligibility uses the same post-spin streak value as other reward calculations, maintaining consistency and fairness.

{% hint style="warning" %} Do not change the required streak logic—only ensure the eligibility check uses the up-to-date streak computed for the current spin. {% endhint %}

The original report as published on Immunefi, by OxPrince. 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

Impact

Users who legitimately qualify for a jackpot through their winning spin are systematically denied their rewards, and the jackpot funds remain in the contract.

What the attacker needed

User has a streak one below the required number; user's spin yields a jackpot-winning random result

The fix

The jackpot eligibility check should use the computed post-spin streak value instead of the stored pre-spin streak count.

How it was found

  1. User has a streak count of 1.
  2. User spins and gets a jackpot-winning random result.
  3. The contract computes the new streak as 2 but checks eligibility using the old streak of 1.
  4. The check fails, so the reward is downgraded to 'Nothing'.
  5. The streak is updated to 2 only after the reward logic, too late to matter.

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.

A smart contract is a program on a blockchain that automatically handles things like rewards. Here, the contract checks if a player has spun the wheel enough times to win a jackpot, but it looks at the old count before adding the current spin, so someone who just reached the needed number is wrongly told they haven't spun enough. The fix is to use the updated count when deciding if they win.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by OxPrince

View all

20 more disclosed reports, best first.

More from Plume Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.