51596 sc low unsafe uint256 to uint8 downcast causes integer overflow leading to unauthorized jackpot payouts after week 255
Description
Brief/Intro
Vulnerability Details
function determineReward(
uint256 randomness,
uint256 streakForReward
) internal view returns (string memory, uint256) {
uint256 probability = randomness % 1_000_000;
// Calculate current week
uint256 daysSinceStart = (block.timestamp - campaignStartDate) / 1 days;
uint8 weekNumber = uint8(getCurrentWeek()); // UNSAFE DOWNCAST
// ... jackpot logic uses weekNumber
if (probability < jackpotThreshold) {
return ("Jackpot", jackpotPrizes[weekNumber]); // Uses overflowed value!
}
}Impact Details
References
Proof of Concept
Previous52248 sc insight lack of initialization check in staking allows users to stake without reward token configured causing permanent loss of yieldNext52845 sc high distributeyieldwithlimit lacks snapshot between batches allowing state changes to break distribution and lock yield
Was this helpful?