code-423n4 / 2023-07-pooltogether-findings

12 stars 7 forks source link

precision loss due to division before multiplication #434

Closed code423n4 closed 11 months ago

code423n4 commented 12 months ago

Lines of code

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/PrizePool.sol#L766-L773

Vulnerability details

Impact

The result will be wrong due to division before multiplication precision issues.

Proof of Concept

This issue is similar to https://github.com/code-423n4/2023-05-ajna-findings/issues/367 Ajna Contest. A good example of this Vulnerability is in the Detector Documentation https://github.com/crytic/slither/wiki/Detector-Documentation#divide-before-multiply

Recommended Mitigation Steps

All the multiplication should be performed in step 1 and then division at the end.

Assessed type

Math

c4-judge commented 11 months ago

Picodes marked the issue as unsatisfactory: Invalid