Skip to content
Business logic Audit finding Intermediate

increaseUnlockTime missing _checkpoint for delegated values

The increaseUnlockTime function in the VotingEscrow contract fails to update voting power for users who are both delegators and delegatees, because the checkpoint is skipped when the user has delegated to someone else. This allows a user to extend their lock time without gaining the corresponding voting power from funds delegated to them.

PwnedNoMore Follow

Originally disclosed on Code4rena

Submitted by PwnedNoMore, also found by ak1, CertoraInc, and scaraven

https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L509-L515

In the VotingEscrow contract, users can increase their voting power by:

  • Adding more funds to their delegated value
  • Increasing the time of their lock
  • Being delegated by another user

Specifically, when users are delegated by other users through the delegate function, the delegated user gains control over the delegate funds from the delegating user.

The delegated user can further increase this power by increasing the time that the delegated funds are locked by calling increaseUnlockTime, resulting in ALL the delegated funds controlled by the delegated user, including those that do not originate from the delegated user, being used to increase the voting power of the user.

The issue lies in the following scenario: If user A delegates to user B, and then user B delegates to user C, user B loses the ability to extend his or her voting power by increaseUnlockTime due to a missing _checkpoint operation. If user B calls the increaseUnlockTime function, the _checkpoint operation will not proceed, as user B is delegating to user C. However, B still owns delegated funds, in the form of the funds delegated from user A. Therefore, user B should still gain voting power from increaseUnlockTime, even though user B is delegating.

Proof of Concept

Assume three users, Alice, Bob, and Carol, who each possess locks with 10 units of delegate value. Also assume that the unlock time is 1 week.

  • Alice delegates her 10 units to Bob.
  • Bob then delegates his 10 units to Carol.
  • At this point, Alice has 0 delegate, value, Bob has 10 delegate value, and Carol has 20 delegate value.
  • Carol calls increaseUnlockTime to 2 weeks, resulting in _checkpoint raising her voting power accordingly.
  • Bob calls increaseUnlockTime to 2 weeks, resulting in no change in his voting power, even though he has 10 units of delegate value.

Recommended Mitigation Steps

Move the _checkpoint outside of the if statement on line 514.

lacoop6tu (FIAT DAO) confirmed, but disagreed with severity and commented:

As most of wardens reported in duplicated, this is Medium finding 2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.

Justin Goro (judge) decreased severity to Medium

IllIllI (warden) reviewed mitigation:

The sponsor addressed the finding with the fix for Issue 2. In cases where a user is both a delegator and a delegatee, the original code did not create a checkpoint for calls to increaseUnlockTime(). Self-delegation and being delegated to both increase the LockedBalance.delegated field, so the change to the condition of the if-statement now includes both cases. The code will not get to the if-statement if the user has already withdrawn, due to a require(), so a user that has delegates but has withdrawn, cannot increase their now-zero unlock time. increaseAmount() has a similar if-statement and comment, but the else-block is already covered by a checkpoint, so there is no analogous issue there.


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

The _checkpoint call is inside an if-statement that only runs when the user is not delegating, so users who are both delegators and delegatees skip the checkpoint update.

Impact

A user who is both a delegator and a delegatee cannot increase their voting power by extending their lock time, potentially reducing their influence in governance.

What the attacker needed

User is both a delegator and a delegatee; User calls increaseUnlockTime

The fix

The _checkpoint call should be moved outside the if-statement so it runs for all users, and the sponsor addressed the finding with a fix.

How it was found

  1. Alice delegates her 10 units to Bob.
  2. Bob delegates his 10 units to Carol.
  3. Carol calls increaseUnlockTime to 2 weeks, and her voting power increases.
  4. Bob calls increaseUnlockTime to 2 weeks, but his voting power does not change.

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 voting system, users lock funds to get voting power and can delegate that power to others. When you extend your lock time, your voting power should increase. But if you have delegated your own power to someone else while also receiving delegated power from another, the code forgets to update your voting power when you extend your lock. This means you lose out on voting power you should have gained.

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 PwnedNoMore

View all

8 more disclosed reports, best first.

More from FIAT DAO veFDT 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.