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

StakingRewards.setRewardsDuration allows setting near zero or enormous rewardsDuration, which breaks reward logic #51

Open
code423n4 opened this issue Sep 16, 2022 · 1 comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/rewards/StakingRewards.sol#L225-L232

Vulnerability details

Impact

Similar to code-423n4/2022-02-concur-findings#223.
notifyRewardAmount will be inoperable if rewardsDuration bet set to zero. If will cease to produce meaningful results if rewardsDuration be too small or too big.

Proof of Concept

The setter do not control the value, allowing zero/near zero/enormous duration:

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/rewards/StakingRewards.sol#L225-L232

Division by the duration is used in notifyRewardAmount:

https://github.com/code-423n4/2022-09-y2k-finance/blob/ac3e86f07bc2f1f51148d2265cc897e8b494adf7/src/rewards/StakingRewards.sol#L189-L195

Tools Used

None

Recommended Mitigation Steps

Check for min and max range in the rewardsDuration setter, as too small or too big rewardsDuration breaks the logic

@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 Sep 16, 2022
code423n4 added a commit that referenced this issue Sep 16, 2022
@MiguelBits MiguelBits added the invalid This doesn't seem right label Sep 30, 2022
@liveactionllama liveactionllama added sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue and removed invalid This doesn't seem right labels Oct 3, 2022
@HickupHH3
Copy link
Collaborator

While the finding is valid,

  • if the rewardsDuration is set to zero, the loss of functionality of notifyRewardAmount has no impact on funds nor existing rewards. function can be called again to re-set its value. one can also view it as a way to prevent further reward distributions
  • if the rewardsDuration is too big: "will cease to produce meaningful results" is a very vague description. More details need to be provided on this: it can cause rewardsRate to be zero, thus bricking reward distribution.

Because the former point has minimal impact while the latter lacks a crucial step in explaining the adverse impact of failing reward distributions, I have to downgrade the issue to QA.

User's primary QA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

4 participants