Users can front-run calls to change_gauge_weight to gain extra voting power
The change_gauge_weight function sets a gauge's weight directly, so a user who had voted can remove their vote before the change and re-vote after, making the final weight higher than intended. This lets users gain extra voting power.
Users can get extra voting power by front-running calls to change_gauge_weight.
Proof of Concept
It can be expected that in some cases calls will be made to change_gauge_weight to increase or decrease a gauge’s weight. The problem is users can be monitoring the mempool expecting such calls. Upon seeing such, any people who have voted for said gauge can just remove their vote prior to change_gauge_weight. Once it executes, they can vote again for their gauge, increasing its weight more than it was expected to be: Example:
Gauge has 1 user who has voted and contributed for 10_000 weight
They see an admin calling change_gauge_weight with value 15_000.
User front-runs it and removes all their weight. Gauge weight is now 0.
Admin function executes. Gauge weight is now 15_000
User votes once again for the gauge for the same initial 10_000 weight. Gauge weight is now 25_000.
Gauge weight was supposed to be changed from 10_000 to 15_000, but due to the user front-running, gauge weight is now 25_000.
Recommended Mitigation Steps
Instead of having a set function, use increase/ decrease methods.
In practice the function should only be used to set the weights to 0 (e.g., when a market got exploited and not all users withdrew their votes yet). But there is nothing that prevents it from setting it to a higher or lower value (at least not in the audited codebase, added that in the meantime). So what is described in the finding is generally true, although it does not require frontrunning or anything like that, because the function just changes the current voting result, anyway. So if voting for the market is not restricted afterwards (by removing it from the whitelist), people can continue to vote on it and the final vote result may be different than what governance has set with this function.
From what I understand the function is essentially broken, and a Medium severity is appropriate given that wardens can’t assume that it will be used only to set the weights to 0 for non-whitelisted markets.
The original report as published on Code4rena, by deadrxsezzz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the function sets the gauge weight to an absolute value instead of adjusting it relative to existing votes, so user votes are not preserved or restricted.
Impact
Users could gain extra voting power, making the final gauge weight higher than governance intended; the judge noted that votes are only counted at the first second of an epoch, so front-running may not work in practice, but the function is still broken.
What the attacker needed
User has voted on a gauge; admin calls change_gauge_weight; user can front-run the transaction
How it was found
A gauge has one user who voted with 10,000 weight.
The admin calls change_gauge_weight with a new value of 15,000.
The user front-runs and removes all their weight, making the gauge weight 0.
The admin's function executes, setting the gauge weight to 15,000.
The user votes again with the same 10,000 weight, making the gauge weight 25,000.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A gauge is a pool that receives rewards based on votes. The admin can change a gauge's weight with a function that sets the total directly. If a user removes their vote just before the admin's change and adds it back just after, the admin's new total plus the user's vote adds up to more than the admin wanted.
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.