Skip to content
Business logic Audit finding Intermediate

MasterChef.sol Users won’t be able to receive the concur rewards

The MasterChef contract records deposits but does not hold the deposit tokens, so its internal balance check always returns zero. As a result, the reward calculation is skipped and users never receive Concur rewards.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by hickuphh3 and leastwood

According to:

MasterChef is only recording the deposited amount in the states, it’s not actually holding the depositToken.

depositToken won’t be transferred from _msgSender() to the MasterChef contract.

Therefore, in updatePool() L140 lpSupply = pool.depositToken.balanceOf(address(this)) will always be 0. And the updatePool() will be returned at L147.

MasterChef.sol#L135-L154

function updatePool(uint _pid) public {
    PoolInfo storage pool = poolInfo[_pid];
    if (block.number <= pool.lastRewardBlock) {
        return;
    }
    uint lpSupply = pool.depositToken.balanceOf(address(this));
    if (lpSupply == 0 || pool.allocPoint == 0) {
        pool.lastRewardBlock = block.number;
        return;
    }
    if(block.number >= endBlock) {
        pool.lastRewardBlock = block.number;
        return;
    }

    uint multiplier = getMultiplier(pool.lastRewardBlock, block.number);
    uint concurReward = multiplier.mul(concurPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
    pool.accConcurPerShare = pool.accConcurPerShare.add(concurReward.mul(_concurShareMultiplier).div(lpSupply));
    pool.lastRewardBlock = block.number;
}

Impact

  • The MasterChef contract fail to implement the most essential function;
  • Users won’t be able to receive any Concur rewards from MasterChef;

Recommended Mitigation Steps

Consider creating a receipt token to represent the invested token and use the receipt tokens in MasterChef.

See: https://github.com/convex-eth/platform/blob/883ffd4ebcaee12e64d18f75bdfe404bcd900616/contracts/contracts/Booster.sol#L272-L277

ryuheimat (Concur) confirmed

Alex the Entreprenerd (judge) commented:

The warden has identified a logical flaw in the Masterchef contract.

The contract is expecting lpTokens (deposited in another depositor contract) to be in the Masterchef at the time in which updatePool is called.

However, due to the fact that the lpToken will be somewhere else, a more appropriate check would be to ask the depositor contract for the total supply.

Given this finding, the Masterchef contract will always reward 0 tokens.

This should classify the finding as Medium Severity (loss of Yield).

However, because the finding shows how this can happen reliably, and effectively breaks the purpose of the contract, I believe High Severity to be more appropriate.


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

The deposit function does not transfer the deposit tokens to the MasterChef contract, so the contract's balance of those tokens is always zero and the reward calculation is skipped.

Impact

Users cannot receive any Concur rewards from MasterChef, effectively breaking the contract's core purpose.

What the attacker needed

None

The fix

The contract should use a receipt token to represent deposited tokens and base reward calculations on that receipt token's supply, or otherwise track deposited amounts correctly.

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.

This is a smart contract that is supposed to give out rewards to people who deposit tokens. But it never actually takes the tokens into its own account, so when it checks how many tokens it has to calculate rewards, it sees zero and gives up. So nobody ever gets any rewards.

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.