code-423n4 / 2024-04-renzo-findings

12 stars 8 forks source link

Inaccurate WETH and `xezETH` accounting inside `xRenzoBridge::xReceive()` due to absence of try/catch block #371

Closed howlbot-integration[bot] closed 6 months ago

howlbot-integration[bot] commented 6 months ago

Lines of code

https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L1/xRenzoBridge.sol#L175-L193 https://github.com/code-423n4/2024-04-renzo/blob/main/contracts/Bridge/L2/xRenzoDeposit.sol#L434

Vulnerability details

Impact

The xReceive() function inside xRenzoBridge.sol does not follow the official recommendation applicable in case of a revert while making an external call i.e. using a try/catch block while making external calls.
It's important to note the following statement made in the Connext docs:

If the call on the receiver contract (also referred to as "target" contract) reverts, funds sent in with the call will end up on the receiver contract.

It then goes on to say that:

To avoid situations where user funds get stuck on the receivers, developers should build any contract implementing IXReceive defensively. Ultimately, the goal should be to handle any revert-susceptible code and ensure that the logical owner of funds always maintains agency over them.

Hence, when xRenzoDeposit::sweep() makes a xcall to xRenzoBridge::xReceive() with balance, the following happens:

Proof of Concept

Tools Used

Manual review

Recommended Mitigation Steps

As has been officially recommended, enclose these external call inside xRenzoBridge::xReceive() in a try/catch block which logs the failure of the transaction. Also add an admin controlled function which can then be called to retry the deposit & burn steps.

Assessed type

Other

C4-Staff commented 6 months ago

CloudEllie marked the issue as primary issue

jatinj615 commented 6 months ago

The try/catch won't mitigate anything. WETH will be present in the xRenzoBridgeContract and the xReceive can be triggered again through connext.

c4-judge commented 6 months ago

alcueca marked issue #373 as primary and marked this issue as a duplicate of 373

c4-judge commented 6 months ago

alcueca marked the issue as satisfactory

alcueca commented 6 months ago

The try/catch would send the tokens at a better place to recover them, at least.