Closed code423n4 closed 3 years ago
ye0lde
Gas savings and code clarity
PrizeDistributor.sol: Both an "if" statement and a "require" are used to protect against "payout <= oldPayout". Only a "require" is needed. https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributor.sol#L72-L80
Visual Studio Code, Remix
Replace this https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributor.sol#L72-L80 with this uint256 payoutDiff;
uint256 payoutDiff;
// helpfully short-circuit, in case the user screwed something up. require(payout > oldPayout, "PrizeDistributor/zero-payout"); payoutDiff = payout - oldPayout; _setDrawPayoutBalanceOf(_user, drawId, payout);
Note also that explicitly initializing "payoutDiff" to 0 isn't necessary although it might be standard practice on your project.
https://github.com/code-423n4/2021-10-pooltogether-findings/issues/41
Duplicate of #41
Handle
ye0lde
Vulnerability details
Impact
Gas savings and code clarity
Proof of Concept
PrizeDistributor.sol: Both an "if" statement and a "require" are used to protect against "payout <= oldPayout". Only a "require" is needed. https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributor.sol#L72-L80
Tools Used
Visual Studio Code, Remix
Recommended Mitigation Steps
Replace this https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributor.sol#L72-L80 with this
uint256 payoutDiff;
Note also that explicitly initializing "payoutDiff" to 0 isn't necessary although it might be standard practice on your project.