Unused debt is not send to Reward Claimer
When a user claims rewards and the Zapper converts them into a chosen token, any leftover tokens from the swap are returned to the StakeV2 contract rather than forwarded to the user. The user therefore loses the unused portion of their reward, which stays stuck in the contract.
- Disclosed after under an hour
#41907 [SC-High] Unused debt is not send to Reward Claimer
Submitted on Mar 19th 2025 at 10:03:41 UTC by @Oxgritty for Audit Comp | Yeet
- Report ID: #41907
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/StakeV2.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
- When a user calls claimRewards(claimRewardsInNative/ claimRewardsInToken0/ claimRewardsInToken1/ claimRewardsInToken) function, his reward is converted into his choice of token, during this swapping the amount of token which was not used will be send to StakeV2.sol instead of the user.
Vulnerability Details
- When a user calls one of these functions(claimRewardsInNative/ claimRewardsInToken0/ claimRewardsInToken1/ claimRewardsInToken) to claim rewards and inside these functions we call a relevant zapOut function(like
Zapper::zapOutNativeforStakeV2::claimRewardsInNativeorZapper::zapOutToToken0forStakingV2::claimRewardsInToken0) in Zapper.sol, Zapper.sol pays back the amount of unused debt to StakeV2.sol and StakeV2 does not send it back to the user.
Impact Details
- Reward Claimer loses unused debt, as it is transferred to StakeV2.sol
References
This issue is present in all 4 claimRewards function:
- claimRewardsInNative
After callingZapper::zapInNative, we should send unused debt back to the user, but we are not doing it.
- Same problem with these other 3 functions as well
- claimRewardsInToken0
- claimRewardsInToken1
- claimRewardsInToken
Proof of Concept
Proof of Concept
Step 0: Assumptions we are making
- Bob has rewards of 50e18 vaultShares that he wants to claim in Native Token(BERA) using
StakeV2::claimRewardsInNative zapOutNativewill turn 50e18 worth of vaultShares into the following Balances- 45e18 (BERA)
- 2e18 (Token0)
- 3e18 (Token1)
Step 1: Calling StakeV2::claimRewardsInNative
- Bob calls
StakeV2::claimRewardsInNativewithamountToWithdraw=50e18and function is successfully executed.
Step 2: Checking Balances:
- For StakeV2
- Token0.balanceOf(address(StakeV2)) = 2e18
- Token1.balanceOf(address(StakeV2)) = 3e18
- BERA.balanceOf(address(StakeV2)) = 0
- For Bob
- Token0.balanceOf(address(Bob)) = 0
- Token1.balanceOf(address(Bob)) = 0
- BERA.balanceOf(address(Bob)) = 45e18
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 claimRewards functions call the Zapper swap helpers but never forward the leftover tokens returned to StakeV2 on to the user.
Impact
The reward claimer loses the unused portion of their reward, which is transferred to and stuck in the StakeV2 contract.
What the attacker needed
User has claimable rewards; user claims in a converted token
How it was found
- Bob calls claimRewardsInNative with an amount of vault shares to withdraw.
- The Zapper converts the shares and returns part of the value as the native token and part as Token0 and Token1.
- Bob receives only the native token portion, while Token0 and Token1 remain in the StakeV2 contract.
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 swap ends up with some leftover tokens, and instead of passing them to the user it leaves them in the main contract. So the user gets less than they should, and the remainder is stranded.
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.