Skip to content
Business logic Audit finding Intermediate

Expired locks should not continue to earn rewards at the original high multiplier rate

Expired locks in a liquidity mining contract continued to earn rewards at the original high multiplier rate, even though users could withdraw at any time. This meant users with expired locks received more rewards than intended, reducing rewards for others.

WatchPug Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-merit-circle-judging/issues/108

Found by

WATCHPUG

Summary

Expired locks should be considered as same as the deposits with no lock.

Vulnerability Detail

The current implementation allows the deposits with expired locks to continue to enjoy the original high multiplier rate, while they can withdraw anytime they want.

The multiplier of shares amount is essentially a higher reward rate (APR) for longer period of locks.

For example:

If the regular APR is 2%; Locking for 4 years will boost the APR to 10%.

  • Alice deposited 1M $MC tokens and got 10% APR;
  • 4 years later, Alice's deposit's lock was expired.

Expected result:

The new APR for Alice's deposit is 2%;

Actual result:

Alice can continue to enjoy a 10% APR while she can withdraw anytime.

Impact

Users with expired locks will take more rewards than expected, which means fewer rewards for other users.

Code Snippet

https://github.com/Merit-Circle/merit-liquidity-mining/blob/ce5feaae19126079d309ac8dd9a81372648437f1/contracts/TimeLockPool.sol#L116-L135

Tool used

Manual Review

Recommendation

Curve's Gauge system introduced a method called kick() which allows the expired (zeroed) veCRV users to be kicked from the rewards.

See: https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/gauges/LiquidityGaugeV5.vy#L430-L446

A similar method can be added to solve this issue:

Solidity
function kick(uint256 _depositId, address _user) external {
    if (_depositId >= depositsOf[_user].length) {
        revert NonExistingDepositError();
    }
    Deposit memory userDeposit = depositsOf[_user][_depositId];
    if (block.timestamp < userDeposit.end) {
        revert TooSoonError();
    }

    // burn pool shares
    _burn(_user, userDeposit.shareAmount - userDeposit.amount);
}

Discussion

federava

Agree on the recommendation, will implement kick function. Noticing that shares go back to a 1:1 ratio and that the function can be called by anyone is a good design choice.

federava

PR from this issue

The original report as published on Sherlock, by WATCHPUG. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 reward calculation did not check whether a deposit's lock had expired, so the multiplier remained at the original high value.

Impact

Users with expired locks could take more rewards than expected, which means fewer rewards for other users.

What the attacker needed

A deposit with an expired lock

The fix

The project agreed to implement a kick function that allows anyone to burn the extra shares of expired locks, resetting their reward rate.

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 some crypto reward systems, you get a higher interest rate if you lock your tokens for a long time. This report found that after the lock period ended, the system still gave the higher rate, even though the tokens could be withdrawn immediately. That meant those users got extra rewards at the expense of others.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Merit Circle

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.