Closed sherlock-admin3 closed 5 months ago
1 comment(s) were left on this issue during the judging contest.
infect3d commented:
Low severity__ high decimal tokens are really rare and not used (YAMv2 is the only one on mainnet and 57k$ marketcap)
Duplicate of #137, Invalid per sherlock rules and discussions with HOJ, extremely high decimal tokens was not explicitly highlighted.
- Non-Standard tokens: Issues related to tokens with non-standard behaviors, such as weird-tokens are not considered valid by default unless these tokens are explicitly mentioned in the README.
KupiaSec
medium
The depositors of the vault with tokens with more than 18 decimals like
YAMv2
are unable to withdraw their shutdown balance due to an overflow error despite of large contribution of the vault to thePrizePool
Summary
When the
PrizePool
is shutdowned, users can withdraw their shutdown balance by calling the withdrawShutdownBalance() function. It calculates the shutdown balance of the user with contribution of the vault to thePrizePool
duringgrandPrizePeriodDraws
days, time weighted balance of the user duringgrandPrizePeriodDraws
days and remained balance ofPrizePool
. However, users who deposited tokens with more than 18 decimals likeYAMv2
into the vaults are unable to withdraw their shutdown balance due to an overflow error in theshutdownBalanceOf
function despite of large contribution of the vault to thePrizePool
.Vulnerability Detail
When the
PrizePool
is shutdown, users can withdraw their shutdown balance by calling the withdrawShutdownBalance() function. The shutdown balance of the user is calculated from the shutdownBalanceOf() function atL942
.It first calculates the shutdown portion of the user at L916 and available balance of the
PrizePool
atL929
. Then it finally calculates shutdown balance of the user atL931
The shutdown portion of the user is calculated from contribution of the vault to the
PrizePool
and the time weighted average balance of the user duringgrandPrizePeriodDraws
days which is usually 365 days.The shutdown balance of of the user is calculate from
L931
.shutdownPortion.numerator
is multiplication ofvaultContrib
and_userTwab
. So the shutdown balance becomes as following.Here, the decimal of
vaultContrib
is 18. As the variablevaultContrib
is the amount of contribution to thePrizePool
duringgrandPrizePeriodDraws
days which is usually 365 days. If the vault contributed a lot to thePrizePool
, it can be large value. Furthermore this value can be increased by calling the contributePrizeTokens() function.The variable
_userTwab
represents time weighted average balance of the user duringgrandPrizePeriodDraws
days. Its decimal is greater than 18 (24 for YAMv2).The variable
balance
is the available amount ofprizetoken
in thePrizePool
that is entitiled to be withdrawn in case of shutdown which is also large value.As a result, the multiply of three variables overflows and the shutdownBalanceOf() function is reverted.
Impact
The depositors of the vault with tokens with more than 18 decimals like
YAMv2
are unable to withdraw their shutdown balance.Tool used
Manual Review
Code Snippet
https://github.com/sherlock-audit/2024-05-pooltogether/blob/1aa1b8c028b659585e4c7a6b9b652fb075f86db3/pt-v5-prize-pool/src/PrizePool.sol#L938-L949
Recommendation
Vaults that uses tokens with more than 18 decimals should be accounted carefully.