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.
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
RewarderFactory.sol#createBribeRewarder doesn't check if caller is owner.
Therefore, attacker can create bribe rewarders many times as he/she wants and then register them to the Voter contract.
Vulnerability Detail
RewarderFactory.sol#createBribeRewarder function is the following.
function createBribeRewarder(IERC20token, addresspool) externalreturns (IBribeRewarder rewarder) {
rewarder =IBribeRewarder(_cloneBribe(RewarderType.BribeRewarder, token, pool));
emitBribeRewarderCreated(RewarderType.BribeRewarder, token, pool, rewarder);
}
As can be seen, since it doesn't check if msg.sender is owner, attacker can create bribe rewarders many times as he/she wants and then register them to the Voter contract.
Voter.sol#onRegister function is the following.
function onRegister() externaloverride {
IBribeRewarder rewarder =IBribeRewarder(msg.sender);
_checkRegisterCaller(rewarder);
uint256 currentPeriodId = _currentVotingPeriodId;
(addresspool, uint256[] memoryperiods) = rewarder.getBribePeriods();
for (uint256 i =0; i < periods.length; ++i) {
// TODO check if rewarder token + pool is already registered @audit-info no implementation require(periods[i] >= currentPeriodId, "wrong period");
141: require(_bribesPerPriod[periods[i]][pool].length+1<= Constants.MAX_BRIBES_PER_POOL, "too much bribes");
_bribesPerPriod[periods[i]][pool].push(rewarder);
}
}
As can be seen, the maximum count of bribes per pool is limited to MAX_BRIBES_PER_POOL = 5.
So, if the attacker create 5 fake bribe rewarders and register them to the voter, administrator can't register normal bribe rewarder to the Voter contract.
Impact
An attacker can prevent administrator from registering bribe rewarders to the Voter contract.
As a result, voters cannot receive bribes.
sherlock-admin4
changed the title
Petite Rouge Huskie - Anyone can create bribe rewarder.
dany.armstrong90 - Anyone can create bribe rewarder.
Jul 29, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA Medium severity issue.RewardA payout will be made for this issue
dany.armstrong90
High
Anyone can create bribe rewarder.
Summary
RewarderFactory.sol#createBribeRewarder
doesn't check if caller is owner.Therefore, attacker can create bribe rewarders many times as he/she wants and then register them to the Voter contract.
Vulnerability Detail
RewarderFactory.sol#createBribeRewarder
function is the following.As can be seen, since it doesn't check if msg.sender is owner, attacker can create bribe rewarders many times as he/she wants and then register them to the Voter contract.
Voter.sol#onRegister
function is the following.As can be seen, the maximum count of bribes per pool is limited to
MAX_BRIBES_PER_POOL = 5
.So, if the attacker create 5 fake bribe rewarders and register them to the voter, administrator can't register normal bribe rewarder to the Voter contract.
Impact
An attacker can prevent administrator from registering bribe rewarders to the Voter contract.
As a result, voters cannot receive bribes.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/tree/main/magicsea-staking/src/rewarders/RewarderFactory.sol#L109-L113
Tool used
Manual Review
Recommendation
Modify the
RewardFactory.sol#createBribeRewarder
function as follows.Duplicate of #190
The text was updated successfully, but these errors were encountered: