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

totalDeclaredReward >= totalReleasedReward not true in AbstractRewardMine #246

Open
code423n4 opened this issue Dec 1, 2021 · 2 comments
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

cmichel

Vulnerability details

The AbstractRewardMine contract states the following about the two variables:

totalReleasedReward and totalDeclaredReward will often be the same. However, in the case of vesting rewards they are different. In that case totalDeclaredReward is total reward, including unvested. totalReleasedReward is just the rewards that have completed the vesting schedule.

According to the description, it should be the case that totalDeclaredReward >= totalReleasedReward at all times.
But it's not true as totalReleasedReward = totalDeclaredReward + _globalWithdrawn >= totalDeclaredReward.

Recommended Mitigation Steps

I don't think the implementation in the abstract contract makes sense, the derived contracts all correctly overwrite it.
Maybe it should be a virtual function without an implementation that needs to be overridden.

@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Dec 1, 2021
code423n4 added a commit that referenced this issue Dec 1, 2021
@0xScotch 0xScotch added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Dec 6, 2021
@0xScotch
Copy link
Collaborator

0xScotch commented Dec 6, 2021

The AbstractRewardMine implementation is indeed incorrect. The solution is to add + _globalWithdrawn to the totalDeclaredReward method.

As stated in the issue above, the 2 places that inherit this contract correctly override the methods in question.

@GalloDaSballo
Copy link
Collaborator

Will mark the finding valid as the logic detailed was incorrect, as for the inheritance discussion, probably best left for a different issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants