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.
Submitted by WatchPug, also found by hickuphh3 and leastwood
According to:
- README
- Implementation of
deposit(): /contracts/MasterChef.sol#L157-L180
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.
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
Concurrewards from MasterChef;
Recommended Mitigation Steps
Consider creating a receipt token to represent the invested token and use the receipt tokens in MasterChef.
Alex the Entreprenerd (judge) commented:
The warden has identified a logical flaw in the
Masterchefcontract.The contract is expecting
lpTokens(deposited in another depositor contract) to be in theMasterchefat the time in whichupdatePoolis called.However, due to the fact that the
lpTokenwill 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.
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.