The jackpot eligibility check uses stale storage data instead of the freshly calculated streak.
The jackpot eligibility check in the Spin contract reads the streak count from storage before it is updated, so it uses the previous spin's streak instead of the freshly calculated one. A user who legitimately wins a jackpot based on their current streak can be wrongly denied the prize.
Plume Network
Originally disclosed on Immunefi
53047 sc high the jackpot eligibility check uses stale storage data instead of the freshly calculated streak
- Report ID: #53047
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/plume/src/spin/Spin.sol
- Impacts: Theft of unclaimed yield
Description
Brief / Intro
The Spin.sol contract has an incorrect update logic flaw in the handleRandomness() function where jackpot eligibility verification uses stale streak data from storage instead of the freshly calculated streak value used for reward determination. This inconsistency causes legitimate users to be wrongfully denied jackpot wins, particularly affecting first-time users and users rebuilding their streaks. The vulnerability undermines the core game mechanics and can result in significant economic losses for users who should have won high-value jackpot prizes.
Vulnerability Details
The vulnerability exists in the handleRandomness() function in Spin.sol. The root cause is a temporal mismatch between streak calculation and streak validation:
// Line 216: Calculate fresh streak for current spin
uint256 currentSpinStreak = _computeStreak(user, block.timestamp, true);
// Line 218: Use fresh streak for reward determination
(string memory rewardCategory, uint256 rewardAmount) = determineReward(randomness, currentSpinStreak);
// Lines 225-232: Jackpot eligibility check uses STALE data
if (keccak256(bytes(rewardCategory)) == keccak256("Jackpot")) {
uint256 currentWeek = getCurrentWeek();
if (currentWeek == lastJackpotClaimWeek) {
// ... weekly limit check ...
} else if (userDataStorage.streakCount < (currentWeek + 2)) { // ❌ USES OLD STREAK
userDataStorage.nothingCounts += 1;
rewardCategory = "Nothing";
rewardAmount = 0;
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
}
userDataStorage.streakCount < (currentWeek + 2) uses the previous spin's streak value stored in userDataStorage.streakCount, while the reward determination used currentSpinStreak which reflects the updated streak after the current spin.
The _computeStreak() function logic:
function _computeStreak(address user, uint256 nowTs, bool justSpun) internal view returns (uint256) {
uint256 streakAdjustment = justSpun ? 1 : 0;
uint256 lastSpinTs = userData[user].lastSpinTimestamp;
if (lastSpinTs == 0) {
return 0 + streakAdjustment; // First-time user returns 1
}
// ... consecutive day logic ...
return 0 + streakAdjustment; // Broken streak returns 1
}
When justSpun = true, this function adds 1 to account for the current spin, but the jackpot eligibility check doesn't see this updated value.
Impact Details
Users who legitimately win jackpots based on correct streak calculations are denied their winnings.
References
- plume/src/spin/Spin.sol
- Vulnerable function:
handleRandomness() - Streak calculation:
_computeStreak()
Proof of Concept
{% stepper %} {% step %}
Day 1 Setup
// New user spins for first time
userData[user].streakCount = 0;
userData[user].lastSpinTimestamp = 0;
// After Day 1 spin completes:
userData[user].streakCount = 1;
userData[user].lastSpinTimestamp = day1_timestamp;
{% endstep %}
{% step %}
Day 2
// User spins next day (Week 0 - requires streak >= 2 for jackpot)
uint256 currentSpinStreak = _computeStreak(user, day2_timestamp, true);
// Returns: 1 + 1 = 2 (consecutive day bonus)
// Reward determination uses fresh streak
(rewardCategory, rewardAmount) = determineReward(randomness, 2); // currentSpinStreak = 2
// Returns: ("Jackpot", 5000) - User wins!
// Eligibility check uses stale data (BUG)
if (userDataStorage.streakCount < (currentWeek + 2)) { // 1 < 2 = TRUE
// DENIED! Uses old streak (1) instead of current streak (2)
rewardCategory = "Nothing";
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
// Storage updated AFTER denial
userDataStorage.streakCount = currentSpinStreak; // Finally becomes 2
Result: User with legitimate 2-day streak is denied 5,000 PLUME jackpot because eligibility check uses the previous streak value (1) while reward calculation used the current streak (2). {% endstep %} {% endstepper %}
Context
Plume Network's spin game lives in Spin.sol, a smart contract that lets a user spin a wheel, build a daily streak, and win rewards. The reward category and amount are decided from a randomness value together with the user's current streak. One of the possible outcomes is a jackpot, which is gated behind a minimum streak requirement that grows with the current week.
The target of this report is the contract at plume/src/spin/Spin.sol in the immunefi-team/attackathon-plume-network repository. The reported impact is theft of unclaimed yield, and the report is rated High severity.
The feature that misbehaves is the jackpot eligibility check inside handleRandomness(). In normal operation a user who has spun on consecutive days should see their streak increase by one for the current spin, and that fresh value should be the one used to decide whether they qualify for the jackpot. The report shows that the eligibility check instead reads the streak value left in storage by the previous spin.
Setup
The only preconditions it establishes are the ones that follow from the game logic itself:
- A user who has never spun before, or a user whose streak has been broken, starts from a streak of zero in storage.
- The jackpot requirement for a given week is
currentWeek + 2. - The reward determination and the eligibility check must both run within the same call to
handleRandomness().
Finding it
The researcher noticed a temporal mismatch between two values that are supposed to describe the same thing: the streak used to pick the reward, and the streak used to decide whether the jackpot is allowed. The fresh streak is computed at the top of handleRandomness() and passed into determineReward(), but the jackpot branch further down reads userDataStorage.streakCount directly from storage, which still holds the value from before the current spin was accounted for.
The relevant excerpt from handleRandomness():
// Line 216: Calculate fresh streak for current spin
uint256 currentSpinStreak = _computeStreak(user, block.timestamp, true);
// Line 218: Use fresh streak for reward determination
(string memory rewardCategory, uint256 rewardAmount) = determineReward(randomness, currentSpinStreak);
// Lines 225-232: Jackpot eligibility check uses STALE data
if (keccak256(bytes(rewardCategory)) == keccak256("Jackpot")) {
uint256 currentWeek = getCurrentWeek();
if (currentWeek == lastJackpotClaimWeek) {
// ... weekly limit check ...
} else if (userDataStorage.streakCount < (currentWeek + 2)) { // ❌ USES OLD STREAK
userDataStorage.nothingCounts += 1;
rewardCategory = "Nothing";
rewardAmount = 0;
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
}
The comparison userDataStorage.streakCount < (currentWeek + 2) is the line that looked wrong. It is evaluated against the previous spin's streak, while the reward was already chosen using currentSpinStreak, which includes the current spin.
The streak calculation itself is what makes the discrepancy visible. The report shows the shape of _computeStreak():
function _computeStreak(address user, uint256 nowTs, bool justSpun) internal view returns (uint256) {
uint256 streakAdjustment = justSpun ? 1 : 0;
uint256 lastSpinTs = userData[user].lastSpinTimestamp;
if (lastSpinTs == 0) {
return 0 + streakAdjustment; // First-time user returns 1
}
// ... consecutive day logic ...
return 0 + streakAdjustment; // Broken streak returns 1
}
When justSpun is true, the function adds one to account for the spin being processed. The jackpot eligibility check never sees that addition, so a user whose stored streak is one short of the threshold is rejected even though the freshly computed streak meets it.
Exploitation
The report frames this as a correctness bug that harms legitimate users rather than as an attack an adversary performs. The proof of concept walks through a two-day scenario for a new user.
Day 1 setup
// New user spins for first time
userData[user].streakCount = 0;
userData[user].lastSpinTimestamp = 0;
// After Day 1 spin completes:
userData[user].streakCount = 1;
userData[user].lastSpinTimestamp = day1_timestamp;
A brand new user begins with a stored streak of zero and no last spin timestamp. After the first spin completes, storage holds a streak of one and the timestamp of that first spin.
Day 2
// User spins next day (Week 0 - requires streak >= 2 for jackpot)
uint256 currentSpinStreak = _computeStreak(user, day2_timestamp, true);
// Returns: 1 + 1 = 2 (consecutive day bonus)
// Reward determination uses fresh streak
(rewardCategory, rewardAmount) = determineReward(randomness, 2); // currentSpinStreak = 2
// Returns: ("Jackpot", 5000) - User wins!
// Eligibility check uses stale data (BUG)
if (userDataStorage.streakCount < (currentWeek + 2)) { // 1 < 2 = TRUE
// DENIED! Uses old streak (1) instead of current streak (2)
rewardCategory = "Nothing";
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
// Storage updated AFTER denial
userDataStorage.streakCount = currentSpinStreak; // Finally becomes 2
The user spins the next day, in week 0, where the jackpot requires a streak of at least two. _computeStreak() returns two because the consecutive day logic adds the current spin to the stored streak of one. determineReward() is called with that fresh value of two and returns a jackpot of 5,000 PLUME.
The eligibility check then runs against userDataStorage.streakCount, which is still one. The comparison 1 < 2 is true, so the reward is overwritten to "Nothing" with an amount of zero and a NotEnoughStreak event is emitted. Only afterwards is storage updated to the fresh streak of two.
The result, in the report's words: a user with a legitimate two-day streak is denied a 5,000 PLUME jackpot because the eligibility check uses the previous streak value of one while the reward calculation used the current streak of two.
Root cause
The bug is an ordering and data-source mistake. handleRandomness() computes the authoritative streak for the current spin into a local variable, uses it for reward selection, and then validates jackpot eligibility against a different source: the storage field that has not yet been updated for this spin. The two checks therefore disagree by exactly one spin's worth of streak.
The report notes that this affects first-time users and users rebuilding a broken streak in particular. Both cases are the ones where _computeStreak() returns 0 + streakAdjustment, so the gap between the stored value and the fresh value is most likely to straddle the currentWeek + 2 threshold.
Impact
Users who legitimately win a jackpot under the correct streak calculation are denied their winnings. The reward is replaced with "Nothing", the amount is set to zero, and nothingCounts is incremented. The report describes this as undermining the core game mechanics and as potentially causing significant economic losses for users who should have won high-value jackpot prizes, and classifies the impact as theft of unclaimed yield.
Fix
The report does not state that a fix was applied, and it does not propose a specific patch.
- Look for any function that computes a derived value into a local variable and then validates a condition against the pre-update storage field. A positive result is a branch where the local and stored values can differ by one step and the branch outcome flips.
- Check reward or eligibility gates that depend on counters incremented later in the same transaction, such as streak counters, spin counts or claim counts. A positive result is a user who meets the threshold after the increment but is rejected before it.
- Test first-time and streak-reset paths specifically, since those are the paths where the computed value jumps from zero to one. A positive result is a rejection that disappears on the user's next interaction.
- Compare the value passed into reward selection with the value used in any subsequent guard in the same function. A positive result is any guard that reads storage rather than the local variable.
This class of bug hides in state machines where a value is both derived and persisted in the same call: streak counters, daily limits, tier upgrades and loyalty multipliers are typical places. During review, the signal is a function that assigns a freshly computed value to a local variable and then, a few lines later, reads the same concept back from storage. Grepping for the storage field name alongside the local variable name usually surfaces it quickly.
The report establishes impact by walking a concrete two-day scenario through the exact lines involved, showing the fresh streak of two, the stored streak of one, the jackpot that determineReward() returns, and the overwrite to "Nothing". That line-by-line trace, tied to a named reward amount, is what makes the denial of a legitimate payout legible to a reviewer.
What happened, in plain words
Plume Network runs a spin game. You spin a wheel, you get a reward, and if you come back on consecutive days your "streak" grows. A streak is simply a counter of how many days in a row you have played. The bigger your streak, the better the prizes you can win, and one special prize, the jackpot, is only allowed once your streak reaches a minimum that depends on which week of the game it is.
The game is implemented as a smart contract called Spin.sol. A smart contract is a program that lives on a blockchain: it runs the same way for everyone, its code is public, and it holds money (in this case a token called PLUME) that it pays out according to its own rules. Nobody can quietly change the rules after the fact, which is why bugs in the rules matter so much: they play out exactly as written, every time.
The bug in this report is a mix-up between two versions of the same number. When you spin, the contract works out your streak for this spin (say, two days in a row). It uses that fresh number to decide what you win, and it correctly decides you have won the jackpot. But then, a few lines later, it checks whether you are allowed to have the jackpot, and for that check it reads the streak value saved from your previous spin (one day). One is less than the two required, so the contract takes the jackpot away, replaces it with "Nothing", and records that you did not have enough streak. Only after that does it save your new streak of two.
The result is that a player who genuinely earned the jackpot is refused it. The report rates this High severity and describes the impact as theft of unclaimed yield, meaning money that should have been paid out to users but was not.
Background you need first
A few ideas come up repeatedly, so here they are from zero.
Smart contract. A small program deployed to a blockchain. It has its own storage (a kind of permanent notebook) and can hold and send tokens. Functions in the contract are the only way to interact with it.
Storage versus local variable. Storage is the contract's permanent notebook: anything written there survives between transactions. A local variable is a temporary scrap of paper used inside a single function call; it disappears when the call ends. A common bug pattern is to compute something correctly on the scrap of paper and then check a rule against the old notebook entry instead.
Streak. A count of consecutive days on which a user has spun. Spin today after spinning yesterday and your streak goes up by one. Miss a day and it resets.
Randomness. The spin result is chosen from a random value, so the outcome is not predictable in advance. The contract takes that random value plus your streak and turns them into a reward category (for example "Jackpot") and a reward amount.
Event. A short message a contract writes to a log when something notable happens, so that outside software (wallets, dashboards, block explorers) can notice it. Here the contract emits an event called NotEnoughStreak when it denies a jackpot.
Transaction. A single action sent to the blockchain. Everything a function does, including all its storage reads and writes, happens inside one transaction, in order, top to bottom.
Context
The spin game lives in Spin.sol, a smart contract that lets a user spin a wheel, build a daily streak, and win rewards. The reward category and amount are decided from a randomness value together with the user's current streak. One of the possible outcomes is a jackpot, which is gated behind a minimum streak requirement that grows with the current week.
The target of this report is the contract at plume/src/spin/Spin.sol in the immunefi-team/attackathon-plume-network repository. The reported impact is theft of unclaimed yield, and the report is rated High severity.
The feature that misbehaves is the jackpot eligibility check inside handleRandomness(). In normal operation a user who has spun on consecutive days should see their streak increase by one for the current spin, and that fresh value should be the one used to decide whether they qualify for the jackpot. The report shows that the eligibility check instead reads the streak value left in storage by the previous spin.
Setup
The only preconditions it establishes are the ones that follow from the game logic itself:
- A user who has never spun before, or a user whose streak has been broken, starts from a streak of zero in storage.
- The jackpot requirement for a given week is
currentWeek + 2. - The reward determination and the eligibility check must both run within the same call to
handleRandomness().
Point 3 is the heart of it. Because both checks happen inside one function call, the contract has a chance to use two different values for the same concept within a few lines of each other, and that is exactly what goes wrong.
Finding it
The researcher noticed a temporal mismatch between two values that are supposed to describe the same thing: the streak used to pick the reward, and the streak used to decide whether the jackpot is allowed. "Temporal" here just means "in time": one value is the state of the world after this spin, the other is the state before it. The fresh streak is computed at the top of handleRandomness() and passed into determineReward(), but the jackpot branch further down reads userDataStorage.streakCount directly from storage, which still holds the value from before the current spin was accounted for.
The relevant excerpt from handleRandomness():
// Line 216: Calculate fresh streak for current spin
uint256 currentSpinStreak = _computeStreak(user, block.timestamp, true);
// Line 218: Use fresh streak for reward determination
(string memory rewardCategory, uint256 rewardAmount) = determineReward(randomness, currentSpinStreak);
// Lines 225-232: Jackpot eligibility check uses STALE data
if (keccak256(bytes(rewardCategory)) == keccak256("Jackpot")) {
uint256 currentWeek = getCurrentWeek();
if (currentWeek == lastJackpotClaimWeek) {
// ... weekly limit check ...
} else if (userDataStorage.streakCount < (currentWeek + 2)) { // ❌ USES OLD STREAK
userDataStorage.nothingCounts += 1;
rewardCategory = "Nothing";
rewardAmount = 0;
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
}
Line by line:
uint256 currentSpinStreak = _computeStreak(user, block.timestamp, true);asks a helper function to work out the user's streak including the spin happening right now, and stores the answer in a temporary variable.block.timestampis the current time according to the blockchain, and thetrueis a flag meaning "a spin is happening now".(string memory rewardCategory, uint256 rewardAmount) = determineReward(randomness, currentSpinStreak);picks the prize. It hands the random value and the fresh streak todetermineReward()and receives back two things: the name of the prize category and the amount.if (keccak256(bytes(rewardCategory)) == keccak256("Jackpot"))is a string comparison. Solidity cannot compare text directly, so it converts both strings to fixed-length fingerprints (hashes) withkeccak256and compares those. In plain words: "if the prize we just picked is the jackpot, then...".uint256 currentWeek = getCurrentWeek();fetches which week of the game we are in.if (currentWeek == lastJackpotClaimWeek)handles the case where a jackpot was already claimed this week, and the comment says a weekly limit check follows there.else if (userDataStorage.streakCount < (currentWeek + 2))is the faulty line. It reads the streak from permanent storage, which has not yet been updated for this spin, and compares it with the week's requirement. The comment marks it as using the old streak.- Inside that branch,
userDataStorage.nothingCounts += 1;increases a counter of how many times the user got nothing,rewardCategory = "Nothing";andrewardAmount = 0;overwrite the prize that was already chosen, andemit NotEnoughStreak(...)writes a log message saying the streak was too short.
The comparison userDataStorage.streakCount < (currentWeek + 2) is the line that looked wrong. It is evaluated against the previous spin's streak, while the reward was already chosen using currentSpinStreak, which includes the current spin.
The streak calculation itself is what makes the discrepancy visible. The report shows the shape of _computeStreak():
function _computeStreak(address user, uint256 nowTs, bool justSpun) internal view returns (uint256) {
uint256 streakAdjustment = justSpun ? 1 : 0;
uint256 lastSpinTs = userData[user].lastSpinTimestamp;
if (lastSpinTs == 0) {
return 0 + streakAdjustment; // First-time user returns 1
}
// ... consecutive day logic ...
return 0 + streakAdjustment; // Broken streak returns 1
}
Line by line:
function _computeStreak(address user, uint256 nowTs, bool justSpun) internal view returns (uint256)declares a helper that takes a user address, a timestamp and a yes/no flag saying whether a spin is being processed, and returns a number.internalmeans only the contract itself can call it, andviewmeans it only reads data and changes nothing.uint256 streakAdjustment = justSpun ? 1 : 0;sets the adjustment to 1 if a spin is happening now, otherwise 0. This is the "add one for today's spin" step.uint256 lastSpinTs = userData[user].lastSpinTimestamp;reads when this user last spun, from storage.if (lastSpinTs == 0)handles a user who has never spun: there is no previous spin, so the streak is just the adjustment, which is 1 when a spin is in progress.- The comment
// ... consecutive day logic ...stands in for the part of the function that checks whether the last spin was yesterday and would extend the streak; the report does not reproduce it. return 0 + streakAdjustment;is the broken-streak path: if the user missed a day, the streak restarts from zero plus today's spin, which is 1.
When justSpun is true, the function adds one to account for the spin being processed. The jackpot eligibility check never sees that addition, so a user whose stored streak is one short of the threshold is rejected even though the freshly computed streak meets it.
Exploitation
The report frames this as a correctness bug that harms legitimate users rather than as an attack an adversary performs. In other words, nobody has to do anything clever to trigger it: an ordinary player following the rules hits it. The proof of concept walks through a two-day scenario for a new user.
Day 1 setup
// New user spins for first time
userData[user].streakCount = 0;
userData[user].lastSpinTimestamp = 0;
// After Day 1 spin completes:
userData[user].streakCount = 1;
userData[user].lastSpinTimestamp = day1_timestamp;
Line by line:
userData[user].streakCount = 0;anduserData[user].lastSpinTimestamp = 0;describe the starting state of a brand new user: a stored streak of zero and no record of a previous spin (timestamp zero is used as "never").userData[user].streakCount = 1;anduserData[user].lastSpinTimestamp = day1_timestamp;describe the state after the first spin finishes: the stored streak is now one, and the contract remembers when that spin happened.
This step is included because the bug only shows up when the stored streak and the freshly computed streak differ. A new user is the cleanest example: storage says zero, the fresh calculation says one.
Day 2
// User spins next day (Week 0 - requires streak >= 2 for jackpot)
uint256 currentSpinStreak = _computeStreak(user, day2_timestamp, true);
// Returns: 1 + 1 = 2 (consecutive day bonus)
// Reward determination uses fresh streak
(rewardCategory, rewardAmount) = determineReward(randomness, 2); // currentSpinStreak = 2
// Returns: ("Jackpot", 5000) - User wins!
// Eligibility check uses stale data (BUG)
if (userDataStorage.streakCount < (currentWeek + 2)) { // 1 < 2 = TRUE
// DENIED! Uses old streak (1) instead of current streak (2)
rewardCategory = "Nothing";
emit NotEnoughStreak("Not enough streak count to claim Jackpot");
}
// Storage updated AFTER denial
userDataStorage.streakCount = currentSpinStreak; // Finally becomes 2
Line by line:
- The comment notes this is week 0, where the jackpot needs a streak of at least two, because the requirement is
currentWeek + 2and0 + 2 = 2. uint256 currentSpinStreak = _computeStreak(user, day2_timestamp, true);computes the streak for today's spin. The comment says it returns1 + 1 = 2: the stored streak of one plus one for the consecutive day.(rewardCategory, rewardAmount) = determineReward(randomness, 2);picks the prize using the fresh streak of two. The comment says it returns("Jackpot", 5000), so the user has won 5,000 PLUME.if (userDataStorage.streakCount < (currentWeek + 2))then checks eligibility against storage, which still says one. The comment spells out the arithmetic:1 < 2is true.- Inside the branch,
rewardCategory = "Nothing";throws away the jackpot andemit NotEnoughStreak("Not enough streak count to claim Jackpot");logs the denial. The comment marks this as the moment the user is denied, using the old streak of one instead of the current streak of two. userDataStorage.streakCount = currentSpinStreak;finally saves the streak of two, but only after the denial has already happened.
The user spins the next day, in week 0, where the jackpot requires a streak of at least two. _computeStreak() returns two because the consecutive day logic adds the current spin to the stored streak of one. determineReward() is called with that fresh value of two and returns a jackpot of 5,000 PLUME.
The eligibility check then runs against userDataStorage.streakCount, which is still one. The comparison 1 < 2 is true, so the reward is overwritten to "Nothing" with an amount of zero and a NotEnoughStreak event is emitted. Only afterwards is storage updated to the fresh streak of two.
The result, in the report's words: a user with a legitimate two-day streak is denied a 5,000 PLUME jackpot because the eligibility check uses the previous streak value of one while the reward calculation used the current streak of two.
Root cause
The bug is an ordering and data-source mistake. handleRandomness() computes the authoritative streak for the current spin into a local variable, uses it for reward selection, and then validates jackpot eligibility against a different source: the storage field that has not yet been updated for this spin. The two checks therefore disagree by exactly one spin's worth of streak.
Both numbers describe the same product, but one was updated and the other was not, so the customer gets refused a purchase they should be allowed to make.
The report notes that this affects first-time users and users rebuilding a broken streak in particular. Both cases are the ones where _computeStreak() returns 0 + streakAdjustment, so the gap between the stored value and the fresh value is most likely to straddle the currentWeek + 2 threshold.
Impact
Users who legitimately win a jackpot under the correct streak calculation are denied their winnings. The reward is replaced with "Nothing", the amount is set to zero, and nothingCounts is incremented. The report describes this as undermining the core game mechanics and as potentially causing significant economic losses for users who should have won high-value jackpot prizes, and classifies the impact as theft of unclaimed yield.
Fix
The report does not state that a fix was applied, and it does not propose a specific patch.
- Look for any function that computes a derived value into a local variable and then validates a condition against the pre-update storage field. A positive result is a branch where the local and stored values can differ by one step and the branch outcome flips.
- Check reward or eligibility gates that depend on counters incremented later in the same transaction, such as streak counters, spin counts or claim counts. A positive result is a user who meets the threshold after the increment but is rejected before it.
- Test first-time and streak-reset paths specifically, since those are the paths where the computed value jumps from zero to one. A positive result is a rejection that disappears on the user's next interaction.
- Compare the value passed into reward selection with the value used in any subsequent guard in the same function. A positive result is any guard that reads storage rather than the local variable.
This class of bug hides in state machines where a value is both derived and persisted in the same call: streak counters, daily limits, tier upgrades and loyalty multipliers are typical places. A state machine, in this context, is simply a contract whose behaviour depends on a stored status that changes over time. During review, the signal is a function that assigns a freshly computed value to a local variable and then, a few lines later, reads the same concept back from storage. Grepping for the storage field name alongside the local variable name usually surfaces it quickly.
The report establishes impact by walking a concrete two-day scenario through the exact lines involved, showing the fresh streak of two, the stored streak of one, the jackpot that determineReward() returns, and the overwrite to "Nothing". That line-by-line trace, tied to a named reward amount, is what makes the denial of a legitimate payout legible to a reviewer.
Glossary
- Smart contract: a program stored on a blockchain that runs automatically and holds its own data and tokens.
- Blockchain: a shared, append-only record of transactions that many computers keep in sync.
- Storage: the permanent data a smart contract keeps between transactions, like a notebook that is never erased.
- Local variable: a temporary value used inside one function call and discarded when the call ends.
- Transaction: a single action sent to the blockchain; all the code it runs executes in order within it.
- Function: a named block of code inside a contract that performs one job.
- Streak: a count of consecutive days on which a user has played.
- Jackpot: the top prize in the spin game, allowed only once a minimum streak is reached.
- Eligibility check: a rule that decides whether a user is allowed to receive something.
- Randomness: an unpredictable value used to choose the spin outcome.
- Reward category: the name of the prize tier, such as "Jackpot" or "Nothing".
- Reward amount: the number of tokens paid out for a prize.
- Event: a log message a contract writes so outside software can see that something happened.
- Emit: the action of writing an event to the log.
- Stale data: a value that is out of date because it has not yet been updated for the current action.
- Temporal mismatch: using two values that describe the same thing at different points in time, so they disagree.
keccak256: a hashing function that turns text into a fixed-length fingerprint, used here to compare strings.- Hash: the fixed-length fingerprint produced by a hashing function.
uint256: an unsigned whole number of up to 256 bits, the usual number type in Solidity.- Solidity: the programming language used to write smart contracts on Ethereum-style blockchains.
viewfunction: a function that only reads data and does not change the blockchain.internalfunction: a function that can only be called from within the same contract.block.timestamp: the current time according to the blockchain when the transaction runs.- PLUME: the token used for rewards in this game.
- Yield: money or tokens owed to users that the contract is meant to pay out.
- Theft of unclaimed yield: an impact category meaning value that should have reached users did not.
- State machine: a contract whose behaviour depends on a stored status that changes over time.
- Guard: a condition in code that blocks an action unless some requirement is met.
- Proof of concept (PoC): a concrete, step-by-step demonstration that a bug really happens.
- Severity: a rating of how serious a bug is, here High.
- Grepping: searching code for a text pattern, usually with the
greptool.