MasterChef.sol A depositor can deposit an arbitrary amount without no cost
The MasterChef contract allows the owner to add a depositor who can call deposit with an arbitrary amount without transferring any tokens. A malicious or compromised depositor could take nearly all shares and rewards from every pool.
Submitted by WatchPug, also found by cmichel
The owner of MasterChef.sol can add a depositor with addDepositor().
function addDepositor(address _depositor) external onlyOwner {
isDepositor[_depositor] = true;
}
A depositor can deposit with an arbitrary amount, without any cost.
function deposit(address _recipient, uint _pid, uint _amount) external nonReentrant onlyDepositor {
PoolInfo storage pool = poolInfo[_pid];
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);
}
}
if (_amount > 0) {
if (pool.depositFeeBP > 0) {
uint depositFee = _amount.mul(pool.depositFeeBP).div(_perMille);
user.amount = SafeCast.toUint128(user.amount + _amount - depositFee);
} else {
user.amount = SafeCast.toUint128(user.amount + _amount);
}
}
user.rewardDebt = SafeCast.toUint128(user.amount * pool.accConcurPerShare / _concurShareMultiplier);
emit Deposit(_recipient, _pid, _amount);
}
This allows a malicious/compromised depositor to take the majority share (nearly 100%) of all pools simply by calling deposit() with extremely large amounts, and take all the rewards.
Recommended Mitigation Steps
See the Recommendation section on issue #200 and remove the depositor role.
ryuheimat (Concur) disputed and commented:
This function will be called by whitelisted depositor contract and the actual token transfer will be done there.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
Because the’re a mapping that allows any contract to be set as depositor, I believe the warden has shown a potential admin privilege that can cause issues with the fair distribution of rewards.
Because this is contingent on a malicious admin, I believe Medium Severity to be more appropriate.
Mitigation would be as simple as having one depositor, alternative a more complicated architecture may need to be used.
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 deposit function updates the user's balance without checking that the corresponding tokens were actually transferred, and the depositor role is not restricted to a trusted contract that performs the transfer.
Impact
A malicious or compromised depositor could take the majority share of all pools and all rewards, though the project says the role is meant for a whitelisted contract that performs the real token transfer.
What the attacker needed
Owner adds a malicious depositor; depositor calls deposit with large amount
The fix
The depositor role should be removed or limited to a single trusted contract that actually transfers tokens, as the judge suggested.
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 smart contract lets a special user (a depositor) add fake deposits without actually paying tokens. Because rewards are based on how much you deposited, that user could claim almost all rewards. The contract owner controls who becomes a depositor, so the risk depends on trusting that owner.
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.