LP unwrap / wrap is fully broken if master chef contract has insufficient reward token and block decollateralize wlp and wlp liquidation
The LP wrapper contract's unwrap function calls an external master chef contract that transfers pending reward tokens; if the master chef lacks sufficient reward tokens, the transfer reverts, blocking unwrap, decollateralisation, and liquidation. An attacker could exploit this by draining or causing a shortage of reward tokens in the master chef, preventing users from withdrawing their LP tokens or liquidating positions.
ladboy233 Follow with rvierdiiev
Originally disclosed on Code4rena
Submitted by ladboy233, also found by rvierdiiev
LP unwrap / wrap is fully broken if master chef contract has insufficient reward token.
Proof of Concept
We need to take a look at the external master chef contract that is not in the control of the init capital protocol team.
When deposit / withdraw / harvest / claim, this function _modify is called, which is this code
if (moeReward > 0) _moe.safeTransfer(account, moeReward);
if (address(extraRewarder) != address(0)) {
extraRewarder.onModify(account, pid, oldBalance, newBalance, oldTotalSupply);
}
As we can see, when deposit / withdraw / harvest, the pending reward is transferred from master chef contract to msg.sender (which is the lp wrapper contract).
When calling extraRewarder.onModify, the reward is transferred from extra rewarder to wrapper contract.
But someone needs to transfer the moe token into the master chef to ensure there is sufficient reward token balance.
Someone needs to transfer the reward token into extraReward contract to ensure there is sufficient reward token balance.
In case when there are insufficient reward token in master chef contract and extraReward, the code will revert:
if (moeReward > 0) _moe.safeTransfer(account, moeReward);
if (address(extraRewarder) != address(0)) {
extraRewarder.onModify(account, pid, oldBalance, newBalance, oldTotalSupply);
}
Suppose the reward accounting update is that the wlp contract is entitled to get 10000 moe token and 100 usdc token as extra reward, but in master chef there are only 9000 token, attempting to transfer the 10000 more tokens will revert.
The impact is severe because this revert would block lp unwrap and block original lp owner attemps to decollateralize wlp and make liquidation revert as well.
Recommended Mitigation Steps
When regular withdraw failed, the code should call emergencyWithdraw.
This function does not claim reward, but at least this function can ensure withdraw wlp when decollateralize lp or liquidation transaction does not revert.
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 wrapper's unwrap function does not handle the case where the external master chef contract has insufficient reward token balance, causing the entire transaction to revert.
What the attacker needed
Master chef has insufficient reward tokens
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 that wraps LP tokens relies on an external 'master chef' contract to pay out rewards when users unwrap. If that external contract runs out of reward tokens, the unwrap fails, and users cannot get their tokens back or liquidate their positions. This is like a bank that cannot process withdrawals because it has run out of cash.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.