Skip to content
Business logic Audit finding Intermediate

ConvexStakingWrapper , StakingRewards Wrong implementation will send concur rewards to the wrong receiver

The ConvexStakingWrapper and StakingRewards contracts call MasterChef's deposit and withdraw functions, which use the caller's address as the user. As a result, all users' staked balances are recorded under the wrapper contract, and reward payouts go to whoever triggers the deposit or withdraw, not the actual depositor.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by bobi, CertoraInc, csanuragjain, danb, hickuphh3, and leastwood

ConvexStakingWrapper.sol#L246 StakingRewards.sol#L99 MasterChef.sol#L159-L167

UserInfo storage user = userInfo[_pid][_msgSender()];
updatePool(_pid);

if(user.amount > 0) {
    uint pending = user.amount * pool.accConcurPerShare / _concurShareMultiplier - user.rewardDebt;
    if (pending > 0) {
        safeConcurTransfer(_recipient, pending);
    }
}

ConvexStakingWrapper, StakingRewards is using masterChef.deposit(), masterChef.withdraw(), and these two functions on masterChef will take _msgSender() as the user address, which is actually the address of ConvexStakingWrapper and StakingRewards.

As a result, when calling ConvexStakingWrapper.deposit(), ConvexStakingWrapper.withdraw(), StakingRewards.stake(), StakingRewards.withdraw(), the concur rewards belongs to all the users of ConvexStakingWrapper / StakingRewards will be sent to the caller wrongfully.

Proof of Concept

  1. Alice deposits 1,000,000 token to pid 1

Actual results on masterChef:

  • userInfo[1][address(ConvexStakingWrapper)] = 1,000,000

Expected results:

  • userInfo[1][address(Alice)] = 1,000,000
  • 1 day later, Bob deposits 1 token to pid 1

Actual results on masterChef:

  • userInfo[1][address(ConvexStakingWrapper)] = 1,000,001
  • all pending rewards sent to Bob

Expected results:

  • userInfo[1][address(Alice)] = 1,000,000
  • userInfo[1][address(Bob)] = 1
  • all pending rewards should be sent to Alice

Recommended Mitigation Steps

Consider adding two new functions to MasterChef: depositFor() and withdrawFor().

ConvexStakingWrapper, StakingRewards can utilize these two functions and get the accounting right.

function depositFor(address _user, uint _pid, uint _amount) external nonReentrant onlyDepositor {
    PoolInfo storage pool = poolInfo[_pid];
    UserInfo storage user = userInfo[_pid][_user];

ryuheimat (Concur) confirmed


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

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 MasterChef contract uses the caller's address as the user identifier, but the wrapper contracts call it on behalf of many users, so individual ownership is lost.

Impact

Any user who calls deposit or withdraw can receive the accumulated rewards that belong to all other users of the wrapper, causing loss of funds for the rightful stakers.

What the attacker needed

Users stake through the wrapper; attacker calls deposit or withdraw

The fix

The report recommends adding depositFor and withdrawFor functions to MasterChef so the wrapper can specify the actual user, and updating the wrapper contracts to use them.

How it was found

  1. Alice deposits 1,000,000 tokens to pid 1 via the wrapper.
  2. MasterChef records the deposit under the wrapper's address, not Alice's.
  3. A day later, Bob deposits 1 token to the same pid.
  4. All pending rewards are sent to Bob instead of Alice.

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 stake tokens through a shared contract, the system should remember that you, not the shared contract, own your stake. Here, the shared contract was recorded as the owner of everyone's tokens, so when rewards were paid, they went to whoever happened to call the function last, not to the person who actually deposited.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Concur Finance contest

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.