You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
Users can not claim from BribeRewarder when Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1
Summary
When Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1, there will be index out of bounds error when accessing the BribeRewarder#_rewards, which will prevent users from claiming rewards.
Vulnerability Detail
When a user creates a BribeRewarder and bribes, there will be _lastVotingPeriod - _startVotingPeriod + 2 RewardPerPeriod added to the _rewards array
when Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1, the BribeRewarder#_modify will revert because of accessing an index out of bounds at
Users can not claim from BribeRewarder when Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1, which will result in DoS on BribeRewarder#claim and loss of funds.
0xSmartContract
added
Medium
A Medium severity issue.
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
High
A High severity issue.
and removed
Excluded
Excluded by the judge without consulting the protocol or the senior
Medium
A Medium severity issue.
labels
Jul 27, 2024
sherlock-admin4
changed the title
Acidic Sable Loris - Users can not claim from BribeRewarder when Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1
iamnmt - Users can not claim from BribeRewarder when Voter#getLatestFinishedPeriod() is greater than BribeRewarder#_lastVotingPeriod + 1Jul 29, 2024
iamnmt
High
Users can not claim from
BribeRewarder
whenVoter#getLatestFinishedPeriod()
is greater thanBribeRewarder#_lastVotingPeriod + 1
Summary
When
Voter#getLatestFinishedPeriod()
is greater thanBribeRewarder#_lastVotingPeriod + 1
, there will be index out of bounds error when accessing theBribeRewarder#_rewards
, which will prevent users from claiming rewards.Vulnerability Detail
When a user creates a
BribeRewarder
and bribes, there will be_lastVotingPeriod - _startVotingPeriod + 2 RewardPerPeriod
added to the_rewards
arrayhttps://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/rewarders/BribeRewarder.sol#L248
When a user calls
BribeRewarder#claim
, the rewards is claimed from_startVotingPeriod
toVoter#getLatestFinishedPeriod()
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/rewarders/BribeRewarder.sol#L159
when
Voter#getLatestFinishedPeriod()
is greater thanBribeRewarder#_lastVotingPeriod + 1
, theBribeRewarder#_modify
will revert because of accessing an index out of bounds athttps://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/rewarders/BribeRewarder.sol#L274
Impact
Users can not claim from
BribeRewarder
whenVoter#getLatestFinishedPeriod()
is greater thanBribeRewarder#_lastVotingPeriod + 1
, which will result in DoS onBribeRewarder#claim
and loss of funds.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/rewarders/BribeRewarder.sol#L154
https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/rewarders/BribeRewarder.sol#L274
Tool used
Manual Review
Recommendation
endPeriod
should be the minimum ofVoter#getLatestFinishedPeriod()
andBribeRewarder#_lastVotingPeriod
src/rewarders/BribeRewarder.sol:154
src/rewarders/BribeRewarder.sol:166
Duplicate of #164
The text was updated successfully, but these errors were encountered: