Skip to content
Business logic Audit finding Intermediate

Users may be forced into long lock times to be able to undelegate back to themselves

A check in the voting escrow contract requires that when delegating, the recipient's lock end must be at least as late as the sender's lock end. This means a user who delegated to someone with an earlier lock end cannot undelegate back to themselves without extending their own lock by five years, forcing them to remain delegated or accept a long unwanted lock extension.

ADM Follow with QiuhaoLi, SpicyMeatball and 12 others

Originally disclosed on Code4rena

Submitted by ADM, also found by lsaudit (1, 2), QiuhaoLi, Jorgect (1, 2), SpicyMeatball, bart1e (1, 2), Yanchuan, 3docSec, MrPotatoMagic, nemveer (1, 2), Yuki, kaden, nonseodion (1, 2), Watermelon, RandomUser, BenRai (1, 2), cducrest, Topmark, Tendency, 0xDING99YA, and Kow

Due to a check requiring users only be able to delegate to others or themselves with longer lock times and verwa’s restrictions of all changes increasing lock times by 5 years users may be forced to remain delegated to someone they do not wish to be or extend their lock much longer than they wish.

Proof of Concept

If a user does not delegate to another user who started their lock during the same epoch they will be unable to undelegate back to themselves without extending their own lock. This is not much of an issue if they wish to do so early in the lock period but can become a problem if they wish to delegate to themselves after a longer period of time. i.e.

  1. Bob creates lock in week 1.
  2. Dave create lock in week 2 & Bob delegates to Dave.
  3. 3 years pass and Bob decides he wishes to undelegate his votes back to himself and calls delegate(msg.sender) but the call will fail due to the check in VotingEscrow#L384:
require(toLocked.end >= fromLocked.end, "Only delegate to longer lock");
  1. In the original FiatDAO contracts a user would be able to just extend their lock by one week to get around this however any changes in the verwa contract results in an extension of 5 years which the user may not want extend their lock by such a long time just to be able to undelegate.

The undelegate fail can be shown by modifying the test testSuccessDelegate to:

    function testSuccessDelegate() public {
        // successful delegate
        testSuccessCreateLock();
        vm.warp(8 days); // warp more than 1 week so both users are not locking in same epoch
        vm.prank(user2);
        ve.createLock{value: LOCK_AMT}(LOCK_AMT);
        vm.prank(user1);
        ve.delegate(user2);
        (, , , address delegatee) = ve.locked(user1);
        assertEq(delegatee, user2);
        (, , int128 delegated, ) = ve.locked(user2);
        assertEq(delegated, 2000000000000000000);
    }

and running: forge test --match testSuccessUnDelegate

Recommended Mitigation Steps

Modify VotingEscrow#L384 to:

require(toLocked.end >= locked_.end, "Only delegate to self or longer lock");

which will allow users to delegate either to longer locks or undelegate back to themselves.

alcueca (Judge) increased severity to High and commented:

I’m merging #245 into this one as the root cause and general mechanics are the same, only that in the 245 group the intent was malicious and in this group is not.

At the same time, I’m upgrading the severity to High. Locking CANTO for an additional 5 years, considering that this is by nature a volatile environment, has an extremely high chance of resulting in losses due to market movements or other factors.

OpenCoreCH (veRWA) confirmed on duplicate 178


The original report as published on Code4rena, by ADM. 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 delegation check compares the recipient's lock end to the sender's lock end, preventing undelegation to self unless the sender extends their lock.

Impact

A user may be forced to remain delegated to someone they do not wish to be or extend their lock by five years, potentially causing losses due to market movements.

What the attacker needed

User has locked tokens; user has delegated to another user; recipient's lock ends earlier than user's lock

The fix

The check should be modified to allow delegation to self regardless of lock end, so users can undelegate without extending their lock.

How it was found

  1. Bob creates a lock in week 1.
  2. Dave creates a lock in week 2 and Bob delegates to Dave.
  3. After three years, Bob tries to undelegate back to himself by calling delegate with his own address.
  4. The call fails because Dave's lock end is earlier than Bob's lock end.

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 tokens for a period and can delegate their voting power to someone else. A rule says you can only delegate to someone whose lock ends later than or equal to yours. If you later want to take your votes back, you might not be allowed unless you extend your own lock, and here any extension adds five years.

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 ADM

View all

1 more disclosed report, best first.

More from veRWA

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.