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.
The voting mechanism for the periods that have a bribe will be DoSed
Summary
The deposit function in BribeRewarder.sol incorrectly checks token ownership, leading to a DoS of the voting mechanism when there's a bribe for a period.
_notifyBribes(_currentVotingPeriodId, pool, tokenId, deltaAmount); // msg.sender, deltaAmount);
}
_notifyBribes checks if there's a bribe rewarder for the given period and pool. If there is, it will call the deposit function of the BribeRewarder.sol:
if (address(rewarders[i]) !=address(0)) {
rewarders[i].deposit(periodId, tokenId, deltaAmount);
_userBribesPerPeriod[periodId][tokenId].push(rewarders[i]);
The deposit function in BribeRewarder.sol will call _modify to deposit votes for the given period and token ID:
function deposit(uint256periodId, uint256tokenId, uint256deltaAmount) public onlyVoter {
_modify(periodId, tokenId, deltaAmount.toInt256(), false);
emitDeposited(periodId, tokenId, _pool(), deltaAmount);
}
The problem is that there's a check in _modify to see if the msg.sender is the owner of the token or not:
if (!IVoter(_caller).ownerOf(tokenId, msg.sender)) {
revertBribeRewarder__NotOwner();
}
In the context of the BribeRewarder.sol, the msg.sender is the Voter.sol and not the actual owner of the token, so the transaction will revert with the BribeRewarder__NotOwner error.
Coded PoC
Please make a file named VoteDoS.t.sol in this path: /test/ and paste the following test code in it:
The voting mechanism for the periods that have a bribe will be completely DoSed, users won't get their rewards and the funds will be locked up in BribeRewarder.sol.
Given that the _modify function is also used in claim and works in that context as expected, you can't remove that check from _modify. Instead, you have to implement another function that doesn't include that check and call that function from deposit:
sherlock-admin4
changed the title
Muscular Pearl Sparrow - The voting mechanism for the periods that have a bribe will be DoSed
Yashar - The voting mechanism for the periods that have a bribe will be DoSed
Jul 29, 2024
Yashar
Medium
The voting mechanism for the periods that have a bribe will be DoSed
Summary
The
deposit
function inBribeRewarder.sol
incorrectly checks token ownership, leading to a DoS of the voting mechanism when there's a bribe for a period.Vulnerability Detail
Users who want to vote should call the
vote
function.The
vote
function will call_notifyBribes
:_notifyBribes
checks if there's a bribe rewarder for the given period and pool. If there is, it will call thedeposit
function of theBribeRewarder.sol
:The
deposit
function inBribeRewarder.sol
will call_modify
to deposit votes for the given period and token ID:The problem is that there's a check in
_modify
to see if themsg.sender
is the owner of the token or not:In the context of the
BribeRewarder.sol
, themsg.sender
is theVoter.sol
and not the actual owner of the token, so the transaction will revert with theBribeRewarder__NotOwner
error.Coded PoC
Please make a file named
VoteDoS.t.sol
in this path:/test/
and paste the following test code in it:Run the test:
forge test --mt test_VoteDoS
Impact
The voting mechanism for the periods that have a bribe will be completely DoSed, users won't get their rewards and the funds will be locked up in
BribeRewarder.sol
.Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/Voter.sol#L211
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/Voter.sol#L225
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L144
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L264
Tool used
Manual Review
Recommendation
Given that the
_modify
function is also used inclaim
and works in that context as expected, you can't remove that check from_modify
. Instead, you have to implement another function that doesn't include that check and call that function fromdeposit
:Duplicate of #39
The text was updated successfully, but these errors were encountered: