Changing Payout Calculator During Active Drawing Causes Loss of Unclaimed Winnings
The jackpot contract reads mutable configuration values such as the payout calculator, entropy provider, protocol fee and referral fee at settlement time rather than snapshotting them when a drawing starts. An admin (or a compromised admin key) could change these mid-drawing so that winnings, fees or refunds are calculated differently from what players expected.
Alex_Cipher Follow with 0xMilenov, AnantaDeva and 21 others
Originally disclosed on Code4rena
Submitted by Alex_Cipher, also found by 0xMilenov, AnantaDeva, BengalCatBalu, dan__vinci, edoscoba, ht111111, InvarianteX, IzuMan, l3gb, mightyraj2605, overseer, pepoc, PureVessel, rfa, rokinot, saraswati, SavantChat, stakog, TOSHI, touristS, valarislife, zcai, and Ziusz
This submission is a duplicate of S-365 created at the judge’s request in order to appropriately allocate credit to wardens who reported partially similar issues.
Expand for detailed Proof of Concept
Proof of Concept
TESTS
🧪 PoC 1 — Setting LPManager Affects Settlement (JackpotLPManager)
import { expect } from "chai";
import { ethers } from "hardhat";
import { time, takeSnapshot } from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { deployJackpotSystem } from "@utils/test/jackpotFixture";
import { usdc, ether } from "@utils/common";
import { ZERO_BYTES32 } from "@utils/constants";
describe("PoC: admin/malicious LPManager affects settlement (JackpotLPManager)", function () {
it("Case A: normal LP manager succeeds; Case B: malicious LP manager causes revert on settlement", async function () {
const jackpotSystem = await deployJackpotSystem();
const {
owner,
buyerOne,
lpOne,
jackpot,
jackpotLPManager,
jackpotNFT,
payoutCalculator,
usdcMock,
entropyProvider,
deploymentParams,
deployer,
} = jackpotSystem as any;
// Initialize contracts (original system)
await jackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await jackpotLPManager.getAddress(),
await jackpotNFT.getAddress(),
await entropyProvider.getAddress(),
await payoutCalculator.getAddress()
);
// Prepare LP deposit so prize pool can be initialized
await jackpot.connect(owner.wallet).initializeLPDeposits(usdc(100000));
await usdcMock.connect(lpOne.wallet).approve(await jackpot.getAddress(), usdc(100000));
await jackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
// Initialize jackpot
const latestBlock = await ethers.provider.getBlock("latest");
const now = latestBlock!.timestamp;
await jackpot.connect(owner.wallet).initializeJackpot(now + 1);
await time.increase(3);
// Buyer purchases tickets
const tickets = [] as any[];
for (let i = 0; i < 3; i++) tickets.push({ normals: [1n,2n,3n,4n,5n], bonusball: 1n });
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(1000));
await jackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, [], [], ZERO_BYTES32);
// Request randomness (runJackpot)
const fee = await jackpot.getEntropyCallbackFee();
await jackpot.connect(buyerOne.wallet).runJackpot({ value: fee });
const randomNumbers = [ [10,11,12,13,14], [6] ];
// Snapshot right before callback
const snapshot = await takeSnapshot();
const beforeId = Number((await jackpot.currentDrawingId()).toString());
// Case A: Normal LP manager runs callback successfully
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterIdA = Number((await jackpot.currentDrawingId()).toString());
expect(afterIdA).to.equal(beforeId + 1);
// Revert to snapshot
await snapshot.restore();
// Case B: Deploy malicious LP manager and create a fresh jackpot that uses it
const MaliciousLP = await ethers.getContractFactory("MaliciousLPManagerMock");
const maliciousLP = await MaliciousLP.connect(owner.wallet).deploy();
// Deploy a new Jackpot with the same params but using the malicious LP manager
const newJackpot = await deployer.deployJackpot(
deploymentParams.drawingDurationInSeconds,
deploymentParams.normalBallMax,
deploymentParams.bonusballMin,
deploymentParams.lpEdgeTarget,
deploymentParams.reserveRatio,
deploymentParams.referralFee,
deploymentParams.referralWinShare,
deploymentParams.protocolFee,
deploymentParams.protocolFeeThreshold,
deploymentParams.ticketPrice,
deploymentParams.maxReferrers,
deploymentParams.entropyBaseGasLimit
);
const newJackpotNFT = await deployer.deployJackpotTicketNFT(await newJackpot.getAddress());
const newPayoutCalculator = await deployer.deployGuaranteedMinimumPayoutCalculator(
await newJackpot.getAddress(),
deploymentParams.minimumPayout,
deploymentParams.premiumTierMinAllocation,
deploymentParams.minPayoutTiers,
deploymentParams.premiumTierWeights
);
const newEntropyProvider = await deployer.deployScaledEntropyProviderMock(
deploymentParams.entropyFee,
await newJackpot.getAddress(),
newJackpot.interface.getFunction("scaledEntropyCallback").selector
);
// Initialize the new jackpot with malicious LP manager
await newJackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await maliciousLP.getAddress(),
await newJackpotNFT.getAddress(),
await newEntropyProvider.getAddress(),
await newPayoutCalculator.getAddress()
);
// Prepare LP deposit for new jackpot
await newJackpot.connect(owner.wallet).initializeLPDeposits(usdc(100000));
await usdcMock.connect(lpOne.wallet).approve(await newJackpot.getAddress(), usdc(100000));
await newJackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
// Initialize new jackpot
const now2 = (await ethers.provider.getBlock("latest"))!.timestamp;
await newJackpot.connect(owner.wallet).initializeJackpot(now2 + 1);
await time.increase(3);
// Buyer purchases tickets on the new jackpot
await usdcMock.connect(buyerOne.wallet).approve(await newJackpot.getAddress(), usdc(1000));
await newJackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, [], [], ZERO_BYTES32);
// Request randomness for new jackpot
const fee2 = await newJackpot.getEntropyCallbackFee();
await newJackpot.connect(buyerOne.wallet).runJackpot({ value: fee2 });
// Attempt to callback via the new entropy provider which should trigger the malicious LP manager revert
await expect(newEntropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers)).to.be.revertedWith(
"Malicious LP Manager"
);
// Confirm new jackpot did not progress
const afterIdB = Number((await newJackpot.currentDrawingId()).toString());
expect(afterIdB).to.equal(beforeId);
});
});
🧪 PoC 2 — Admin Alters Entropy Provider Mid-Draw (EntropyProvider Manipulation)
import { expect } from "chai";
import { ethers } from "hardhat";
import { time, takeSnapshot } from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { deployJackpotSystem } from "@utils/test/jackpotFixture";
import { usdc, ether } from "@utils/common";
import { ZERO_BYTES32 } from "@utils/constants";
describe("PoC: admin changes mid-drawing affect settlement (entropy provider)", function () {
it("Case A: normal provider works; Case B: malicious provider causes DOS / revert", async function () {
const jackpotSystem = await deployJackpotSystem();
const {
owner,
buyerOne,
lpOne,
jackpot,
jackpotLPManager,
jackpotNFT,
payoutCalculator,
usdcMock,
entropyProvider,
} = jackpotSystem as any;
// Initialize contracts
await jackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await jackpotLPManager.getAddress(),
await jackpotNFT.getAddress(),
await entropyProvider.getAddress(),
await payoutCalculator.getAddress()
);
// Prepare LP deposit so prize pool can be initialized
await jackpot.connect(owner.wallet).initializeLPDeposits(usdc(100000));
await usdcMock.connect(lpOne.wallet).approve(await jackpot.getAddress(), usdc(100000));
await jackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
// Initialize jackpot
const latestBlock = await ethers.provider.getBlock("latest");
const now = latestBlock!.timestamp;
await jackpot.connect(owner.wallet).initializeJackpot(now + 1);
await time.increase(3);
// Buyer purchases tickets
const tickets = [] as any[];
for (let i = 0; i < 3; i++) tickets.push({ normals: [1n,2n,3n,4n,5n], bonusball: 1n });
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(1000));
await jackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, [], [], ZERO_BYTES32);
// Request randomness (runJackpot)
const fee = await jackpot.getEntropyCallbackFee();
await jackpot.connect(buyerOne.wallet).runJackpot({ value: fee });
const randomNumbers = [ [10,11,12,13,14], [6] ];
// Snapshot right before callback
const snapshot = await takeSnapshot();
const beforeId = Number((await jackpot.currentDrawingId()).toString());
// Case A: Normal provider runs callback successfully
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterIdA = Number((await jackpot.currentDrawingId()).toString());
expect(afterIdA).to.equal(beforeId + 1);
// Revert to snapshot
await snapshot.restore();
// Case B: deploy malicious provider and set it as the entropy provider
const Malicious = await ethers.getContractFactory("MaliciousEntropyProviderMock");
const malicious = await Malicious.connect(owner.wallet).deploy(ether(0.00001));
const maliciousAddr = await malicious.getAddress();
await jackpot.connect(owner.wallet).setEntropy(maliciousAddr);
// Attempt to invoke callback via malicious provider - expect revert (DOS)
await expect(malicious.connect(owner.wallet).randomnessCallback(randomNumbers)).to.be.revertedWith(
"Malicious provider: refusing to callback"
);
// Confirm drawing did not progress
const afterIdB = Number((await jackpot.currentDrawingId()).toString());
expect(afterIdB).to.equal(beforeId);
});
});
🧪 PoC 3 — Admin Modifies Protocol Fee During Active Draw (Protocol Fee Exploit)
import { expect } from "chai";
import { ethers } from "hardhat";
import { time, takeSnapshot } from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { deployJackpotSystem } from "@utils/test/jackpotFixture";
import { usdc, ether } from "@utils/common";
import { ZERO_BYTES32 } from "@utils/constants";
describe("PoC: admin changes mid-drawing affect settlement (protocolFee)", function () {
it("changing protocolFee before callback changes protocol fee extracted at settlement", async function () {
// Deploy full fixture
const jackpotSystem = await deployJackpotSystem();
const {
owner,
buyerOne,
lpOne,
jackpot,
jackpotLPManager,
jackpotNFT,
payoutCalculator,
usdcMock,
entropyProvider,
deploymentParams,
deployer,
} = jackpotSystem as any;
// Initialize contracts
await jackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await jackpotLPManager.getAddress(),
await jackpotNFT.getAddress(),
await entropyProvider.getAddress(),
await payoutCalculator.getAddress()
);
// Initialize LP deposits (set a large cap)
await jackpot.connect(owner.wallet).initializeLPDeposits(usdc(1000000));
// LP deposit so that LP accounting is non-zero
await usdcMock.connect(lpOne.wallet).approve(await jackpot.getAddress(), usdc(100000));
await jackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
// Initialize jackpot (set initial drawing time to now)
const latestBlock = await ethers.provider.getBlock("latest");
const now = latestBlock!.timestamp;
await jackpot.connect(owner.wallet).initializeJackpot(now + 1);
// Move time forward so drawing is due
await time.increase(3);
// Buyer purchases multiple tickets to create sufficient lpEarnings > protocolFeeThreshold
const tickets = [] as any[];
for (let i = 0; i < 10; i++) {
tickets.push({ normals: [1n, 2n, 3n, 4n, 5n], bonusball: 1n });
}
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(1000));
await jackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, [], [], ZERO_BYTES32);
// Request randomness (runJackpot) and fund with provider fee
const fee = await jackpot.getEntropyCallbackFee();
await jackpot.connect(buyerOne.wallet).runJackpot({ value: fee });
// Prepare deterministic randomness: two arrays (5 normals, 1 bonusball) that don't match purchased tickets
const randomNumbers = [
[10, 11, 12, 13, 14],
[6]
];
const protocolFeeAddress = await jackpot.protocolFeeAddress();
// Ensure Case A uses a protocolFee of 0.01 (explicit) then snapshot the chain state right before callback
const originalFee = ether(0.01);
await jackpot.connect(owner.wallet).setProtocolFee(originalFee);
const snapshot = await takeSnapshot();
// Case A: use the current protocolFee (as deployed)
const beforeA = await usdcMock.balanceOf(protocolFeeAddress);
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterA = await usdcMock.balanceOf(protocolFeeAddress);
const collectedA = afterA - beforeA;
// Revert to snapshot (before callback)
await snapshot.restore();
// Case B: change protocolFee to a different value mid-drawing, then callback
const higherFee = ether(0.02); // 2%
await jackpot.connect(owner.wallet).setProtocolFee(higherFee);
const beforeB = await usdcMock.balanceOf(protocolFeeAddress);
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterB = await usdcMock.balanceOf(protocolFeeAddress);
const collectedB = afterB - beforeB;
// Assert that collected protocol fees differ when protocolFee changed mid-drawing
expect(collectedA).to.not.equal(collectedB);
// If higherFee > original, the later collected amount should be >= earlier (sanity)
expect(collectedB >= collectedA).to.be.true;
});
});
🧪 PoC 4 — Admin Changes Payout Calculator (Winnings Distortion)
import { expect } from "chai";
import { ethers } from "hardhat";
import { time, takeSnapshot } from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { deployJackpotSystem } from "@utils/test/jackpotFixture";
import { usdc, ether } from "@utils/common";
describe("PoC: admin changes mid-drawing affect settlement (payoutCalculator)", function () {
it("swapping payoutCalculator before callback changes drawing user winnings and protocol fee", async function () {
const jackpotSystem = await deployJackpotSystem();
const {
owner,
buyerOne,
lpOne,
jackpot,
jackpotLPManager,
jackpotNFT,
payoutCalculator,
usdcMock,
entropyProvider,
} = jackpotSystem as any;
// Initialize contracts
await jackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await jackpotLPManager.getAddress(),
await jackpotNFT.getAddress(),
await entropyProvider.getAddress(),
await payoutCalculator.getAddress()
);
// Prepare LP deposit so prize pool can be initialized
await jackpot.connect(owner.wallet).initializeLPDeposits(usdc(100000));
await usdcMock.connect(lpOne.wallet).approve(await jackpot.getAddress(), usdc(100000));
await jackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
// Initialize jackpot
const latestBlock = await ethers.provider.getBlock("latest");
const now = latestBlock!.timestamp;
await jackpot.connect(owner.wallet).initializeJackpot(now + 1);
await time.increase(3);
// Buyer purchases tickets
const tickets = [] as any[];
for (let i = 0; i < 5; i++) tickets.push({ normals: [1n,2n,3n,4n,5n], bonusball: 1n });
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(1000));
await jackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, [], [], "0x0000000000000000000000000000000000000000000000000000000000000000");
// Request randomness (runJackpot)
const fee = await jackpot.getEntropyCallbackFee();
await jackpot.connect(buyerOne.wallet).runJackpot({ value: fee });
const randomNumbers = [ [10,11,12,13,14], [6] ];
const protocolFeeAddress = await jackpot.protocolFeeAddress();
// Snapshot right before callback
const snapshot = await takeSnapshot();
// Case A: use original payoutCalculator
const beforeA = await usdcMock.balanceOf(protocolFeeAddress);
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterA = await usdcMock.balanceOf(protocolFeeAddress);
const collectedA = afterA - beforeA;
// Revert to snapshot
await snapshot.restore();
// Case B
// Deploy a mock payout calculator that returns slightly larger user winnings (multiplier > 1e18 but modest)
const Mock = await ethers.getContractFactory("MockPayoutCalculator");
// multiplier 1.1x = 1.1e18 (use integer math)
const mult = (ether(1) * 11n) / 10n;
const mock = await Mock.connect(owner.wallet).deploy(mult);
const mockAddr = await mock.getAddress();
// Swap payout calculator (admin action) before callback
await jackpot.connect(owner.wallet).setPayoutCalculator(mockAddr);
const beforeB = await usdcMock.balanceOf(protocolFeeAddress);
await entropyProvider.connect(owner.wallet).randomnessCallback(randomNumbers);
const afterB = await usdcMock.balanceOf(protocolFeeAddress);
const collectedB = afterB - beforeB;
// Swapping to a different payout calculator should change the protocol fee collected at settlement
expect(collectedA).to.not.equal(collectedB);
});
});
🧪 PoC 5 — Admin Modifies Referral Fee (Refund Manipulation)
import { expect } from "chai";
import { ethers } from "hardhat";
import { time, takeSnapshot } from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { deployJackpotSystem } from "@utils/test/jackpotFixture";
import { usdc, ether } from "@utils/common";
import { ZERO_BYTES32 } from "@utils/constants";
describe("PoC: admin changes mid-drawing affect refunds (referralFee)", function () {
it("changing referralFee before emergency refund changes refund amount", async function () {
const jackpotSystem = await deployJackpotSystem();
const {
owner,
lpOne,
buyerOne,
referrerOne,
jackpot,
jackpotLPManager,
jackpotNFT,
payoutCalculator,
usdcMock,
entropyProvider,
} = jackpotSystem as any;
// Initialize contracts (use addresses from the fixture)
await jackpot.connect(owner.wallet).initialize(
await usdcMock.getAddress(),
await jackpotLPManager.getAddress(),
await jackpotNFT.getAddress(),
await entropyProvider.getAddress(),
await payoutCalculator.getAddress()
);
// Ensure LP deposits and first drawing are set up (reuse the same sequence as other PoCs)
await jackpot.connect(owner.wallet).initializeLPDeposits(usdc(100000));
// LP deposit so that LP accounting is non-zero
await usdcMock.connect(lpOne.wallet).approve(await jackpot.getAddress(), usdc(100000));
await jackpot.connect(lpOne.wallet).lpDeposit(usdc(10000));
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(1000));
// Give buyerOne a small amount and initialize the jackpot
const latestBlock = await ethers.provider.getBlock("latest");
const now = latestBlock!.timestamp;
await jackpot.connect(owner.wallet).initializeJackpot(now + 1);
// Move time forward so drawing is due
await time.increase(3);
// Buy a single ticket with a referral scheme (referrerOne gets 100%)
const tickets = [{ normals: [1n,2n,3n,4n,5n], bonusball: 1n }];
const referrers = [referrerOne.address];
const referralSplit = [ether(1)]; // 100% to single referrer
// Approve and buy
await usdcMock.connect(buyerOne.wallet).approve(await jackpot.getAddress(), usdc(10));
await jackpot.connect(buyerOne.wallet).buyTickets(tickets, buyerOne.address, referrers, referralSplit, ZERO_BYTES32);
// Identify the minted ticket id via the NFT helper
const drawingId = Number((await jackpot.currentDrawingId()).toString());
const userTickets = await jackpotNFT.getUserTickets(buyerOne.address, drawingId);
expect(userTickets.length).to.be.greaterThan(0);
const ticketId = userTickets[0].ticketId;
// Snapshot the chain right before emergency/refund
const snapshot = await takeSnapshot();
// Case A: set referralFee to original (e.g., 6.5%) then enable emergency and refund
const originalReferralFee = ether(0.065);
await jackpot.connect(owner.wallet).setReferralFee(originalReferralFee);
// Enable emergency mode and perform refund
await jackpot.connect(owner.wallet).enableEmergencyMode();
const beforeA = await usdcMock.balanceOf(buyerOne.address);
await jackpot.connect(buyerOne.wallet).emergencyRefundTickets([ticketId]);
const afterA = await usdcMock.balanceOf(buyerOne.address);
const refundedA = afterA - beforeA;
// Revert to snapshot (ticket and balances restored)
await snapshot.restore();
// Case B: increase referralFee (10%) before refund, then enable emergency and refund
const higherReferralFee = ether(0.1);
await jackpot.connect(owner.wallet).setReferralFee(higherReferralFee);
await jackpot.connect(owner.wallet).enableEmergencyMode();
const userTicketsB = await jackpotNFT.getUserTickets(buyerOne.address, drawingId);
const ticketIdB = userTicketsB[0].ticketId;
const beforeB = await usdcMock.balanceOf(buyerOne.address);
await jackpot.connect(buyerOne.wallet).emergencyRefundTickets([ticketIdB]);
const afterB = await usdcMock.balanceOf(buyerOne.address);
const refundedB = afterB - beforeB;
// The refund uses `ticketPrice * (1 - referralFee)` when a referral scheme exists.
// Therefore increasing referralFee should *decrease* the refund amount.
expect(refundedA).to.not.equal(refundedB);
expect(refundedA > refundedB).to.be.true;
});
});
Mocks
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import { IScaledEntropyProvider } from "../interfaces/IScaledEntropyProvider.sol";
/**
* @notice Malicious entropy provider used for PoC testing.
* Its `randomnessCallback` intentionally reverts to simulate a DOS or faulty provider.
*/
contract MaliciousEntropyProviderMock is IScaledEntropyProvider {
uint256 public fee;
constructor(uint256 _fee) {
fee = _fee;
}
function requestAndCallbackScaledRandomness(
uint32,
IScaledEntropyProvider.SetRequest[] memory,
bytes4,
bytes memory
) external payable returns (uint64 requestId) {
// Record request but do nothing special; return id
requestId = uint64(1);
}
function randomnessCallback(uint256[][] memory) external {
revert("Malicious provider: refusing to callback");
}
function getFee(uint32) external view returns (uint256) {
return fee;
}
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import { IJackpotLPManager } from "../interfaces/IJackpotLPManager.sol";
contract MaliciousLPManagerMock is IJackpotLPManager {
// Use an internal struct name to avoid conflicting with the interface's LPDrawingState
struct InternalLPState {
uint256 lpPoolTotal;
uint256 pendingDeposits;
uint256 pendingWithdrawals;
}
mapping(uint256 => InternalLPState) internal states;
function processDeposit(uint256 _drawingId, address /* _lpAddress */, uint256 _amount) external override {
// Track pending deposits so Jackpot.initializeJackpot can proceed
states[_drawingId].pendingDeposits += _amount;
states[_drawingId].lpPoolTotal += _amount;
}
function processInitiateWithdraw(uint256, address, uint256) external override {
// no-op
}
function processFinalizeWithdraw(uint256, address) external pure override returns (uint256 withdrawableAmount) {
return 0;
}
function processDrawingSettlement(
uint256 _drawingId,
uint256 /* _lpEarnings */,
uint256 /* _userWinnings */,
uint256 /* _protocolFeeAmount */
) external override returns (uint256, uint256) {
// Allow the initial settlement called during initializeJackpot (drawing 0) to succeed
// but become malicious for real drawings (drawingId > 0)
if (_drawingId == 0) {
uint256 newLPValue = states[_drawingId].lpPoolTotal;
return (newLPValue, 1e18);
}
revert("Malicious LP Manager");
}
function emergencyWithdrawLP(uint256, address) external pure override returns (uint256 withdrawableAmount) {
return 0;
}
function initializeDrawingLP(uint256 _drawingId, uint256 _initialLPValue) external override {
states[_drawingId].lpPoolTotal = _initialLPValue;
}
function setLPPoolCap(uint256, uint256) external override {
// no-op
}
function initializeLP() external override {
// no-op
}
function getDrawingAccumulator(uint256 _drawingId) external view override returns (uint256) {
return states[_drawingId].lpPoolTotal == 0 ? 0 : 1e18;
}
function getLPDrawingState(uint256 _drawingId) external view override returns (LPDrawingState memory) {
InternalLPState memory s = states[_drawingId];
return LPDrawingState({ lpPoolTotal: s.lpPoolTotal, pendingDeposits: s.pendingDeposits, pendingWithdrawals: s.pendingWithdrawals });
}
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import "../interfaces/IPayoutCalculator.sol";
/**
* @notice Simple mock payout calculator used for PoC testing.
* It returns drawing winnings equal to prizePool * multiplier (PRECISE_UNIT scale).
*/
contract MockPayoutCalculator is IPayoutCalculator {
uint256 public multiplier; // PRECISE_UNIT scale
mapping(uint256 => uint256) public drawingWinnings;
constructor(uint256 _multiplier) {
multiplier = _multiplier;
}
function setMultiplier(uint256 _multiplier) external {
multiplier = _multiplier;
}
function setDrawingTierInfo(uint256 /* _drawingId */) external pure override {
// No-op for mock
}
function calculateAndStoreDrawingUserWinnings(
uint256 _drawingId,
uint256 _prizePool,
uint8 /* _ballMax */,
uint8 /* _bonusballMax */,
uint256[] memory /* _result */,
uint256[] memory /* _dupResult */
) external override returns (uint256) {
// Multiply prizePool by multiplier (1e18 scale)
uint256 w = (_prizePool * multiplier) / 1e18;
drawingWinnings[_drawingId] = w;
return w;
}
function getTierPayout(uint256 _drawingId, uint256 /* _tierId */) external view override returns (uint256) {
// For simplicity, split total evenly across 12 tiers
uint256 total = drawingWinnings[_drawingId];
return total / 12;
}
}
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 contract reads settlement parameters (payout calculator, entropy provider, protocol fee, referral fee) from storage at callback time instead of capturing them when the drawing begins.
Impact
An admin could alter winnings, protocol fees or refunds after tickets are sold, potentially causing loss of unclaimed winnings or unfair payouts; the text frames this as an admin-trust issue rather than an unprivileged attack.
What the attacker needed
Admin or compromised admin key; an active drawing in progress
How it was found
- Deploy and initialise the jackpot with LP deposits and a starting drawing
- Buy tickets and request randomness via runJackpot
- Before the randomness callback, change a settlement parameter such as the payout calculator or protocol fee
- Trigger the randomness callback and observe that the payout or fee differs from the original configuration
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 lottery-style contract lets players buy tickets, then later picks winners and pays out. The settings that decide how much each winner gets are read at the moment of payout, not when tickets were sold. If someone with admin rights changes those settings in between, the payout can differ from what players signed up for.
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.