Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

BTK - pow() function returns inconsistent values #31

Closed
sherlock-admin2 opened this issue Aug 29, 2023 · 1 comment
Closed

BTK - pow() function returns inconsistent values #31

sherlock-admin2 opened this issue Aug 29, 2023 · 1 comment
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Aug 29, 2023

BTK

medium

pow() function returns inconsistent values

Summary

The GPToke.previewPoints function calculates the points a user will earn by staking a specified amount for a given duration. It ensures the duration is within valid limits, then calculates points using a formula involving the staking duration and a multiplier. The function returns the earned points and the staking end time.

The multiplier is calculated using pow() as follow:

        uint256 multiplier = PRBMathUD60x18.pow(YEAR_BASE_BOOST, endYearpoc);

Vulnerability Detail

The issue is that PRBMath contains a critical vulnerability in the pow() function, which can return inconsistent values. This vulnerability is of great importance to the Tokemak protocol, as the function is used in the computation of how many points a user should get.

GPToke.previewPoints function is called in both:

Recently, another protocol has also experienced the same bug, and the creators of the PRBMath have acknowledged this situation:

sablier-labs/v2-core#432

Impact

PRBMath pow() function can return inconsistent values.

Code Snippet

Tool used

Manual Review

Recommendation

To mitigate this issue, please update the contracts to 0.8.19 and upgrade the PRBMath to version V4 because these errors have been corrected(Link).

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Sep 11, 2023
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

Trumpero commented:

according PaulRBerg/prb-math#181, the issue happens when calculating x^y and x < 1e18. But in the current implementation, x = YEAR_BASE_BOOST = 18e17 > 1e18

@sherlock-admin sherlock-admin changed the title Lively Coal Pike - pow() function returns inconsistent values BTK - pow() function returns inconsistent values Oct 3, 2023
@sherlock-admin sherlock-admin added the Non-Reward This issue will not receive a payout label Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

2 participants