Closed code423n4 closed 1 year ago
Picodes marked the issue as duplicate of #393
Picodes marked the issue as satisfactory
Picodes marked the issue as selected for report
Picodes marked issue #351 as primary and marked this issue as a duplicate of 351
Lines of code
https://github.com/GenerationSoftware/pt-v5-vault/blob/55dcd65de4436d50967819c2ac313c3910b6f5f3/src/Vault.sol#L480-L482 https://github.com/generationsoftware/pt-v5-twab-controller/blob/1cdf78e87a3d9127f85a3755024f143664643c5e/src/TwabController.sol#L500-L502 https://github.com/generationsoftware/pt-v5-twab-controller/blob/1cdf78e87a3d9127f85a3755024f143664643c5e/src/TwabController.sol#L656-L661 https://github.com/generationsoftware/pt-v5-twab-controller/blob/1cdf78e87a3d9127f85a3755024f143664643c5e/src/TwabController.sol#L24
Vulnerability details
Impact
TwabController.delegateBalance
is related to the probability to get the prize, andVault.sponsor
can make the others' delegateBalance to 0. A malicious user can send a small amount of assets to every depositor and be the only prize taker.Proof of Concept
Paste this test in
VaultDepositTest
below this line. https://github.com/GenerationSoftware/pt-v5-vault/blob/55dcd65de4436d50967819c2ac313c3910b6f5f3/test/unit/Vault/Deposit.t.sol#L401 I commented the purpose of the code.Then run these commands.
This changes the probability of getting the prize, because
TwabLib.AccountDetails.delegateBalance
is the actual balance recorded in theTwabLib.Account.observations
mapping. https://github.com/GenerationSoftware/pt-v5-twab-controller/blob/1cdf78e87a3d9127f85a3755024f143664643c5e/src/libraries/TwabLib.sol#L203 https://github.com/GenerationSoftware/pt-v5-twab-controller/blob/1cdf78e87a3d9127f85a3755024f143664643c5e/src/libraries/TwabLib.sol#L119The observations mapping is used in
PrizePool._isWinner
to calculate the winning zone based on_userTwab
. https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/PrizePool.sol#L864 https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/PrizePool.sol#L928 https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/TierCalculationLib.sol#L93Tools Used
Manual review
Recommended Mitigation Steps
TwabController.sponsor
had better take an additional input argumentuint256 amount
to indicate the amount to sponsor.Assessed type
Other