Closed code423n4 closed 1 year ago
Picodes marked the issue as duplicate of #423
Downgrading to Med as this report doesn't show how it could qualify for High severity
Picodes changed the severity to 2 (Med Risk)
Picodes marked the issue as selected for report
Picodes marked the issue as satisfactory
Hello, Picodes! While the issue with that function is real, I believe the appropriate mitigation was proposed by Obront you can see more about this in this post , as the co-founder of the project being audited is also the creator of PRBMath. Therefore, it seems out of reach for the PT team to fix the function directly, and instead, the suitable mitigation would be the one proposed by the PRBMath team after they resolved the problem with exp2(). I discussed this further in my report.
Additionally, I think this issue should be considered of high severity because even though the problem was with exp2(), there were some inconsistencies in functions like div and mul, which are heavily used in important calculations within PT. The PRBMath team has already resolved these inconsistencies in version 4.
Picodes marked issue #423 as primary and marked this issue as a duplicate of 423
@catellaTech thank you for your comment. You are correct about the mitigation. Regarding the severity, I downgraded these issues to Med because in my opinion none of these reports properly demonstrates that this could lead to a credible loss of funds scenario. From my understanding, the issue on pow
occurs only in a specific range (it is related to a bitmask error and required 50000 fuzz tests to be uncovered), so there is a significant probability that the affected zone cannot be touched by DrawAccumulatorLib.sol
TierCalculationLib.sol
, or that the resulting inconsistencies aren't large enough to lead to a loss of funds. Overall I think Medium severity is more appropriate here - although if we dig into it the issue might be High.
Thanks so much for the answer! 😊👍
Lines of code
https://github.com/PaulRBerg/prb-math/blob/df27d3d12ce12153fb166e1e310c8351210dc7ba/src/sd59x18/Math.sol#L596-L609 https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/DrawAccumulatorLib.sol#L390-L399
Vulnerability details
Impact
Protocol is highly dependent on the computation of area under the curve
c(d) = −t ∗ ln(α)∗α ^ d
which uses PRB-Math's Pow() function to calculate . Recently It has been found thispow()
function can give inconsistent values and break the computation.PRBMath's
pow()
function takes two signed integer (say a and b) and returns ab A proper implementation of power function states that : for any a >= b and x >= 0 , a x >= b ** xSimplifying this further as (a>=b)= ((a/b)>=1) and so (a/b)**x >=1 [x>=0] this
pow()
function doesn't follow this and gives inconsistent values.This Mainly affects
integrate
function ofDrawAccumulatorLib.sol
which integrate from a lower value higher value for the exponential weighted averageProof of Concept
Test Function
Root cause described by a senior watson - "in the exp2() function, bit masks are applied to multiply the result by root(2,2^-i) for each position i with a value of 1. However at Common.sol#L170, the value is incorrectly included as 0xFF00000000 instead of 0xFF000000 "
Tools Used
Manual , Foundry Testing
Recommended Mitigation Steps
Ensure that calculation is accurate by adjusting the comparison value in
exp2()
functionAssessed type
Math