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

Short Olive Penguin - notifyRewardAmount calls updateIndex() twice, making the second update useless #116

Closed
sherlock-admin4 opened this issue Jul 25, 2024 · 2 comments
Labels
Low/Info A Low/Info severity issue. Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin4
Copy link

Short Olive Penguin

Low/Info

notifyRewardAmount calls updateIndex() twice, making the second update useless

Summary

StakedEXA::notifyRewardAmount() can only be called by the admin role, in the call trace, the updateIndex() is called twice, first is line 454
https://github.com/sherlock-audit/2024-07-exactly-stacking-contracts/blob/main/protocol/contracts/StakedEXA.sol#L454
second is line 210
https://github.com/sherlock-audit/2024-07-exactly-stacking-contracts/blob/main/protocol/contracts/StakedEXA.sol#L210

Vulnerability Detail

When first call the updateIndex(), it sets rewardData.index to globalIndex(reward), deep into the globalIndex(), there is (rewardData.rate * (lastTimeRewardApplicable(rewardData.finishAt) - rewardData.updatedAt)), because rewardData.updatedAt is set to lastTimeRewardApplicable(rewardData.finishAt) at line 122.So the second call of updateIndex() will result in rewardData.rate * 0, which is meaning less.

Impact

multiple call may cause undesirable behavior and results in unexpected results.

Code Snippet

https://github.com/sherlock-audit/2024-07-exactly-stacking-contracts/blob/main/protocol/contracts/StakedEXA.sol#L454
https://github.com/sherlock-audit/2024-07-exactly-stacking-contracts/blob/main/protocol/contracts/StakedEXA.sol#L210

Tool used

Manual Review

Recommendation

Remove the first updateIndex()

@sherlock-admin4 sherlock-admin4 added Low/Info A Low/Info severity issue. Non-Reward This issue will not receive a payout labels Jul 25, 2024
@sherlock-admin3 sherlock-admin3 added Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Jul 30, 2024
@sherlock-admin2
Copy link
Contributor

The protocol team fixed this issue in the following PRs/commits:
exactly/protocol#758

@sherlock-admin2
Copy link
Contributor

The Lead Senior Watson signed off on the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low/Info A Low/Info severity issue. Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

3 participants