Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prb-math library is not audited and needs to be carefully trusted #246

Closed
code423n4 opened this issue Jul 14, 2023 · 11 comments
Closed

prb-math library is not audited and needs to be carefully trusted #246

code423n4 opened this issue Jul 14, 2023 · 11 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/PrizePool.sol#L8-L11
https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/UD34x4.sol#L5
https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/TierCalculationLib.sol#L5-L6
https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/DrawAccumulatorLib.sol#L6
https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/abstract/TieredLiquidityDistributor.sol#L5-L8
https://github.com/GenerationSoftware/pt-v5-claimer/blob/57a381aef690a27c9198f4340747155a71cae753/src/Claimer.sol#L4-L6

Vulnerability details

Impact

In most of the PoolTogether contracts prb-math library is heavily used but the library prb-math documents that it is not audited by a security researcher. This means its more risky to rely on this library.

The prb-math library mentions,
Security
While I set a high bar for code quality and test coverage, you should not assume that this project is completely safe to use. PRBMath has not yet been audited by a third-party security researcher.

Reference link- https://github.com/PaulRBerg/prb-math#security

Therefore, the prb-math library should be audited before its heavy usage in PoolTogether contracts.

Proof of Concept

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

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/UD34x4.sol#L5

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/TierCalculationLib.sol#L5-L6

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/libraries/DrawAccumulatorLib.sol#L6

https://github.com/GenerationSoftware/pt-v5-prize-pool/blob/4bc8a12b857856828c018510b5500d722b79ca3a/src/abstract/TieredLiquidityDistributor.sol#L5-L8

https://github.com/GenerationSoftware/pt-v5-claimer/blob/57a381aef690a27c9198f4340747155a71cae753/src/Claimer.sol#L4-L6

Tools Used

Manual review

Recommended Mitigation Steps

Consider (crowdsourcing) an audit for prb-math library.

Assessed type

Other

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jul 14, 2023
code423n4 added a commit that referenced this issue Jul 14, 2023
@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #423

@c4-judge
Copy link
Contributor

Picodes marked the issue as partial-50

@c4-judge c4-judge added the partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) label Jul 16, 2023
@c4-judge
Copy link
Contributor

Picodes marked the issue as unsatisfactory:
Overinflated severity

@c4-judge c4-judge added unsatisfactory does not satisfy C4 submission criteria; not eligible for awards and removed partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) labels Jul 16, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Aug 5, 2023

Picodes marked the issue as not a duplicate

@c4-judge
Copy link
Contributor

c4-judge commented Aug 5, 2023

Picodes changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 5, 2023
@Picodes
Copy link

Picodes commented Aug 5, 2023

Downgrading to QA as this report doesn't showcase any bug

@0xRizwan
Copy link

0xRizwan commented Aug 9, 2023

@Picodes

With due respect to judge decision, I would like to add additional context as below,

This is valid issue and as confirmed in #423 the root cause of the issue is the prb-math library which is not audited. Usually, external libraries which are used in contracts are audited or libraries which are used at project risk should already informed in known issue, however this is not the case here.

Further after digging in prb-math library, i found below issues which are fixed in latest version.

prb-math library library author bug acceptance:
sablier-labs/v2-core#432
PaulRBerg/prb-math#181
PaulRBerg/prb-math#179

It is good to know that, prb-math will add a new directory "audits" performed by Cantina(a marketplace by spearbit).

It is further recommended to update the prb-math library to latest version v4.0.1

I think the issue deserves to be particially satisfactory to Medium.

Thank you!

@Picodes
Copy link

Picodes commented Aug 12, 2023

@mohammedrizwann123 this specific report is not of Medium severity. It only highlights that one of the project's dependencies is not audited. It is good to be aware of and certainly valuable for users but I don't see how it could fulfill code4rena's definition of a Med severity finding: "Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements."

@0xRizwan
Copy link

0xRizwan commented Aug 12, 2023

Hi @Picodes

Thanks for the comment.

Please note this issue has been judged as Medium severity in Tracer audit at code4rena.

Reference: code-423n4/2021-06-tracer-findings#11

While drafting the report, I had referenced it and yes it is very much fulfill Medium severity defination as It is a confirmed finding judged by Code4rena.

I agree some reference is missing in original report but it is highlighted in above response and here and i believe the issue deserves to be particially satisfactory to Medium and made as already duplicate of #423.

Thank you!

@Picodes
Copy link

Picodes commented Aug 12, 2023

@mohammedrizwann123 the issue you are referring to dates from more than 2 years ago. Please note that referring to another contest is not a valid point and it happens quite frequently that we disagree between judges.

Side note: please recall that the rules are the following: "At the point that a judge provides a response, the conversation is over, unless you wish to provide additional facts which demonstrate inaccurate assumptions in the judge's response. "

@0xRizwan
Copy link

@Picodes

No issues, I respect your judging decision.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants