Not updating totalWeight when operator is removed in VeTokenMinter
The VeTokenMinter contract fails to reduce totalWeight when an operator is removed, so remaining operators receive a smaller share of rewards and some rewards are never minted. An attacker cannot directly exploit this, but the misconfiguration causes unfair reward distribution.
Submitted by sseefried, also found by shenwilly
Impact
The totalWeight state variable of the VeTokenMinter contract is used to work out the amount of veAsset earned when the Booster.rewardClaimed function is called.
However, while totalWeight is modified inside the VeTokenMinter contract when function updateveAssetWeight is called, the totalWeight is not similarly reduced when function removeOperator 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
- Operator 1 is added with weight 9
- Operator 2 is added with weight 1
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. Function rewardClaimed 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.
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 by
- adding the removed operator with
addOperator - setting the weight to
0usingupdateveAssetWeight. This will have the effect of reducing thetotalWeightby the right amount. - removing the operator again using
removeOperator
However, the removeOperator function should just be rewritten to be as follows:
function removeOperator(address _operator) public onlyOwner {
totalWeight -= veAssetWeights[_operator];
veAssetWeights[_operator] = 0;
operators.remove(_operator);
}
You might also want to modify addOperator so that a weight can be provided as an extra argument. This saves having to call addOperator and then updateveAssetWeight which could save on gas.
solvetony (veToken Finance) disagreed with severity and commented:
Confirmed. But this should be a middle risk.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
The warden has shown how, due to a privileged call, removing an operator, the weight used to distribute rewards will not be updated fairly. This will cause an improper distribution of rewards.
Because the finding is limited to Loss of Yield, due to Admin Configuration, I believe Medium Severity to be more appropriate.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
Remaining operators do not receive a fair share of the total rewards and a portion of the rewards are not given out at all; the judge rated this as Medium severity due to loss of yield from admin configuration.
What the attacker needed
Owner privilege to call removeOperator; at least two operators with different weights
The fix
The removeOperator function should be rewritten to subtract the operator's weight from totalWeight before removing the operator.
How it was found
- Operator 1 is added with weight 9
- Operator 2 is added with weight 1
- The totalWeight becomes 10, so Operator 1 gets 90% and Operator 2 gets 10%
- removeOperator is called on Operator 1, but totalWeight stays 10
- Operator 2 still receives only 10% of rewards, and 90% is never minted
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where a number used to split rewards is not updated when a participant is removed. As a result, the remaining participants get less than they should, and some rewards are never given out at all.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.