Skip to content
Business logic Audit finding Intermediate

When calling StakeV2::claimRewardsInNative() surplus $YEET are send to the StakeV2 contract instead of the user

When a user claims rewards in native tokens via StakeV2::claimRewardsInNative, surplus YEET tokens left after the swap are sent to the StakeV2 contract instead of the user. This causes the user to lose those surplus tokens.

BenR Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42039 [SC-High] When calling `StakeV2::claimRewardsInNative()` surplus $YEET are send to the StakeV2 contract instead of the user

Submitted on Mar 20th 2025 at 08:26:24 UTC by @BenR for Audit Comp | Yeet

Description

Brief/Intro

When a user calls StakeV2::claimRewardsInNative to claim his rewards in $BERA tokens, surplus $YEET tokens are send to the StakeV2 contract instead of the user. This results in a loss of the surplus tokens for the user.

Vulnerability Details

When staking $YEET in the StakeV2 contract, users are earning rewards in form of vault shares from the Trifecta vault. If a user wants to claim his rewards in $BERA tokens he calls StakeV2::claimRewardsInNative(). The function checks if the user has earned the provided amount of shares and calls Zapper:: zapOutNative(). This function

  • withdraws the provided amount of share amount from the Trifecta vault
  • unstakes the received LP tokens from the $YEET/$WBERA KodiakVault and receives the corresponding $YEET and $WBERA tokens
  • swaps the $YEET tokens to $WBERA tokens based on swap parameters provided by the user
  • unwraps the $WBERA to $BERA and sends it to the user
  • transfers any surplus $YEET tokens not consumed by the swap using the _clearUserDebt function
Solidity
_clearUserDebt(token0, token1, token0Debt, token1Debt, _msgSender());

The issue arises from the fact that the receiver of the surplus $YEET tokens is set to _msgSender() which is the StakeV2 contract and not the user.

Impact Details

Because the surplus $YEET tokens are send to _msgSender() which is the StakeV2 contract, their value is lost for the user.

References

https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/contracts/Zapper.sol#L622

Proof of Concept

POC (step by step)

  • user want to claim his rewards in BERA and calls StakeV2::claimRewardsInNative with the amount of 100 shares
  • the 100 shares are withdrawn from the TrifectaVault returning 100 LP tokens of the $YEET/$WBERA KodiakVault
  • the 100 LP tokens are unstaked from the $YEET/$WBERA KodiakVault and the Zapper contract receives 500$WBERA and 500,000 $YEET
  • based on the parameters provided by the user 400,000 $YEET are swapped to 400 $WBERA
  • all 900 $WBERA are unwrapped to $BERA and send to the user
  • the surplus 100.000 $YEET are send to the StakingV2 contract instead of the user resulting in a loss of 100.000 $YEET for the user

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

Likely the surplus token transfer uses the immediate caller (the StakeV2 contract) as the receiver instead of the original user.

Impact

The user loses the surplus YEET tokens, which are sent to the StakeV2 contract instead.

What the attacker needed

User has staking rewards; user calls claimRewardsInNative

How it was found

  1. User calls StakeV2::claimRewardsInNative with an amount of shares.
  2. The shares are withdrawn from the TrifectaVault, returning LP tokens.
  3. The LP tokens are unstaked, yielding YEET and WBERA tokens.
  4. Part of the YEET is swapped to WBERA based on user parameters.
  5. All WBERA is unwrapped to BERA and sent to the user.
  6. Surplus YEET is sent to the StakeV2 contract instead of 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.

A user can earn rewards and choose to receive them as the native coin. The code that converts the reward tokens into the native coin sometimes has leftover tokens. Those leftovers are sent to the wrong address, so the user does not get them.

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 BenR

View all

1 more disclosed report, 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.