In _liquidateNormalMode(), WAsset rewards for collToRedistribute will accrue to Yeti Finance Treasury, However, if a borrower wrap WJLP and set _rewardOwner to other address, _updateWAssetsRewardOwner() will fail due to failure of IWAsset(token).updateReward().
function wrap(uint _amount, address _from, address _to, address _rewardOwner) external override {
JLP.transferFrom(_from, address(this), _amount);
JLP.approve(address(_MasterChefJoe), _amount);
// stake LP tokens in Trader Joe's.
// In process of depositing, all this contract's
// accumulated JOE rewards are sent into this contract
_MasterChefJoe.deposit(_poolPid, _amount);
// update user reward tracking
_userUpdate(_rewardOwner, _amount, true);
_mint(_to, _amount);
}
PoC
Alice wrap() some JLP to WJLP and set _rewardOwner to another address;
Alice deposited WJLP as a collateral asset and borrowed the max amount of YUSD;
When the liquidator tries to call batchLiquidateTroves() when Alice defaulted, the transaction will fail.
Recommendation
Consider checking if the user have sufficient reward amount to the balance of collateral in BorrowerOperations.sol#_transferCollateralsIntoActivePool().
Duplicate #136 and is more specific about the exact error. For issue 136, had to extrapolate to find the real error there, and this issue is a better description.
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/TroveManagerLiquidations.sol#L409-L409
In
_liquidateNormalMode()
, WAsset rewards for collToRedistribute will accrue to Yeti Finance Treasury, However, if a borrower wrapWJLP
and set_rewardOwner
to other address,_updateWAssetsRewardOwner()
will fail due to failure ofIWAsset(token).updateReward()
.https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/AssetWrappers/WJLP/WJLP.sol#L126-L138
PoC
wrap()
someJLP
toWJLP
and set_rewardOwner
to another address;WJLP
as a collateral asset and borrowed the max amount of YUSD;batchLiquidateTroves()
when Alice defaulted, the transaction will fail.Recommendation
Consider checking if the user have sufficient reward amount to the balance of collateral in
BorrowerOperations.sol#_transferCollateralsIntoActivePool()
.