-
Notifications
You must be signed in to change notification settings - Fork 0
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
Unbounded loop in RewardsPool#getInflationAmt #139
Comments
Primary because longer description, but only marginally better |
GalloDaSballo marked the issue as primary issue |
primary for the unbounded loop |
I have already judged a similar report for Gas, and because the variables are in memory, believe that the finding's impact is heavily diminished Let's assume each loop costs us: (both exaggerated) We'd need over 26k iterations before getting to 8MLN gas (AVAX cap) Additionally, the function is called by For this reason, I believe the finding to be valid, but to be of Low Severity L |
GalloDaSballo changed the severity to QA (Quality Assurance) |
GalloDaSballo marked the issue as grade-c |
Lines of code
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/RewardsPool.sol#L66
https://github.com/code-423n4/2022-12-gogopool/blob/aec9928d8bdce8a5a4efe45f54c39d4fc7313731/contracts/contract/RewardsPool.sol#L74
Vulnerability details
Impact
the function getInflationAmt will be more and more expensive to call.
Proof of Concept
note the function
note the for loop
This for loop has no upper bound and can grow and grow infinitely and consume more and more gas.
We need to look into getInflationIntervalsElapsed
startTime is set when the function is initiliazed.
block.timestamp only grows as time passes
the dao.getInflationIntervalSeconds() parameter is 1 day.
This is set in the ProtocolDAO.sol setting contract.
According to
the getInflationIntervalsElapsed value incresae by 1 per day. After 1 years, the loop needs to run 365 times, after 10 years, the look needs to run 3650 times, which is costly, which make user not incentived to call the function
Tools Used
Manual Review
Recommended Mitigation Steps
We recommend the project refractor the implementation the cache the looped amount to not make the for loop increasing infinitely.
The text was updated successfully, but these errors were encountered: