Submitted by 0xBinChook, also found by debo, pep7siup, DemoreX, Greed, alix40, and Chad0
When EbtcLeverageZapRouter::openCdpWithEth and EbtcLeverageZapRouter::adjustCdpWithEth stake ETH with Lido, the underlying function performing the call assumes that any exceptions (from Lido) will be bubbled up, but with call being a low level rather than a Solidity function, it is not the case.
Lido stETH has two cases where a revert on depositing ETH for staking may be encountered, when deposits are paused or when staking limits are enabled and it is exceeded.
If Lido returns a revert it is ignored and the entire CDP flow continues (permits, flash loans, account synching, CDP initialization, eBTC minting), with a revert only being cause only by one of the last step of the flow, moving the collateral to the active pool.
The two parts to the issue:
1. Lido deposit could revert:
Lido has pausable staking on Ethereum stETH
Lido can impose a per block stake limit on Ethereum stETH
Both these cause the same effect; a possible revert during the submit of ETH for staking with Ethereum stETH:
2. Incorrect assumption that revert would bubble:
EbtcLeverageZapRouter and EbtcZapRouter both use the same ancestor function to stake ETH with Lido,
that performs the call operation on a address in ZapRouterBase::_depositRawEthIntoLido
As outlined in Solidity by Example - call
EbtcZapRouter does check the collateral balance in the function that follows the staking of ETH with Lido in EbtcZapRouter::_openCdpWithPermit()
EbtcLeverageZapRouter performs no similar checks on the collateral balance after the staking, rather failing on a ERC20 transfer after another ~320K gas of other operations.
Adds a pause to the CollateralTokenTester and demonstrates the non-propagation of the initial revert, instead relying on the later ERC20 revert.
The CollateralTokenTester mocks Lido stETH, add the following to the version used by the ebtc-zap-router tests (should be at /lib/ebtc/packages/contracts/TestContracts/CollateralTokenTester.sol):
Add to LeverageZaps:
Run with forge test --match-contract LeverageZaps --match-test test_ZapOpenCdp_WithEth_LidoRReverts.
Foundry
Use submit instead, as that will propagate any revert.
In ZapRouterBase::\_depositRawEthIntoLido():
The msg.sender could also be included for the referral, as that will be included by Lido their emitted event.
GalloDaSballo (Badger) confirmed and commented:
0xsomeone (judge) increased severity to High and commented:
Slavcheww (warden) commented:
0xsomeone (judge) commented:
Slavcheww (warden) commented:
0xsomeone (judge) decreased severity to Medium and commented:
GalloDaSballo (Badger) commented:
For this audit, 2 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by Rhaydden received the top score from the judge.
The following wardens also submitted reports: jesjupyter.
