Skip to content
Business logic Audit finding Intermediate

stakerewardV2pool.withdraw() should check the user’s boost lock status.

The withdraw function in the staking pool does not check whether the user's boost lock period has ended, so a user can stake, set the longest lock for the highest boost, and then immediately withdraw all funds while still earning boosted rewards. This lets them collect extra rewards without keeping funds locked as intended.

KupiaSec Follow with Toshii, LaScaloneta and 10 others

Originally disclosed on Code4rena

Submitted by KupiaSec, also found by Toshii, LaScaloneta, DedOhWale, 0xRobocop, Kenshin, KupiaSec, Inspecktor, 0xkazim, ke1caM, Hama, yudan, and Co0nan

Users can withdraw their staking token immediately after charging more rewards using boost.

Proof of Concept

withdraw() should prevent withdrawals during the boost lock, but there is no such logic.

The below steps show how users can charge more rewards without locking their funds.

  1. Alice stakes their funds using stake().
  2. They set the longest lock duration to get the highest boost using setLockStatus().
  3. After that, when they want to withdraw their staking funds, they call withdraw().
    function withdraw(uint256 _amount) external updateReward(msg.sender) {
        require(_amount > 0, "amount = 0");
        balanceOf[msg.sender] -= _amount;
        totalSupply -= _amount;
        stakingToken.transfer(msg.sender, _amount);
        emit WithdrawToken(msg.sender, _amount, block.timestamp);
    }
  1. Then, the highest boost factor will be applied to their rewards in earned() and they can withdraw all of their staking funds and rewards immediately without checking any lock duration.
    // Calculates and returns the earned rewards for a user
    function earned(address _account) public view returns (uint256) {
        return ((balanceOf[_account] * getBoost(_account) * (rewardPerToken() - userRewardPerTokenPaid[_account])) / 1e38) + rewards[_account];
    }

Tools Used

Manual Review

Recommended Mitigation Steps

withdraw() should check the boost lock like this:

    function withdraw(uint256 _amount) external updateReward(msg.sender) {
        require(block.timestamp >= esLBRBoost.getUnlockTime(msg.sender), "Your lock-in period has not ended.");

        require(_amount > 0, "amount = 0");
        balanceOf[msg.sender] -= _amount;
        totalSupply -= _amount;
        stakingToken.transfer(msg.sender, _amount);
        emit WithdrawToken(msg.sender, _amount, block.timestamp);
    }

Assessed type

Invalid Validation

LybraFinance acknowledged

0xean (judge) decreased severity to Medium


The original report as published on Code4rena, by KupiaSec. 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 withdraw function lacks a check that the caller's boost unlock time has passed, so the lock status is ignored during withdrawal.

Impact

A user could earn boosted rewards while withdrawing their stake immediately, undermining the lock mechanism and potentially draining reward funds.

What the attacker needed

A staking position in the pool; ability to set a boost lock

The fix

The withdraw function should require that the current time is at or past the user's boost unlock time before allowing withdrawal.

How it was found

  1. Alice stakes her funds using stake().
  2. She sets the longest lock duration to get the highest boost using setLockStatus().
  3. She calls withdraw() to remove her staking funds.
  4. The highest boost factor is still applied to her rewards in earned(), so she receives boosted rewards without staying locked.

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 staking system, users can lock their tokens for a longer time to earn a higher reward rate (a 'boost'). The withdraw function should prevent taking tokens out while that lock is active, but it does not check the lock at all. So someone can lock for the maximum time to get the biggest boost, then withdraw straight away and still receive rewards as if they had stayed locked.

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 KupiaSec

View all

28 more disclosed reports, best first.

More from Lybra Finance

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.