Skip to content
Business logic Audit finding Intermediate

When claiming rewards from StakeV2 left-over debt is sent to StakeV2 instead of the user

When claiming rewards from StakeV2, if the user specifies a swap input amount smaller than the token0 debt, the leftover token0 is sent to the StakeV2 contract instead of the user. This causes a permanent loss of those leftover tokens for the user.

kmm Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42598 [SC-High] When claiming rewards from `StakeV2` left-over debt is sent to `StakeV2` instead of the user

Submitted on Mar 24th 2025 at 22:08:01 UTC by @kmm for Audit Comp | Yeet

Description

Brief/Intro

When claiming rewards from StakeV2, vault tokens are zapped out via the zapper contract. However, if a user specifies a smaller inputAmount for the token swap, any excess tokens are erroneously sent to StakeV2 and become permanently locked.

Vulnerability Details

Users claim their rewards using the following functions:

  • claimRewardsInNative
  • claimRewardsInToken0
  • claimRewardsInToken1
  • claimRewardsInToken

The vulnerability applies to all of them, but we will focus on claimRewardsInToken1:

Solidity
function claimRewardsInToken1(
    uint256 amountToWithdraw,
    IZapper.SingleTokenSwap calldata swapData,
    IZapper.KodiakVaultUnstakingParams calldata unstakeParams,
    IZapper.VaultRedeemParams calldata redeemParams
) external nonReentrant {
    _updateRewards(msg.sender); // Update the rewards

    IZapper.VaultRedeemParams memory updatedRedeemParams = _verifyAndPrepareClaim(amountToWithdraw, redeemParams);

    IERC20(redeemParams.vault).approve(address(zapper), amountToWithdraw);

    uint256 receivedAmount = zapper.zapOutToToken1(msg.sender, swapData, unstakeParams, updatedRedeemParams);

    emit Claimed(msg.sender, receivedAmount);
}

The function validates the withdrawal amount and delegates to the zapper via zapOutToToken1:

Solidity
function zapOutToToken1(
    address receiver,
    SingleTokenSwap calldata swapData,
    KodiakVaultUnstakingParams calldata unstakeParams,
    VaultRedeemParams calldata redeemParams
) public nonReentrant onlyWhitelistedKodiakVaults(unstakeParams.kodiakVault) returns (uint256 totalToken1Out) {
    (IERC20 token0, IERC20 token1, uint256 token0Debt, uint256 token1Debt) = _yeetOut(redeemParams, unstakeParams);
    
    if (token0Debt == 0 && token1Debt == 0) {
        return 0;
    }

    token0Debt -= swapData.inputAmount;
    token1Debt += _verifyTokenAndSwap(swapData, address(token0), address(token1), address(this));

    _sendERC20Token(token0, _msgSender(), token0Debt);
    _sendERC20Token(token1, receiver, token1Debt);

    return token1Debt;
}

Here, _yeetOut returns amounts in token0Debt and token1Debt. The user provides a swap amount (swapData.inputAmount) for converting token0 to token1. Any leftover token0Debt (i.e., token0Debt - inputAmount) is sent to _msgSender(), which is the StakeV2 contract.

This leads to a scenario where if a user intends to convert only part of their token0Debt (e.g., 50%), the remaining 50% is sent to StakeV2 and becomes inaccessible to the user. This results in a permanent partial loss.

Impact Details

Permanent, irrecoverable loss of user funds occurs when the user specifies a swapData.inputAmount smaller than the full token0Debt. The excess token0 is sent to StakeV2 and becomes trapped.

References

Proof of Concept

Proof of Concept

For simplicity assume that the rate of token0/token1 is always 1:1.

  1. User has 5 compounding vault shares that equal (500 token0 and 500 token1).
  2. User call claim claimRewardsInToken1 and passes swapData.inputAmount = 250
  3. 250 token0 is swapped for 250 token1 tokens
  4. 750 token1 tokens are sent out to the user, while 250 token0 tokens are sent to StakeV2, causing a net loss of 250 token0 tokens for the user.

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

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

Impact

The user permanently loses the leftover token0 amount, which becomes trapped in the StakeV2 contract.

What the attacker needed

User claims rewards with partial swap

How it was found

  1. User has 5 compounding vault shares equal to 500 token0 and 500 token1.
  2. User calls claimRewardsInToken1 with swapData.inputAmount = 250.
  3. 250 token0 is swapped for 250 token1.
  4. 750 token1 is sent to the user, while 250 token0 is sent to StakeV2, causing a net loss of 250 token0 for the user.

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.

When you claim rewards, the contract swaps some of your tokens for another type. If you only swap part of your tokens, the rest should go back to you. But here, the rest is sent to the main contract instead, so you lose them forever.

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 kmm

View all

2 more disclosed reports, best first.

More from Yeet

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.