Skip to content
Business logic Audit finding Intermediate

ExecuteRewardDistributionYeet will count user withdraws as rewards

The reward calculation subtracts totalSupply from the contract's token balance, but pending unstake amounts stay in the contract while totalSupply is reduced, so those pending withdrawals are counted as rewards. An attacker or manager-triggered distribution could swap user withdrawal funds as rewards, leaving the contract insolvent.

Pyro Follow

Originally disclosed on Immunefi

Critical View original
  • Disclosed after under an hour

#41456 [SC-Critical] `executeRewardDistributionYeet` will count user withdraws as rewards

Submitted on Mar 15th 2025 at 13:46:21 UTC by @Pyro for Audit Comp | Yeet

Description

Brief/Intro

executeRewardDistributionYeet will count user withdraws as rewards due to the way we calculate the rewards inside accumulatedDeptRewardsYeet

Vulnerability Details

accumulatedDeptRewardsYeet calculates the rewards generated by removing totalSupply from stakingToken.balanceOf(address(this))

Solidity
    function accumulatedDeptRewardsYeet() public view returns (uint256) {
        return stakingToken.balanceOf(address(this)) - totalSupply;
    }

Where that difference is used inside executeRewardDistributionYeet as generated rewards, which are swapped for vault shares.

Solidity
    function executeRewardDistributionYeet( ... ) external onlyManager nonReentrant {
    
        uint256 accRevToken0 = accumulatedDeptRewardsYeet();
        require(accRevToken0 > 0, "No rewards to distribute");
        require(swap.inputAmount <= accRevToken0, "Insufficient rewards to distribute");

        stakingToken.approve(address(zapper), accRevToken0);
        IERC20 token0 = IKodiakVaultV1(stakingParams.kodiakVault).token0();
        IERC20 token1 = IKodiakVaultV1(stakingParams.kodiakVault).token1();

        uint256 vaultSharesMinted;
        require(
            address(token0) == address(stakingToken) || address(token1) == address(stakingToken),
            "Neither token0 nor token1 match staking token"
        );

However accumulatedDeptRewardsYeet forgets to consider the fact that startUnstake keeps the staking tokens inside the contract, but lowers totalSupply by unStakeAmount as it sets that amount for a vest.

Solidity
    function startUnstake(uint256 unStakeAmount) external {
        // ...
        balanceOf[msg.sender] -= unStakeAmount;
        totalSupply -= unStakeAmount;

        // ...
    }

In short all user withdraws will be counted by the contract as rewards, meaning that if swapped these withdraws will not be refundable, or even worse - they would be taken from the users that didn't appoint a withdraw, making the contract insolvent.

Impact Details

Contract is insolvent due to it counting all pending withdraws as rewards and swapping them in a different token.

References

none are needed

Proof of Concept

Proof of Concept

  1. 10 users deposit, each with 100 tokens
  2. 1 schedules a withdraw for 100 tokens
  3. Admin distributes rewards (these 100 tokens are counted towards the rewards)
  4. User withdraws his 100 tokens

step 3 and 4 both costed 100 tokens, meaning the contract has 800 actual tokens and 900 deposited balances, making it insolvent.

The original report as published on Immunefi, by Pyro. 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 reward calculation uses the raw token balance minus totalSupply without excluding tokens reserved for pending unstakes.

Impact

The contract becomes insolvent because pending withdrawals are swapped out as rewards, so users may be unable to withdraw their funds.

What the attacker needed

Manager calls reward distribution; at least one pending unstake

The fix

The reward calculation should exclude tokens reserved for pending unstakes, for example by tracking a separate reserved balance rather than using the raw token balance minus totalSupply.

How it was found

  1. Ten users each deposit 100 tokens.
  2. One user schedules a withdrawal of 100 tokens.
  3. The admin distributes rewards, counting those 100 tokens as rewards.
  4. The user withdraws their 100 tokens.

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.

The contract tracks how many tokens users have deposited, and it also holds the actual tokens. It works out 'rewards' by comparing the real token balance with the tracked deposits. When a user starts a withdrawal, the tracked amount drops but the real tokens stay put, so the gap looks like free reward money. That gap is then swapped away, leaving too few tokens to pay everyone back.

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 Pyro

View all

6 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.