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

lastUpdatedDay not initialized #14

Open
code423n4 opened this issue Apr 4, 2021 · 0 comments
Open

lastUpdatedDay not initialized #14

code423n4 opened this issue Apr 4, 2021 · 0 comments
Labels
3 (High Risk) bug Something isn't working

Comments

@code423n4
Copy link
Collaborator

Email address

[email protected]

Handle

gpersoon

Eth address

gpersoon.eth

Vulnerability details

The variable lastUpdatedDay in IncentiveDistribution.sol is not (properly) initialized.
This means the function updateDayTotals will end up in a very large loop which will lead to an out of gas error.
Even if the loop would end, the variable currentDailyDistribution would be updated very often.
Thus updateDayTotals cannot be performed

Impact

The entire IncentiveDistribution does not work.
If the loop would stop, the variable currentDailyDistribution is not accurate, resulting in a far lower incentive distribution than expected.

Recommended mitigation steps

Initialize lastUpdatedDay with something like block.timestamp / (1 days)

Proof of concept

uint256 lastUpdatedDay; # ==> lastUpdatedDay = 0

#When the function updateDayTotals is called:
uint256 public nowDay = block.timestamp / (1 days); #==> ~ 18721
uint256 dayDiff = nowDay - lastUpdatedDay; #==> 18721-0 = 18721

for (uint256 i = 0; i < dayDiff; i++) { # very long loop (18721)
currentDailyDistribution = ....
}
#will result in an out of gas error

@code423n4 code423n4 added 3 (High Risk) bug Something isn't working labels Apr 4, 2021
code423n4 added a commit that referenced this issue Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant