Closed c4-submissions closed 1 year ago
0xA5DF marked the issue as primary issue
0xA5DF marked the issue as sufficient quality report
There is no issue here, it is not part of any system function the Bridge Agents being able to retain ETH balance.
0xBugsy (sponsor) disputed
alcueca marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/RootBridgeAgent.sol#L788 https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/RootBridgeAgent.sol#L938 https://github.com/LayerZero-Labs/LayerZero/blob/48c21c3921931798184367fc02d3a8132b041942/contracts/Endpoint.sol#L95
Vulnerability details
Impact
_performFallbackCall can revert sliently when refundee is not capable of taking ETH refund from layerzero side
Proof of Concept
In RootBridgeAgent.sol when the has fall back toggle flag is on, the smart contract aim to perform a fallback call to notify the dest chain the failure to deliver the message
for example, the relevent code is here
and here when retrieve the deposit
the logicof the _performFallbackCall is here
the code forward all ETH (address(this).balance) and aim to use the ETH to pay for the layerzero fee
after the message is sent via the endpoint, the layerzero endpoint foward the message to UltraLightNodeV2
the code quote the fee and refund the excessive fee to the refundee address
but if the refundee address is capable of taking the ETH refund, the refundee takes all the ETH in the agent contract minus the layerzero fee paid
the relevant logic on layerzero UltraLightNodeV2 is here: in this line of code
can add this test into the BranchBridgeAgentTest.t.sol to prove that excessive ETH is refunded to the refundee
assume the agent contract hold 1 ETH, and the fee required is 0.01 ETH, the refund can take the rest 0.99 ETH and clear the ETH hold in the agent contract
the POC shows that the message is sent successfully but the refundee address takes the remaining refunded fee
then add
and we can run the fork test
the full transaction log is attached
note, the BranchBridgeAgent has the same problem when executing fallback call
basically user can observe the ETH balacne of the agent contract and turn on the fallback flag and revert intentionally and then trigger the fallback to take the ETH in the agent as layerzero fee refund
Tools Used
Manual Review, foundry
Recommended Mitigation Steps
use layerzero estimate fee endpoint to estimate the fee instead of sending all ETH as fee
or the protocol may consider set the refundee to the agent contract itself to make sure the excessive refunded fee goes back
Assessed type
ETH-Transfer