Skip to content
Business logic Audit finding Intermediate

Wrapped week index can mis price jackpot table after long uptime

The Spin contract casts the current week from a 256-bit integer to an 8-bit integer when selecting a jackpot prize, so after week 255 the week number wraps around to an early week. An attacker could then win jackpot prizes that should no longer be available, draining contract funds over time.

spongebob Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

52901 sc low wrapped week index can mis price jackpot table after long uptime

Submitted on Aug 14th 2025 at 08:01:53 UTC by @spongebob for Attackathon | Plume Network

Description

The Spin contract has an underflow/wrap bug in the determineReward() function that allows unauthorized distribution of jackpot prizes after week 255.

Relevant code references:

getCurrentWeek() returns a uint256 current campaign week, but this value is cast to uint8 when used to index jackpot prizes. Because uint8 max is 255, any week ≥ 256 wraps (e.g., 256 -> 0, 257 -> 1). The wrapped value is then used to access jackpotPrizes[weekNumber], which can return prizes from early campaign weeks when the campaign should have ended.

The campaign is designed to last only 12 weeks (weeks 0–11), as shown by getWeeklyJackpot() returning zero for weeks beyond 11:

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/spin/Spin.sol#L425-L427

Jackpot prizes are only initialized for weeks 0–11 during contract initialization:

https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/plume/src/spin/Spin.sol#L107-L118

This creates an inconsistency: jackpot eligibility checks correctly use the full uint256 week value for weekly limits, but prize selection uses the wrapped uint8 value, allowing users to receive jackpot prizes when the campaign should be over.

Impact

After week 255, users can win jackpot prizes that should remain unclaimed, since the campaign should have ended after week 11. Because the contract tracks lastJackpotClaimWeek (using the full uint256 week), this allows one jackpot payout per (wrapped) week, enabling a continuous drain on contract funds over time.

Proof of Concept

Setup:

  • The Spin contract is deployed and initialized with jackpot prizes for weeks 0–11.
  • The campaign has been running for 255+ weeks (≈ 5+ years).
  • An attacker has sufficient streak count and funds to spin.

{% stepper %} {% step %}

Verify Current Week State

  • Confirm getCurrentWeek() returns a value ≥ 256 (e.g., 256).
  • Verify getWeeklyJackpot() correctly returns (256, 0, 0) (no jackpot should be available). {% endstep %}

{% step %}

User Initiates Spin

  • User calls startSpin() with correct payment.
  • Contract accepts the spin because basic eligibility checks pass.
  • An oracle request is generated and pending. {% endstep %}

{% step %}

Oracle Callback Triggers Bug

  • Oracle calls handleRandomness() with a low random number (e.g., 0).
  • determineReward() is invoked with this randomness. {% endstep %}

{% step %}

Week Number Wrapping

  • getCurrentWeek() returns 256.
  • Casting to uint8 wraps 256 to 0.
  • weekNumber becomes 0 instead of 256. {% endstep %}

{% step %}

Jackpot Prize Access

  • Code accesses jackpotPrizes[0] (week 0 prize) instead of jackpotPrizes[256].
  • Returns week 0's jackpot prize (e.g., 5000 tokens) instead of 0. {% endstep %}

{% step %}

Eligibility Bypass

  • The eligibility checks in handleRandomness() use the correct uint256 week value.
  • currentWeek (256) ≠ lastJackpotClaimWeek (likely < 256), so the weekly limit check passes.
  • If the user meets the streak requirement, jackpot distribution proceeds. {% endstep %}

{% step %}

Unauthorized Reward Distribution

  • User receives the week 0 jackpot (e.g., 5000 PLUME).
  • lastJackpotClaimWeek is updated to 256.
  • Contract transfers tokens that should not have been distributed. {% endstep %}

{% step %}

Repeated Exploitation

  • The process can repeat weekly as getCurrentWeek() keeps incrementing.
  • Week 257 wraps to 1 (returns week 1 prize), week 258 wraps to 2, etc.
  • This leads to a continuous unauthorized drain of protocol funds. {% endstep %} {% endstepper %}

References

The original report as published on Immunefi, by spongebob. 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 current week, returned as a large integer, is cast to a small 8-bit integer before indexing the jackpot prize array, causing the value to wrap after 255.

Impact

After week 255, users could win jackpot prizes that should remain unclaimed, allowing a continuous drain on contract funds over time.

What the attacker needed

Campaign running for 255+ weeks; attacker has sufficient streak count; attacker has funds to spin

The fix

The week value should be kept as a full-width integer when indexing the jackpot prize array, or the campaign should be explicitly ended before the counter can exceed the array bounds.

How it was found

  1. Confirm the current week is 256 or more and that the weekly jackpot lookup returns zero.
  2. Call startSpin with the correct payment so the spin is accepted and an oracle request is pending.
  3. The oracle calls handleRandomness with a low random number, invoking determineReward.
  4. The week number 256 is cast to uint8 and wraps to 0, so the week 0 jackpot prize is selected.
  5. Eligibility checks use the full week value, so the weekly limit check passes and the jackpot is paid out.
  6. Repeat each week as the counter increments, wrapping to week 1, week 2 and so on.

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 number stored in a small container can only hold values up to a limit; when it goes past that limit it starts again from zero. Here the week counter is squeezed into a tiny container that holds at most 255, so week 256 looks like week 0. That makes the contract hand out old jackpot prizes long after the campaign should have ended.

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 spongebob

View all

15 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.