If governance removes a gauge, user’s voting power for that gauge will be lost
When governance removes a gauge, users who had voted for it cannot withdraw their voting power because the contract rejects votes for removed gauges. This permanently locks the voting power allocated to that gauge, preventing users from reallocating it to other gauges.
Submitted by thekmj, also found by mert_eren, popular00, Eeyore, immeas, bart1e, 0xCiphky, ltyu, 0xbrett8571, deadrxsezzz, 0xDetermination, Tripathi, Team_Rocket, and pep7siup
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L127-L132
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L213
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L241
If governance removes a gauge for any (non-malicious) reason, a user’s voting power for that gauge will be completely lost.
Vulnerability details
The GaugeController is a solidity port of Curve DAO’s Vyper implementation. Users are to vote for channeling incentives by using the vote_for_gauge_weights() function, and each user can fraction their voting power by $10000$ (that is, defined by BPS).
One modification from the original is that governance can now remove gauges, not allowing users to vote on it. However, any existing individual user’s voting power before removal is not reset. Since vote_for_gauge_weights() does not allow voting for removed gauges, the voting power is then forever lost.
Consider the following scenario:
- Alice has some veRWA, and is now able to vote.
- She votes on some pool, say, G1, using 100% of her voting power.
- Pool G1 is removed by governance due to any reason. Perhaps the pool was found to be faulty and liquidity should be migrated, perhaps the market itself has became illiquid and unsafe, perhaps the intended incentives duration for that pool has simply expired.
- Alice still has 100% of her voting power in that pool, but she cannot remove her vote and claim the voting power back.
It is worth noting that, even if Alice does not use 100% of her voting power on that particular gauge, she would still lose whatever percent vote placed in that pool, and her overall voting power was weakened by said percent.
Impact
Users can lose their voting power.
Proof of concept
We provide the following POC to use on GaugeController tests.
function testPOC() public {
// prepare
uint256 v = 10 ether;
vm.deal(gov, v);
vm.startPrank(gov);
ve.createLock{value: v}(v);
// add gauges
gc.add_gauge(gauge1);
gc.change_gauge_weight(gauge1, 100);
gc.add_gauge(gauge2);
gc.change_gauge_weight(gauge2, 100);
// all-in on gauge1
gc.vote_for_gauge_weights(gauge1, 10000);
// governance removes gauge1
gc.remove_gauge(gauge1);
// cannot vote for gauge2
vm.expectRevert("Used too much power");
gc.vote_for_gauge_weights(gauge2, 10000);
// cannot remove vote for gauge1
vm.expectRevert("Invalid gauge address"); // @audit remove when mitigate
gc.vote_for_gauge_weights(gauge1, 0);
// cannot vote for gauge2 (to demonstrate again that voting power is not removed)
vm.expectRevert("Used too much power"); // @audit remove when mitigate
gc.vote_for_gauge_weights(gauge2, 10000);
}
Tools used
Forge
Recommended mitigation steps
The simplest way to mitigate this is to allow zero-weight votings on expired pools simply to remove the vote. Modify line 213 as follow:
require(_user_weight == 0 || isValidGauge[_gauge_addr], "Can only vote 0 on non-gauges");
https://github.com/code-423n4/2023-08-verwa/blob/main/src/GaugeController.sol#L213
The given POC can then be the test case to verify successful mitigation.
As a QA-based recommendation, the sponsor can also provide an external function to remove votes, and/or provide a function to vote for various pools in the same tx. This will allow users to channel their votes directly from removed pools to ongoing pools.
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
Users can permanently lose the voting power they allocated to a removed gauge, weakening their overall influence.
What the attacker needed
User has voting power; user voted for a gauge; governance removes that gauge
The fix
The report recommends allowing zero-weight votes on removed gauges so users can clear their allocation, and optionally adding a function to remove votes or vote for multiple gauges in one transaction.
How it was found
- Alice creates a lock and receives voting power.
- Alice votes for gauge G1 using 100% of her voting power.
- Governance removes gauge G1.
- Alice tries to vote for another gauge but is rejected because her power is still allocated to G1.
- Alice tries to remove her vote from G1 but is rejected because the gauge is no longer valid.
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.
In this system, users lock tokens to get voting power and can direct that power to different 'gauges' (pools that receive rewards). If the administrators later remove a gauge, the contract no longer accepts votes for it, so any voting power a user had placed there cannot be withdrawn or moved. That power is stuck and cannot be used elsewhere.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.