Open code423n4 opened 2 years ago
@denett withholdRatio is is not an iron rule and can be updated by the owner at will. recoverEther will likely only be used when we are migrating to a new minting contract, so the accounting in that case is no longer important.
Lines of code
https://github.com/code-423n4/2022-09-frax/blob/55ea6b1ef3857a277e2f47d42029bc0f3d6f9173/src/frxETHMinter.sol#L191-L196
Vulnerability details
The emergency exit function
recoverEther
allows the owner to retrieve the ETH in case an issue were to happen.The problem is that this function does not update
currentWithheldETH
.This means upon deposit starting again after the emergency recovery,
currentWithheldETH
will have an offset and will not match thewithholdRatio
.Direct consequences:
depositEther
may not deposit the expected amount of ETH into the ETH 2.0 staking contract.moveWithheldETH()
will be higher than what it should be.Impact
Medium
Proof Of Concept
withholdRatio
set to2 * 1e5
- ie the contract is meant to hold20%
of the ETH deposited.recoverEther(address(this).balance)
. Before the call, the total balance was1e20
(100 ETH), andcurrentWithheldETH == 2 * 1e19
- for simplicity we assume no calls tomoveWithheldETH
ordepositEther
have been done yet.0
, butcurrentWithheldETH
is still2 * 1e19
1e20
(100 ETH), andcurrentWithheldETH == 4 * e19
depositEther
deposits32 ether
instead of64 ether
, becausecurrentWithheldETH == 40 ether
instead of20 ether
. The owner can also callmoveWithheldETH
withamount == 4 * 1e19
instead ofamount == 2 * 1e19
.You can add the following foundry test in
frxETHMinter.t.sol
to reproduce the issue:address Alice = address(1);
before thesetUp()
Tools Used
Manual Analysis, Foundry
Mitigation
Update
currentWithheldETH
inrecoverEther
: