Skip to content
Business logic Audit finding Intermediate

Incomplete token return whena user claim his rewards leads to rewards fund loss

When a user claims rewards through the Zapper's token0 or token1 claim functions, leftover tokens that were not swapped are sent back to the StakeV2 contract instead of the user. This means the user receives only part of their rewards, and the remainder is absorbed into the pool's general rewards for all stakers.

Le_Rems Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42732 [SC-High] Incomplete token return whena user claim his rewards leads to rewards fund loss

Submitted on Mar 25th 2025 at 13:54:49 UTC by @Le_Rems for Audit Comp | Yeet

Description

Description

If users claim rewards using claimRewardsInToken0 or claimRewardsInToken1, the Zapper contract may return unused tokens to the StakeV2 contract instead of to the user who initiated the claim.

The root cause is in the Zapper contract's token handling logic. When redeeming vault shares, the Zapper receives both token0 and token1. It then swaps a portion of one token for the other based on parameters provided by the user. However, any remaining tokens that aren't swapped are sent back to the calling contract (StakeV2) rather than to the user who initiated the claim.

This behavior is highly likely, as market conditions will change between the time the user calculates the swap inputs off-chain and when the transaction is executed.

This results in users receiving only part of their earned rewards, with the remainder being trapped in the StakeV2 contract where they effectively become part of the pool's general rewards, benefiting all stakers rather than the specific user who earned them.

Recommendations

Approach 1: Modify Zapper to send all tokens to the receiver

Update the zapOutToToken0 and zapOutToToken1 functions in the Zapper contract to send all tokens to the specified receiver rather than sending some back to the caller:

Solidity
// In Zapper::zapOutToToken0
function zapOutToToken0(
    address receiver,
    SingleTokenSwap calldata swapData,
    KodiakVaultUnstakingParams calldata unstakeParams,
    VaultRedeemParams calldata redeemParams
) public nonReentrant onlyWhitelistedKodiakVaults(unstakeParams.kodiakVault) returns (uint256 totalToken0Out) {
    (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));
    
    // Send all tokens to the receiver instead of sending token0 back to _msgSender()
    _sendERC20Token(token0, receiver, token0Debt);
    _sendERC20Token(token1, receiver, token1Debt);
    return (token1Debt);
}

Proof of Concept

Proof of Concept

  1. A user has earned rewards and calls StakeV2::claimRewardsInToken0 to claim them
  2. StakeV2 calls Zapper::zapOutToToken0 which:
    • Redeems vault shares, receiving both token0 and token1
    • Swaps a portion of token1 for token0 based on the swapData parameter
    • Sends token0 to the user (receiver)
    • Sends any remaining token1 back to StakeV2 (the _msgSender())
  3. The relevant code in Zapper::zapOutToToken0:
Solidity
token0Debt -= swapData.inputAmount;
token1Debt += _verifyTokenAndSwap(swapData, address(token0), address(token1), address(this));
// @audit-issue token remainder will be sent back to StakerV2 --> inflating other users shares and not sending them back to the legitmate user
_sendERC20Token(token0, _msgSender(), token0Debt);
_sendERC20Token(token1, receiver, token1Debt);
  1. The issue is that token0Debt (remaining token0) is sent to _msgSender() (the StakeV2 contract) instead of to the user who initiated the claim.
  2. These tokens become "stuck" in the StakeV2 contract and are counted as part of accumulatedDeptRewardsYeet(), which distributes them to all stakers rather than returning them to the original user.

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

Root cause

The Zapper's zap-out functions send the unswapped token remainder to the caller (StakeV2) instead of to the receiver address passed in by the user.

Impact

Users could receive only part of their earned rewards, with the remainder effectively redistributed to all stakers, causing a loss of unclaimed yield.

What the attacker needed

User has claimable rewards; swap inputs become stale before execution

The fix

The Zapper's zap-out functions should send all tokens to the specified receiver rather than returning some to the caller.

How it was found

  1. A user calls claimRewardsInToken0 on StakeV2 to claim earned rewards
  2. StakeV2 calls zapOutToToken0 on the Zapper, which redeems vault shares into both tokens
  3. The Zapper swaps part of one token for the other using the user-supplied swap data
  4. The Zapper sends the swapped token to the user but sends the unswapped remainder back to StakeV2
  5. The leftover tokens are counted in the pool's accumulated rewards and shared among all stakers

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.

A user earns rewards and asks the contract to pay them out in a particular token. The helper contract that does the conversion keeps some of the tokens and sends them to the main staking contract rather than to the user. So the user gets less than they earned, and the leftover is shared among everyone who stakes.

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 Le_Rems

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.