Not updating totalWeight
when operator is removed in VeTokenMinter
#120
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
disagree with severity
Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments)
Lines of code
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L36-L38
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VeTokenMinter.sol#L41-L4
https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L598-L614
Vulnerability details
Impact
The
totalWeight
state variable of theVeTokenMinter
contract is used to work out the amount ofveAsset
earned when theBooster.rewardClaimed
function is called.However, while
totalWeight
is modified inside theVeTokenMinter
contract when functionupdateveAssetWeight
is called, thetotalWeight
is not similarly reduced when functionremoveOperator
is called.The impact is that remaining operators do not receive a fair share of the total rewards and a portion of the rewards are not given out at all.
Proof of Concept
The
totalWeight
is now 10.This means that Operator 1 receives 90% of the amount while Operator 2 receives 10%.
If we then call
removeOperator
on Operator 1 then 90% of the reward is no longer minted and distributed. This is unfair to the remaining operators.The can be seen on lines 607 - 608 of the
Booster
contract. FunctionrewardClaimed
will never be called for (removed) Operator 1. But for Operator 2 they will still receive 10% of the rewards even though Operator 1 is no longer registered in the system.Tools Used
Manual Inspection
Recommended Mitigation Steps
The
totalWeight
should be reduced so that the remaining operators receive a fair share of the total rewards.Using just method calls from
VeTokenMinter
one could rectify this situation byaddOperator
0
usingupdateveAssetWeight
. This will have the effect of reducing thetotalWeight
by the right amount.removeOperator
However, the
removeOperator
function should just be rewritten to be as follows:You might also want to modify
addOperator
so that a weight can be provided as an extra argument. This saves having to calladdOperator
and thenupdateveAssetWeight
which could save on gas.The text was updated successfully, but these errors were encountered: