Skip to content
Business logic Audit finding Intermediate

Voting overwrites checkpoint.voted in last checkpoint, so users can just vote right before claiming rewards

The gauge's reward calculation checks a 'voted' flag from the last checkpoint, but voting overwrites that flag without creating a new checkpoint. An attacker could vote just before claiming rewards and reset immediately after, receiving full rewards without maintaining a vote for the period.

smiling_heretic Follow

Originally disclosed on Code4rena

Submitted by smiling_heretic

Gauge.sol#L195 Gauge.sol#L489-L490 Gauge.sol#L499-L500

            if (cp0.voted) {
                reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION;

this line in gauge.earned function looks like the intention here is to incentivize users to keep their escrow.balanceOfNft voted for this gauge.

However, it’s enough to vote just before claiming rewards (even in the same transaction) and voter.reset just after receiving rewards to pass this if and get rewards for full period since last interaction with the gauge.

Proof of Concept

See original submission for test file.

Note, that Bob kept his votes for this gauge for full 6-day period but Alice just voted before claiming rewards. In logs, we can see that they both received the same (non-zero) amount of VELO tokens.

Alice can reset her votes in the same transaction after claiming rewards, if she decides to do so.

Tools Used

Foundry

Recommended Mitigation Steps

A partial solution would be to create a new checkpoint each time user’s voted status changes (setVoteStatus is called) instead of overwriting the voted in last one.

However, even then, users can just assign very small weight to this gauge, and lock very little VELO, so I don’t think this if statement helps with anything. I think, it’s better to rethink how to incentivize users to vote for specific gauges.

pooltypes (Velodrome) acknowledged and commented:

Patched in mainnet deployment.

Alex the Entreprenerd (judge) increased severity to High and commented:

The warden has found a way to sidestep the loss of rewards that automatically happens due to the faulty checkpoint system that always sets voted to false.

In doing so they also showed how the system can fall apart and provided a POC to replicate.

Because I’ve rated issues related to the voted checkpoints and loss of rewards with High Severity, at this time I believe this finding should also be bumped as it shows how the system is broken and the way to avoid a loss of rewards.

The sponsor seems to have remedied by deleting the voted logic.


The original report as published on Code4rena, by smiling_heretic. 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.

How it worked

Root cause

Likely the checkpoint system overwrites the 'voted' status in the last checkpoint instead of creating a new checkpoint when the vote status changes, so the reward calculation cannot tell how long the user actually voted.

Impact

Users could receive full rewards without keeping their votes for the required period, undermining the incentive mechanism.

What the attacker needed

A user with voting power; ability to claim rewards

The fix

The sponsor patched the issue in the mainnet deployment, and the judge noted the voted logic was deleted.

How it was found

  1. Vote for the gauge just before claiming rewards.
  2. Claim the rewards, which pass the voted check and pay for the full period.
  3. Reset the votes immediately after claiming, optionally in the same transaction.

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.

A smart contract gives extra rewards to users who keep their tokens voted for a particular gauge. The contract only checks whether you voted at the last checkpoint, not whether you voted for the whole period. So you can vote right before claiming, get the full reward, and then remove your vote.

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.

More by smiling_heretic

View all

1 more disclosed report, best first.

More from Velodrome Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.