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
A malicious attacker can damage the bribe distribution function at low cost.
Summary
Anyone can create a bribe reward and thus the attacker can control the distribution of the bribe.
Vulnerability Detail
As you know, in RewarderFactory.sol anyone can create a bribe reward.
function createBribeRewarder(IERC20token, addresspool) externalreturns (IBribeRewarder rewarder) {
rewarder =IBribeRewarder(_cloneBribe(RewarderType.BribeRewarder, token, pool));
emitBribeRewarderCreated(RewarderType.BribeRewarder, token, pool, rewarder);
}
BribeRewarder.sol uses fundAndBribe() and bribe() to distribute bribes to certain pools in a given period.
function _bribe(uint256startId, uint256lastId, uint256amountPerPeriod) internal {
_checkAlreadyInitialized();
if (lastId < startId) revertBribeRewarder__WrongEndId();
if (amountPerPeriod ==0) revertBribeRewarder__ZeroReward();
IVoter voter =IVoter(_caller);
if (startId <= voter.getCurrentVotingPeriod()) {
revertBribeRewarder__WrongStartId();
}
uint256 totalAmount =_calcTotalAmount(startId, lastId, amountPerPeriod);
uint256 balance =_balanceOfThis(_token());
if (balance < totalAmount) revertBribeRewarder__InsufficientFunds();
_startVotingPeriod = startId;
_lastVotingPeriod = lastId;
_amountPerPeriod = amountPerPeriod;
// create rewads per perioduint256 bribeEpochs =_calcPeriods(startId, lastId);
for (uint256 i =0; i <= bribeEpochs; ++i) {
_rewards.push();
}
_lastUpdateTimestamp =block.timestamp;
IVoter(_caller).onRegister();
emitBribeInit(startId, lastId, amountPerPeriod);
}
But here this funtion calls onRegister() of Voter.sol.
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 registeredrequire(periods[i] >= currentPeriodId, "wrong period");
@ require(_bribesPerPriod[periods[i]][pool].length+1<= Constants.MAX_BRIBES_PER_POOL, "too much bribes");
_bribesPerPriod[periods[i]][pool].push(rewarder);
}
}
As you can see, the number of bribeRewarders in the pool that can distribute bribes in a given period cannot exceed MAX_BRIBES_PER_POOL (5).
Therefore attacker only needs to create a BribeRewarder and consume the gas to run fundAndBribe().
Impact
The attacker manipulates the bribe distribution function to damage the core functionality of the protocol.
sherlock-admin4
changed the title
Abundant Pickle Rattlesnake - A malicious attacker can damage the bribe distribution function at low cost.
blockchain555 - A malicious attacker can damage the bribe distribution function at low cost.
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
blockchain555
Medium
A malicious attacker can damage the bribe distribution function at low cost.
Summary
Anyone can create a bribe reward and thus the attacker can control the distribution of the bribe.
Vulnerability Detail
As you know, in
RewarderFactory.sol
anyone can create a bribe reward.BribeRewarder.sol
usesfundAndBribe()
andbribe()
to distribute bribes to certain pools in a given period.But here this funtion calls
onRegister()
ofVoter.sol
.As you can see, the number of bribeRewarders in the pool that can distribute bribes in a given period cannot exceed
MAX_BRIBES_PER_POOL
(5).Therefore attacker only needs to create a BribeRewarder and consume the gas to run
fundAndBribe()
.Impact
The attacker manipulates the bribe distribution function to damage the core functionality of the protocol.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L111-L124
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L226-L258
Tool used
Manual Review
Recommendation
Ensure that only permitted people call
createBribeRewarder()
inRewarderFactory.sol
.Duplicate of #190
The text was updated successfully, but these errors were encountered: