Setting new controller can break YVaultLPFarming
The farming contract's reward accrual subtracts a stored previous balance from the current balance, and if the vault's controller is changed so that the reported balance drops, the subtraction underflows and reverts. Because withdrawals call the same update first, users can no longer withdraw their funds.
Submitted by cmichel
yVaultLPFarming.sol#L170 yVault.sol#L108
The accruals in yVaultLPFarming will fail if currentBalance < previousBalance in _computeUpdate.
currentBalance = vault.balanceOfJPEG() + jpeg.balanceOf(address(this));
uint256 newRewards = currentBalance - previousBalance;
No funds can be withdrawn anymore as the withdraw functions first trigger an _update.
The currentBalance < previousBalance case can, for example, be triggerd by decreasing the vault.balanceOfJPEG() due to calling yVault.setController:
function setController(address _controller) public onlyOwner {
// @audit can reduce balanceofJpeg which breaks other masterchef contract
require(_controller != address(0), "INVALID_CONTROLLER");
controller = IController(_controller);
}
function balanceOfJPEG() external view returns (uint256) {
// @audit new controller could return a smaller balance
return controller.balanceOfJPEG(address(token));
}
Recommended Mitigation Steps
Setting a new controller on a vault must be done very carefully and requires a migration.
This is not a duplicate of H-05. Though both of them deal with issues related to balanceOfJPEG, they describe different causes.
spaghettieth (JPEG’d) acknowledged
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
What the attacker needed
Vault owner changes the controller; new controller reports lower balance
The fix
Changing a vault's controller should be done carefully and requires a migration so the farming contract's stored balance stays consistent.
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 vault reports how much it holds, and a farming contract remembers that number to work out new rewards. If an admin swaps the vault's controller and the new one reports a smaller balance, the farming contract tries to subtract a bigger number from a smaller one. That calculation fails, and since withdrawing also runs it first, nobody can take their money out.
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.