MuteAmplifier.rescueTokens() checks the wrong condition for muteToken
The rescueTokens function in MuteAmplifier incorrectly checks the balance condition for the muteToken, allowing rewards to be withdrawn before staking starts and leaving some rewards locked forever. An attacker could withdraw rewards early, breaking the reward system, or cause rewards to be permanently locked.
hansfriese Follow with evan
Originally disclosed on Code4rena
Submitted by hansfriese, also found by evan
There will be 2 impacts.
- The reward system would be broken as the rewards can be withdrawn before starting staking.
- Some rewards would be locked inside the contract forever as it doesn’t check
totalReclaimed
Proof of Concept
rescueTokens() checks the below condition to rescue muteToken.
else if (tokenToRescue == muteToken) {
if (totalStakers > 0) {
require(amount <= IERC20(muteToken).balanceOf(address(this)).sub(totalRewards.sub(totalClaimedRewards)),
"MuteAmplifier::rescueTokens: that muteToken belongs to stakers"
);
}
}
But there are 2 problems.
- Currently, it doesn’t check anything when
totalStakers == 0. So some parts(or 100%) of rewards can be withdrawn before the staking period. In this case, the reward system won’t work properly due to the lack of rewards. - It checks the wrong condition when
totalStakers > 0as well. As we can see here, some remaining rewards are tracked usingtotalReclaimedand transferred to treasury directly. So we should consider this amount as well.
Recommended Mitigation Steps
It should be modified like the below.
else if (tokenToRescue == muteToken) {
if (totalStakers > 0) { //should check totalReclaimed as well
require(amount <= IERC20(muteToken).balanceOf(address(this)).sub(totalRewards.sub(totalClaimedRewards).sub(totalReclaimed)),
"MuteAmplifier::rescueTokens: that muteToken belongs to stakers"
);
}
else if(block.timestamp <= endTime) { //no stakers but staking is still active, should maintain totalRewards
require(amount <= IERC20(muteToken).balanceOf(address(this)).sub(totalRewards),
"MuteAmplifier::rescueTokens: that muteToken belongs to stakers"
);
}
}
mattt21 (Mute Switch) confirmed
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 rescueTokens function fails to check totalReclaimed and does not restrict withdrawals when totalStakers is zero but staking is still active.
Impact
Rewards could be withdrawn before staking starts, breaking the reward system, and some rewards may be locked forever.
What the attacker needed
None
The fix
The rescueTokens function should also subtract totalReclaimed and add a check for when totalStakers is zero but staking is still active.
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 bug where a function that lets the owner rescue tokens checks the wrong condition. Because of that, tokens meant for rewards can be taken out too early or get stuck in the contract forever.
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.